/// <summary> /// Debug draw periapsis, apoapsis and center points in scene window /// </summary> /// <param name="body"></param> static void DrawOrbitPointsInEditorFor(CelestialBody body) { if (!body.isActiveAndEnabled || body.IsFixedPosition || body.Attractor == null || body.RelativeVelocity == Vector2.zero || !body.IsValidOrbit()) { return; } var size = 1f; DebugDrawX(body.CenterPoint, size, Color.red); DebugDrawX(body.Periapsis, size, Color.green); Handles.color = Color.blue; /* Handles.DrawLine( body._transform.position, body.Attractor._transform.position ); * //additional optional debug lines: Vector2 meanLine = new Vector2( 0, 3 ) * body._radiusVectorMagnitude; meanLine = CelestialBody.RotateVectorByAngle( meanLine, body._argumentOfPeriapsis + body._meanAnomaly ); Handles.color = Color.yellow; Handles.DrawLine( body._centerPoint, body._centerPoint + meanLine ); Vector2 eccLine = new Vector2( 0, 3 ) * body._radiusVectorMagnitude; eccLine = CelestialBody.RotateVectorByAngle( eccLine, body._argumentOfPeriapsis + body._eccentricAnomaly ); Handles.color = Color.white; Handles.DrawLine( body._centerPoint, body._centerPoint + eccLine ); Vector2 trueLine =new Vector2( 0, 2 ) * body._radiusVectorMagnitude; trueLine = CelestialBody.RotateVectorByAngle( trueLine, body._argumentOfPeriapsis + body._trueAnomaly ); Handles.color = Color.cyan; Handles.DrawLine( body._focusPoint, body._focusPoint + trueLine ); */ Handles.color = Color.white; if (body.Eccentricity < 1) { DebugDrawX(body.Apoapsis, size, Color.yellow); //apoasis become infinity if eccentricity >= 1 } }
/// <summary> /// Debug draw periapsis, apoapsis and center points in scene window /// </summary> /// <param name="body"></param> static void DrawOrbitPointsInEditorFor(CelestialBody body) { if (!body.isActiveAndEnabled || body.IsFixedPosition || body.Attractor == null || body.RelativeVelocity == Vector2.zero || !body.IsValidOrbit()) { return; } var size = 1f; DebugDrawX(body.CenterPoint, size, Color.red); DebugDrawX(body.Periapsis, size, Color.green); Handles.color = Color.blue; /* * Handles.DrawLine( body._transform.position, body.Attractor._transform.position ); * //additional optional debug lines: * Vector2 meanLine = new Vector2( 0, 3 ) * body._radiusVectorMagnitude; * meanLine = CelestialBody.RotateVectorByAngle( meanLine, body._argumentOfPeriapsis + body._meanAnomaly ); * Handles.color = Color.yellow; * Handles.DrawLine( body._centerPoint, body._centerPoint + meanLine ); * Vector2 eccLine = new Vector2( 0, 3 ) * body._radiusVectorMagnitude; * eccLine = CelestialBody.RotateVectorByAngle( eccLine, body._argumentOfPeriapsis + body._eccentricAnomaly ); * Handles.color = Color.white; * Handles.DrawLine( body._centerPoint, body._centerPoint + eccLine ); * Vector2 trueLine =new Vector2( 0, 2 ) * body._radiusVectorMagnitude; * trueLine = CelestialBody.RotateVectorByAngle( trueLine, body._argumentOfPeriapsis + body._trueAnomaly ); * Handles.color = Color.cyan; * Handles.DrawLine( body._focusPoint, body._focusPoint + trueLine ); */ Handles.color = Color.white; if (body.Eccentricity < 1) { DebugDrawX(body.Apoapsis, size, Color.yellow); //apoasis become infinity if eccentricity >= 1 } }