I would like to create an ellipse that goes all around Earth, to represent a satellite' trajectory. I would like to give it a center, a semi major axis, a semi minor axis, an inclinaison. I have done this code, but it gives something not perfectly around Earth, or not properly located. I haven't found any answers on the internet since a week of research.
Perhaps, I should locate the center with Cartesian Coordinates but I don't know how, it seems that all objects are located with longitude, latitude and not x, y,z on cesium.
var greenCircle = viewer.entities.add({
position: Cesium.Cartesian3.fromDegrees(90, 0),
name : 'Green circle at height with outline',
ellipse : {
semiMinorAxis : 7000000.0,
semiMajorAxis : 11000000.0,
fill: false,
outline: true,
outlineColor: Cesium.Color.YELLOW,
outlineWidth: 2.0
}
});
Hi there,
When we render satellite trajectories in Cesium, we use Polylines with the pre-calculated positions. Here’s a quick example:
var viewer = new Cesium.Viewer(‘cesiumContainer’);
var semiMinorAxis = 7000000.0;
var semiMajorAxis = 11000000.0;
var positions = ;
for (var i = -180; i <= 180; i+=10) {
var axis = semiMinorAxis + Math.cos(i * Math.PI / 180.0) * (semiMajorAxis - semiMinorAxis);
positions.push(Cesium.Cartesian3.fromDegrees(i, 0, axis));
}
var entity = viewer.entities.add({
polyline : {
positions : positions,
followSurface : true,
width : 4,
material : Cesium.Color.RED
}
});
viewer.zoomTo(viewer.entities);
``
Thanks,
Gabby
1 Like
First, I wanted to thank @Gabby_Getz for this incredibly helpful response – I have been trying to figure this out and I don’t know how I haven’t seen this until now! I just wanted to fix the formatting. I should warn, however, that my use case only needed 2GB of RAM when I used SampledPositionProperty, but attempted to eat an entire 15GB when I tried to do the same thing with polylines. For context, I was visualizing the path of ~13,000 satellites. Even if you don’t have a ton of entities, I would recommend using SampledPositionProperty anyways since it gives you the option for animation.
With the disclaimer out of the way:
var viewer = new Cesium.Viewer(‘cesiumContainer’);
var semiMinorAxis = 7000000.0;
var semiMajorAxis = 11000000.0;
var positions = [];
for (var i = -180; i <= 180; i += 10) {
var axis =
semiMinorAxis +
Math.cos(i * Math.PI / 180.0) * (semiMajorAxis - semiMinorAxis);
positions.push(Cesium.Cartesian3.fromDegrees(i, 0, axis));
}
var entity = viewer.entities.add({
polyline: {
positions: positions,
followSurface: true,
width: 4,
material: Cesium.Color.RED
}
});
viewer.zoomTo(viewer.entities);