-
Notifications
You must be signed in to change notification settings - Fork 1
Curve Drawing
Written by JC Luna.
Space Teams PRO provides a simple programming interface for drawing custom curves within the graphical client. Curves exist in the simulation as entities and share the location and orientation of the entity that represents their origin. This means that you can represent an orbit defined in the Earth Centered Inertial frame by placing the curve entity at origin of the Earth Centered Inertial entity found in many Solar System simulations, for example.
Note that the specific names vary by implementation language.
- AutoUpdates
- Boolean
- Whether or not the curve automatically redraws itself.
- Defaults to true.
- Closed
- Boolean
- Whether or not the curve closes in on itself. When true, the first and last points are connected in a curve
- Defaults to false.
- Color
- DoubleV4
- The color of the curve, in normalized RGBA space.
- Defaults to opaque red:
(1, 0, 0, 1).
- OriginEntity
- EntityRef
- The entity that represents the curve's origin.
- Points
- Array of DoubleV3
- The points to plot, in kilometers.
- RequiresUpdate
- Boolean
- Whether or not the curve should redraw itself. This is always true for a curve that automatically updates itself.
- Header File:
Visualization/CurveDrawing.h - Namespace:
spaceteams::vis::curves- Key Members of This Namespace
params::InitParamsDrawCurve()SetPoints()GetPoints()
- Key Members of This Namespace
Inclusion of Visualization/CurveDrawing.h is the minimum amount of work required to use curves.
With this,
there are several options for curve drawing through the multiple overloads of DrawCurve() which use:
-
params::InitParamsstruct usage - A
spaceteams::SimGlobals::AddEntityFromConfig()-like interface - Verbose positional arguments
Since the curve created through these methods is an entity,
it is possible to update its appearance after initialization using the SetParam() function.
The param keys to use are located under spaceteams::vis::curves::params.
For the common action of setting and getting points from a curve,
SetPoints() and GetPoints() functions exist under the curves namespace.
Points are measured in kilometers.
Consider the example of an orbit with points expressed in the non-inertial Earth-centered, Earth-fixed frame. You can represent this using the curve drawing interface.
The example assumes that the following exists in code:
#include "Visualization/CurveDrawing.h"
using namespace spaceteams::vis::curves;These exist alongside the following declarations. Details on both how points for the orbit and the reference to the Earth are acquired are withheld:
std::vector<SC_DoubleV3> points; // in km
SC_EntityRef earth;Finally, a call to DrawCurve().
This uses the preferrable first method.
params::InitParams initParams;
initParams.OriginEntity = earth;
initParams.Points = points;
initParams.Closed = true;
initParams.Color = SC_DoubleV4(0.0, 0.0, 1.0, 1.0);
SC_EntityRef curve = DrawCurve(initParams);Calls to SetPoints() offer another way of setting the points visualized,
Initialization with points is offered for convenience.
- Module:
spaceteams.vis.curves - Key Members of This Module:
DrawCurve()SetPoints()GetPoints()
Python conveniently allows for passage of named arguments, with no set order, through keyword arguments.
A call to DrawCurve() still returns an entity representing the curves,
and the regular routines of getting and setting points still exist.
Consider an orbit about the Earth in a non-inertial Earth-centered, Earth-fixed frame. These code snippets, working off of the Python system template, demonstrate how to achieve this result.
First, consider that these declarations contain references to the Earth and the points of some craft about it, expressed in the same non-inertial basis as above. Implementation details are intentionally left vague, again.
earth: st.Entity
points: list[np.array] = [ ] # in kmCurve drawing is now simply done:
curve = st.vis.curves.DrawCurve(
earth,
color = [0.0, 0.0, 1.0, 1.0],
closed = True,
points = points)Module aliasing is possible as desired, to shorten multiple calls to curve drawing utilities:
curves = st.vis.curvesYou can additionally make calls to SetPoints() and GetPoints()
to set and get points to draw as desired.
