Answers for "What's the most efficient way to rotate a Vector2 of a certain angle around the axis orthogonal to the plane they describe?"
http://answers.unity.com/questions/661383/whats-the-most-efficient-way-to-rotate-a-vector2-o.html
The latest answers for the question "What's the most efficient way to rotate a Vector2 of a certain angle around the axis orthogonal to the plane they describe?"Answer by DDP
http://answers.unity.com/answers/734946/view.html
What about using an extension method?
using UnityEngine;
public static class Vector2Extension {
public static Vector2 Rotate(this Vector2 v, float degrees) {
float sin = Mathf.Sin(degrees * Mathf.Deg2Rad);
float cos = Mathf.Cos(degrees * Mathf.Deg2Rad);
float tx = v.x;
float ty = v.y;
v.x = (cos * tx) - (sin * ty);
v.y = (sin * tx) + (cos * ty);
return v;
}
}
Can be use that way:
Vector2 direction = Vector2.right.Rotate(45f);Wed, 25 Jun 2014 16:12:57 GMTDDPAnswer by whydoidoit
http://answers.unity.com/answers/661418/view.html
Well if it works don't knock it. You could also do this:
return Quaternion.AngleAxis(_angle, Vector3.forward) * normalizedDirection;Tue, 11 Mar 2014 18:41:30 GMTwhydoidoit