This function transforms the coordinates of spline data between Cartesian and polar coordinate systems. The origin x and y coordinates can be supplied by the user, or calculated automatically (see Details).
Usage
transform_coord(
data,
to = "polar",
origin = NULL,
fan_lines = c(10, 25),
use_XY = FALSE
)
Arguments
- data
A data set containing the spline coordinates (cartesian coordinates must be in columns named
X
andY
, polar coordinates in columns namedangle
andradius
; these are the defaults in data imported withread_aaa()
).- to
Which system to convert to, as a string, either
"polar"
or"cartesian"
(the default is"polar"
).- origin
The coordinates of the origin as a vector of
c(x, y)
coordinates.- fan_lines
A numeric vector with two fan lines (the default is
c(10, 25)
).- use_XY
Whether to use the column names
X
andY
when converting to and from polar coordinates, rather than the defaultangle
andradius
(the default isFALSE
. IfTRUE
, the columnsX
andY
are overwritten with the converted values. If converting to polar,X
is theangle
andY
theradius
.
Value
An object of class tbl_df-class
(a tibble).
Details
The transformation between the coordinate systems require the selection of an
origin in Cartesian coordinates (x and y). The origin ideally corresponds to
the virtual origin of the ultrasound waves from the probe. The origin
coordinates can be supplied by the user as a vector with the origin
argument, or they can be estimated automatically if origin = NULL
(the
default). The estimation is performed by get_origin
(see that
function documentation for details).