public Tuple3 BedrockPosition(double latitude, double longitude, ReferenceFrame referenceFrame) { var altitude = BedrockHeight(latitude, longitude); var position = InternalBody.GetWorldSurfacePosition(latitude, longitude, altitude); return(referenceFrame.PositionFromWorldSpace(position).ToTuple()); }
Tuple3 PositionAt (double latitude, double longitude, double altitude, ReferenceFrame referenceFrame) { if (ReferenceEquals (referenceFrame, null)) throw new ArgumentNullException (nameof (referenceFrame)); var position = InternalBody.GetWorldSurfacePosition (latitude, longitude, altitude); return referenceFrame.PositionFromWorldSpace (position).ToTuple (); }
public double SurfaceHeight (double latitude, double longitude) { var alt = Math.Max (0, BedrockHeight (latitude, longitude)); // Using raycast to find real surface height. const double raySource = 1000; const double raySecondPoint = 500; Vector3d rayCastStart = InternalBody.GetWorldSurfacePosition(latitude, longitude, alt + raySource); Vector3d rayCastStop = InternalBody.GetWorldSurfacePosition(latitude, longitude, alt + raySecondPoint); RaycastHit hit; //Casting a ray on the surface (layer 15 in KSP). if (Physics.Raycast(rayCastStart, (rayCastStop - rayCastStart), out hit, float.MaxValue, 1 << 15)) { // Ensure hit is on the topside of planet, near the rayCastStart, not on the far side. if (Mathf.Abs(hit.distance) < 3000) { // Okay, a hit was found, use it instead of PQS alt: alt = alt + raySource - hit.distance; } } return alt; }
public Tuple3 MSLPosition(double latitude, double longitude, ReferenceFrame referenceFrame) { var position = InternalBody.GetWorldSurfacePosition(latitude, longitude, 0); return(referenceFrame.PositionFromWorldSpace(position).ToTuple()); }