/// <summary> /// Construct from a KSP celestial body object. /// </summary> public CelestialBody(global::CelestialBody body) { InternalBody = body; if (body.name != Planetarium.fetch.Sun.name) { orbit = new Orbit(body); } }
internal static ReferenceFrame Orbital(global::CelestialBody body) { if (body == body.referenceBody || body.orbit == null) { throw new ArgumentException("CelestialBody '" + body.name + "' does not orbit anything"); } return(new ReferenceFrame(ReferenceFrameType.CelestialBodyOrbital, body)); }
internal Orbit(global::CelestialBody body) { if (body == body.referenceBody) { throw new ArgumentException("Body does not orbit anything"); } InternalOrbit = body.GetOrbit(); }
private void _pushBody(global::CelestialBody body) { celestialBodies.Add(new game.CelestialBody(this, body)); foreach (var subbody in body.orbitingBodies) { _pushBody(subbody); } }
public void update(global::CelestialBody body) { name = body.GetName(); position = new Vector3(body.position); rotation = new Quaternion(body.rotation); radius = body.Radius; mass = body.Mass; gravParameter = body.gravParameter; }
ReferenceFrame( Type type, global::CelestialBody body = null, global::Vessel vessel = null, ManeuverNode node = null, Part part = null, ModuleDockingNode dockingPort = null) { this.type = type; this.body = body; this.vesselId = vessel != null ? vessel.id : Guid.Empty; this.node = node; //TODO: is it safe to use a part id of 0 to mean no part? this.partId = part != null ? part.flightID : 0; this.dockingPort = dockingPort; }
public static Vector3d GetWorldVelocity(this global::CelestialBody body) { if (body != body.referenceBody) { // Body orbits something return(body.GetOrbit().GetVel()); } else { // Body does not orbit anything // Get a body that orbits the sun var orbitingBody = FlightGlobals.Bodies.Find(b => b.name != "Sun" && b.GetOrbit().referenceBody == body); var orbit = orbitingBody.GetOrbit(); // Compute the velocity of the sun in world space from this body // Can't be done for from the sun object as it has no orbit object return(orbit.GetVel() - orbit.GetRelativeVel()); } }
ReferenceFrame( ReferenceFrameType type, global::CelestialBody body = null, global::Vessel vessel = null, ManeuverNode node = null, Part part = null, ModuleDockingNode dockingPort = null, Thruster thruster = null, ReferenceFrame parent = null, ReferenceFrame hybridPosition = null, ReferenceFrame hybridRotation = null, ReferenceFrame hybridVelocity = null, ReferenceFrame hybridAngularVelocity = null) { this.type = type; this.body = body; vesselId = vessel != null ? vessel.id : Guid.Empty; this.node = node; //TODO: is it safe to use a part id of 0 to mean no part? if (part != null) { partId = part.flightID; } this.dockingPort = dockingPort; this.thruster = thruster; this.parent = parent; this.hybridPosition = hybridPosition; this.hybridRotation = hybridRotation; this.hybridVelocity = hybridVelocity; this.hybridAngularVelocity = hybridAngularVelocity; }
internal static ReferenceFrame NonRotating(global::CelestialBody body) { return(new ReferenceFrame(ReferenceFrameType.CelestialBodyNonRotating, body, null, null)); }
internal static ReferenceFrame Object(global::CelestialBody body) { return(new ReferenceFrame(ReferenceFrameType.CelestialBody, body)); }
public CelestialBody(Universe universe, global::CelestialBody body) : this(universe) { update(body); }
/// <summary> /// Vector from center of given body to north pole of body being orbited, in world space. /// </summary> static Vector3d ToNorthPole(global::CelestialBody body) { var parent = body.referenceBody; return(parent.position + (((Vector3d)parent.transform.up) * parent.Radius) - body.position); }