A, B and Center are 2D vector points.
n is the length of the circle's circumference from A to B.
I want to get B.
I'm looking for a way to pop in A, Center, n and the circle's radius to pop out vector point B.
(I'm coding with C# in Unity using Mathf, but I don't need code as an answer, just some basic steps should help plenty, thanks)
All angles are in radians. Your n is whats called the circles arc.
public Vector2 RotateByArc(Vector2 Center, Vector2 A, float arc)
{
//calculate radius
float radius = Vector2.Distance(Center, A);
//calculate angle from arc
float angle = arc / radius;
Vector2 B = RotateByRadians(Center, A, angle);
return B;
}
public Vector2 RotateByRadians(Vector2 Center, Vector2 A, float angle)
{
//Move calculation to 0,0
Vector2 v = A - Center;
//rotate x and y
float x = v.x * Mathf.Cos(angle) + v.y * Mathf.Sin(angle);
float y = v.y * Mathf.Cos(angle) - v.x * Mathf.Sin(angle);
//move back to center
Vector2 B = new Vector2(x, y) + Center;
return B;
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With