// ** Begin public void Draw3D(RenderContext11 renderContext, float opacity, Vector3d centerPoint) { Matrix3d orbitalPlaneOrientation = Matrix3d.RotationZ(Coordinates.DegreesToRadians(elements.w)) * Matrix3d.RotationX(Coordinates.DegreesToRadians(elements.i)) * Matrix3d.RotationZ(Coordinates.DegreesToRadians(elements.omega)); // Extra transformation required because the ellipse shader uses the xy-plane, but WWT uses the // xz-plane as the reference. orbitalPlaneOrientation = orbitalPlaneOrientation * orbitalToWwt; Matrix3d worldMatrix = orbitalPlaneOrientation * Matrix3d.Translation(centerPoint) * renderContext.World; double M = elements.n * (SpaceTimeController.JNow - elements.T); double F = 1; if (M < 0) { F = -1; } M = Math.Abs(M) / 360.0; M = (M - (int)(M)) * 360.0 * F; Color color = Color.FromArgb((int)(opacity * 255.0f), orbitColor); // Newton-Raphson iteration to solve Kepler's equation. // This is faster than calling CAAKepler.Calculate(), and 5 steps // is more than adequate for draw the orbit paths of small satellites // (which are ultimately rendered using single-precision floating point.) M = Coordinates.DegreesToRadians(M); double E = M; for (int i = 0; i < 5; i++) { E += (M - E + elements.e * Math.Sin(E)) / (1 - elements.e * Math.Cos(E)); } renderContext.DepthStencilMode = DepthStencilMode.ZReadOnly; renderContext.BlendMode = BlendMode.Alpha; EllipseRenderer.DrawEllipse(renderContext, elements.a / scale, elements.e, E, color, worldMatrix); renderContext.DepthStencilMode = DepthStencilMode.ZReadWrite; }