//--------------Static Functions----------------// /// <summary> /// the angle difference from angle1 to angle2 (in radians) /// </summary> /// <param name="angle1"></param> /// <param name="angle2"></param> /// <returns></returns> public static double Angle(double angle1, double angle2) { Polar2d angle1Pol = new Polar2d(1, angle1); Polar2d angle2Pol = new Polar2d(1, angle2); return(Vector2d.Angle(angle1Pol.cartesian, angle2Pol.cartesian) * Mathd.Deg2Rad); }
public void Angle() { for (int i = 0; i < count; i++) { float ax, ay; float bx, by; ax = UnityEngine.Random.Range(-10F, 10F); ay = UnityEngine.Random.Range(-10F, 10F); bx = UnityEngine.Random.Range(-10F, 10F); by = UnityEngine.Random.Range(-10F, 10F); Vector2 a = new Vector2(ax, ay); Vector2 b = new Vector2(bx, by); Vector2d ad = new Vector2d(ax, ay); Vector2d bd = new Vector2d(bx, by); float value = Vector2.Angle(a, b); float valued = Vector2d.Angle(ad, bd); if ((Mathf.Abs(value - valued) < deviation)) { Assert.True(true); } else { Assert.Fail(string.Format("{0}\n{1}", value.ToString("0.00000"), valued.ToString("0.00000"))); } } }
public static double AngularRadius(double radius, double distance) { Vector2d center = Vector2d.zero; Vector2d point = center + distance * Vector2d.right; double x_offset = CircleCircleIntersectionOffset(radius, distance / 2, distance / 2); // offset is the x-coord of a point on the body. double y_offset = Math.Sqrt((radius * radius) - (x_offset * x_offset)); Vector2d calc; calc.x = x_offset; calc.y = y_offset; return(Vector2d.Angle(center - point, calc - point)); }