I have a circle with a known radius centered at the origin.
Radius <- 1
Horizontal_Coordinates <- seq(-Radius, Radius, 0.01)
Positive_Vertical_Coordinates <- sqrt((Radius ^ 2) - (Horizontal_Coordinates ^ 2))
Negative_Vertical_Coordinates <- -sqrt((Radius ^ 2) - (Horizontal_Coordinates ^ 2))
Circle_Coordinates <- data.frame(Horizontal_Coordinates = c(Horizontal_Coordinates, rev(Horizontal_Coordinates), Horizontal_Coordinates[1]), Vertical_Coordinates = c(Positive_Vertical_Coordinates, rev(Negative_Vertical_Coordinates), Positive_Vertical_Coordinates[1]))
plot(0, type = "n", xlim = c(-(Radius * 1.05), (Radius * 1.05)), ylim = c(-(Radius * 1.05), (Radius * 1.05)), xlab = "", ylab = "")
polygon(Circle_Coordinates$Horizontal_Coordinates, Circle_Coordinates$Vertical_Coordinates)
I also have two points (these two happen to have been chosen at random) that fall somewhere along the perimeter of this circle.
Random_Angle_1 <- runif(1, 0, (2 * pi))
Random_Angle_2 <- runif(1, 0, (2 * pi))
Point_1 <- c(cos(Random_Angle_1), sin(Random_Angle_1))
Point_2 <- c(cos(Random_Angle_2), sin(Random_Angle_2))
points(Point_1[1], Point_1[2], pch = 19, col = 2)
points(Point_2[1], Point_2[2], pch = 19, col = 2)
The Circle_Coordinates
data frame is of particular interest to me. I want to subset this data frame so that it only includes values that fall between the two points that are red in the figure. The two points will never fall directly opposite on the circle from each other, so there will always be a shorter arc and a longer arc between them. I’m interested only in the shorter arc – I want to subset the data frame so it only includes values that fall on the shorter arc.