public void AngleBetween() { for (int i = 0; i < count; i++) { float ax, ay, az; float bx, by, bz; ax = UnityEngine.Random.Range(-10F, 10F); ay = UnityEngine.Random.Range(-10F, 10F); az = UnityEngine.Random.Range(-10F, 10F); bx = UnityEngine.Random.Range(-10F, 10F); by = UnityEngine.Random.Range(-10F, 10F); bz = UnityEngine.Random.Range(-10F, 10F); Vector3 a = new Vector3(ax, ay, az); Vector3 b = new Vector3(bx, by, bz); Vector3d ad = new Vector3d(ax, ay, az); Vector3d bd = new Vector3d(bx, by, bz); float value = Vector3.AngleBetween(a, b); float valued = Vector3d.AngleBetween(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"))); } } }
/// <summary> /// Override this function and use <see cref="Current"/> instead of Planetarium sun /// </summary> public override Double GetLocalTimeAtPosition(Vector3d wPos, CelestialBody cb) { Vector3d pos1 = Vector3d.Exclude(cb.angularVelocity, FlightGlobals.getUpAxis(cb, wPos)); Vector3d pos2 = Vector3d.Exclude(cb.angularVelocity, Current.sun.position - cb.position); #pragma warning disable CS0618 Double angle = (Vector3d.Dot(Vector3d.Cross(pos2, pos1), cb.angularVelocity) < 0 ? -1 : 1) * Vector3d.AngleBetween(pos1, pos2) / 6.28318530717959 + 0.5; #pragma warning restore CS0618 if (angle > Math.PI * 2) { angle -= Math.PI * 2; } return(angle); }