- Home /
Given a point, a "radius" and an arc, how do I find the resulting point?
Like this diagram here
What is the value of X and Y? Even if someone just knows generally mathematically how to do it.
Answer by Eno-Khaon · Nov 18, 2017 at 11:47 AM
When you already know the center point for the rotation as well as the angle, this is a simple and straightforward transformation to apply.
Fundamentally, the calculations are based on a 2-Dimensional, 2x2 rotation matrix.
// Where "T" is the rotation value theta, or θ
┌ ┐
|cos(T) -sin(T)|
|sin(T) cos(T) |
└ ┘
When you apply this to a given value, it will look something like this:
// C#
public static Vector2 RotatePoint(Vector2 inputPoint, Vector2 center, float degrees)
{
// First, convert degrees to radians
float radians = degrees * Mathf.Deg2Rad;
// Then, create the output
Vector2 outputPoint = inputPoint;
// Next, shift the input based on the center of rotation
Vector2 shiftedPoint = inputPoint - center;
// Finally, apply the values from the matrix to the X and Y
outputPoint.x = center.x + (shiftedPoint.x * Mathf.Cos(radians) - shiftedPoint.y * Mathf.Sin(radians));
outputPoint.y = center.y + (shiftedPoint.y * Mathf.Cos(radians) + shiftedPoint.x * Mathf.Sin(radians));
return outputPoint;
}
Your answer
Follow this Question
Related Questions
How to get a vector3 (postion) 1 unit away from another in the direction of a 3rd vector3? 2 Answers
Math behind Transform.TransformPoint? 1 Answer
Moveing on a Sphere in direction of Camera with Math 0 Answers
How can I calculate the Vector3 b using Vector 3 a pos with an angle? 1 Answer
Given a vector, how do i generate a random perpendicular vector? 5 Answers