public static Vector3d GetPlanet3dLocationJD(SolarSystemObjects target, double jNow) { try { Vector3d result = new Vector3d(); AstroRaDec centerRaDec = AstroCalc.GetPlanet(jNow, 0, 0, 0, -6378149); Vector3d center = (Vector3d)Coordinates.RADecTo3dAu(centerRaDec.RA, centerRaDec.Dec, centerRaDec.Distance); if (target == SolarSystemObjects.Earth) { result = Vector3d.Create(-center.X, -center.Y, -center.Z); } else { AstroRaDec planet = AstroCalc.GetPlanet(jNow, (EO)(int)target, 0, 0, -6378149); result = (Vector3d)Coordinates.RADecTo3dAu(planet.RA, planet.Dec, planet.Distance); result.Subtract(center); } result.RotateX(Coordinates.MeanObliquityOfEcliptic(jNow) * RC); if (Settings.Active.SolarSystemScale != 1) { switch (target) { case SolarSystemObjects.Moon: { Vector3d parent = (Vector3d)GetPlanet3dLocationJD(SolarSystemObjects.Earth, jNow); // Parent Centric result.Subtract(parent); result.Multiply(Settings.Active.SolarSystemScale / 2); result.Add(parent); } break; case SolarSystemObjects.Io: case SolarSystemObjects.Europa: case SolarSystemObjects.Ganymede: case SolarSystemObjects.Callisto: { Vector3d parent = (Vector3d)GetPlanet3dLocationJD(SolarSystemObjects.Jupiter, jNow); // Parent Centric result.Subtract(parent); result.Multiply(Settings.Active.SolarSystemScale); result.Add(parent); } break; default: break; } } return (Vector3d)result; } catch { return Vector3d.Create(0, 0, 0); } }
void InitLineBuffer(RenderContext renderContext) { if (renderContext.gl != null) { if (lineBuffers.Count == 0) { int count = linePoints.Count; PositionVertexBuffer lineBuffer = null; Vector3d[] linePointList = null; localCenter = new Vector3d(); if (DepthBuffered) { // compute the local center.. foreach (Vector3d point in linePoints) { localCenter.Add(point); } localCenter.X /= count; localCenter.Y /= count; localCenter.Z /= count; } int countLeft = count; int index = 0; int counter = 0; Vector3d temp; foreach (Vector3d point in linePoints) { if (counter >= 100000 || linePointList == null) { if (lineBuffer != null) { lineBuffer.Unlock(); } int thisCount = Math.Min(100000, countLeft); countLeft -= thisCount; lineBuffer = new PositionVertexBuffer(thisCount); linePointList = (Vector3d[])lineBuffer.Lock(); // Lock the buffer (which will return our structs) lineBuffers.Add(lineBuffer); lineBufferCounts.Add(thisCount); counter = 0; } if (UseLocalCenters) { temp = Vector3d.SubtractVectors(point, localCenter); linePointList[counter] = temp; } else { linePointList[counter] = point; } index++; counter++; } if (lineBuffer != null) { lineBuffer.Unlock(); } } } }