# How to find the angle of an arc for reflection

I am using the following code to calculate points for a circle arc drawn with a Line Renderer.

for (int i = 0; i <= pts; i++)
{

arcLine.positionCount = i + 1;
arcLine.SetPosition(i, new Vector2(x, y));
ang += (float)totalAngle / pts;

}


How can I change the angle ang to create a reflected arc along the line P1P2 as in the image below?

Please note that totalAngle represents the portion of the circle that is to be drawn between 0 and 360.

• Funny enough, I just finished writing an answer about circular arc interpolation that covers flipping the arc. – DMGregory Apr 17 '18 at 12:41
• @DMGreogory I've done a lot of work the relies on the code I provided, that's why I wanted a solution that could possibly work with changing the angle. Not sure if that's possible. – Hilarious404 Apr 17 '18 at 16:30
• You'll need to also change the center point of the circle, since the second arc lies on a circle with a different center. – DMGregory Apr 17 '18 at 17:08
• @DMGregory I also tried adding the center value to my values, E.g, float x = center.x + radius * Mathf.Cos(ang * Mathf.Deg2Rad); and float y = radius * Mathf.Sin(ang * Mathf.Deg2Rad); and calculated the center as you did in the linked solution but that gave me the same result as before. – Hilarious404 Apr 17 '18 at 17:14

I'm assuming the code handles a special case where the circle center is [0,0] and the arc is drawn is counterclockwise from the point [radius,0].

The idea is to reflect all points across a line in space, defined by P0 and P1, where P0 is the starting point [radius,0] and P1 is the last point on the arc, or [radius * cos(totalAngle), radius * sin(totalAngle)]. Note, if a more general arc drawing algorithm were used, you could place the circle center at the reflected location, as proposed, but you still might need similar math to find that reflected location.

First step, redefine the line as P0 and a unit direction, which is VUnitDirection = normalize(P1-P0). Second step, move each point into a coordinate space where P0 is at the origin, which is PRelative = (P0-point). Third step, project the point onto the line, by finding how far along the line its projection lies, which is SAlong = dotProduct(PRelative,VUnitDirection), and then find the actual projected point by moving along the line that distance, which is PProjected = P0 + (SAlong*VUnitDirection). The distance between the original point and the projected point must be traversed twice to reach the reflected point, so calculate VOffset = PProjected - point, and finally, PFinal = PProjected + VOffset.

The code below is tested in 3ds max using the MaxScript language, a personal preference for prototyping. Note array access is 1-based, so a[1] is the first element of an array.

radius = 50.0
pointCount = 20
pointList = #() -- empty array
totalAngle = 95.0
ang = 0

for i = 1 to pointCount do
(
x = radius * (cos ang)
y = radius * (sin ang)
ang = ang + (totalAngle / (pointCount-1))
Point position:[x,y,0] size:1 wirecolor:red
append pointList [x,y,0]
)