Get its center, radius and angle from a circle's string

string_to_circle(x, y, xend, yend, radian = NULL, radius = NULL)

Arguments

x, y, xend, yend

start and end points defining a string of a circle

radian

angle of the string.

radius

radius of the circle. Only used if radian is NULL or 2*pi.

Value

a list of center, radius, string.start, string.end, angle, angle.start, angle.end

Details

For a string, given its radian or radius, there will be two circle centers matched. This function will return both centers in a order of left center and right center. For brevity, the radian will always less than pi (0-2*pi).

Examples

string_to_circle(-1, 0, 1, 0, pi)
#> $radius #> [1] 1 #> #> $string.start #> [1] -1 0 #> #> $string.start #> [1] 1 0 #> #> $angle #> [1] 3.141593 #> #> $left #> $left$center #> [1] 0 0 #> #> $left$angle.start #> [1] 3.141593 #> #> $left$angle.end #> [1] 0 #> #> #> $right #> $right$center #> [1] 0 0 #> #> $right$angle.start #> [1] 3.141593 #> #> $right$angle.end #> [1] 0 #> #>
string_to_circle(-1, 0, 1, 0, pi/2)
#> $radius #> [1] 1.414214 #> #> $string.start #> [1] -1 0 #> #> $string.start #> [1] 1 0 #> #> $angle #> [1] 1.570796 #> #> $left #> $left$center #> [1] -6.123032e-17 1.000000e+00 #> #> $left$angle.start #> [1] -2.356194 #> #> $left$angle.end #> [1] -0.7853982 #> #> #> $right #> $right$center #> [1] 6.123032e-17 -1.000000e+00 #> #> $right$angle.start #> [1] 2.356194 #> #> $right$angle.end #> [1] 0.7853982 #> #>
string_to_circle(0, 1, 0, -1, pi/2)
#> $radius #> [1] 1.414214 #> #> $string.start #> [1] 0 1 #> #> $string.start #> [1] 0 -1 #> #> $angle #> [1] 1.570796 #> #> $left #> $left$center #> [1] -1 0 #> #> $left$angle.start #> [1] 0.7853982 #> #> $left$angle.end #> [1] -0.7853982 #> #> #> $right #> $right$center #> [1] 1 0 #> #> $right$angle.start #> [1] 2.356194 #> #> $right$angle.end #> [1] -2.356194 #> #>