public static Vector2 PolarToCartesian(this Vector2Polar p) { Vector2 result = new Vector2(); result.X = (float)(p.Radius * Math.Cos(p.Theta)); result.Y = (float)(p.Radius * Math.Sin(p.Theta)); return(result); }
public static Vector2Polar Add(this Vector2Polar a,Vector2Polar b) { var X = Math.Cos(a.Theta)*a.Radius + Math.Cos(b.Theta)*b.Radius; var Y = Math.Sin (a.Theta) * a.Radius + Math.Sin (b.Theta) * b.Radius; var theta = Math.Atan2(Y,X); theta = NormalizeAngle (theta); var radius = Math.Sqrt (X * X + Y * Y); return new Vector2Polar () { Theta = (float)theta, Radius = (float)radius }; }
public static Vector2Polar Add(this Vector2Polar a, Vector2Polar b) { var X = Math.Cos(a.Theta) * a.Radius + Math.Cos(b.Theta) * b.Radius; var Y = Math.Sin(a.Theta) * a.Radius + Math.Sin(b.Theta) * b.Radius; var theta = Math.Atan2(Y, X); theta = NormalizeAngle(theta); var radius = Math.Sqrt(X * X + Y * Y); return(new Vector2Polar() { Theta = (float)theta, Radius = (float)radius }); }