cartesian_to_xy.Rd
Convert canvas coordinates to the data coordinates
cartesian_to_xy(x, y, track_index = current_track_index())
X-locations of the data points in canvas coordinates.
Y-locations of the data points in canvas coordinates.
Index of the track.
The data points are assigned to the nearest inner loops. Denote the a data point has a coordinate (r, theta) in the polar coordinate system, r_k and r_k+1 are the radius of the two loops at theta + 2*pi*a and theta + 2*pi*(a+1) that below and above the data point, the data point is assigned to the loop k.
A data frame with two columns: x and y.
x = runif(100, -5, 5)
y = runif(100, -5, 5)
spiral_initialize()
spiral_track()
df = cartesian_to_xy(x, y)
# directly draw in the viewport
grid.points(x, y, default.units="native")
# check whether the converted xy are correct (should overlap to the previous points)
spiral_points(df$x, df$y, pch = 16)