Draw a generalized orbit ellipse

695 views
Skip to first unread message

Aaron

unread,
Apr 24, 2018, 11:18:00 PM4/24/18
to cesium-dev
1. A concise explanation of the problem you're experiencing.

I'm trying to draw the path of a orbit around Earth given the semi major axis, along with the point of perigee and apogee. Also, I'd like to incline the orbit, longitude of the ascending node and argument of periapsis. Basically everything that defines an orbit without having to say where the object is along the orbit.

I tried using a EllipseGeometry, but that didn't work since it kept being attached to the surface of the Earth or curved with the surface when I added height.


2. A minimal code example. If you've found a bug, this helps us reproduce and repair it.

I can sort of get what I want using a polyline  for a circular orbit:

var meo_orbit     = 20000000;
var inclination = 30;

var meoline = viewer.entities.add({
    name : 'Blue dashed line',
    polyline : {
        positions : Cesium.Cartesian3.fromDegreesArrayHeights(
            [0, 0, meo_orbit,
             90, inclination, meo_orbit,
             180, 0, meo_orbit,
             270,inclination * -1 , meo_orbit,
             0, 0, meo_orbit
            ]),
        width : 1,
        material : new Cesium.PolylineDashMaterialProperty({
            color: Cesium.Color.GRAY
        })
    }
});

The issue I'm having is generalizing the calculation of the 4 vertex points. I'm assuming there is a way I can calculate those with the given inputs but I want to make sure this is the best/proper approach as I'm just starting to learn space, orbits and such.

3. Context. Why do you need to do this? We might know a better way to accomplish your goal.

My goal is to create a simply panel for quickly visualizing different orbits (LEO, HEO, MEO, etc) paths without having to propagate a satellite or object around to get it. I want to visualize how the orbits change as different parameters are adjusted.

4. The Cesium version you're using, your operating system and browser.

1.44. Linux. Firefox.


Thank you for help.

Aaron

unread,
Apr 25, 2018, 12:24:26 AM4/25/18
to cesium-dev
I have more complete code example:
var inclination = 30;
var parogee = 1000000;
var appogee = 20000000;
var loan = 30;

var e = 1 - 2 / ( (appogee / parogee) + 1);

// altitude for minor vertix
var h1 = appogee * Math.sqrt(1 - Math.pow(e, 2));
console.log(h1);

var meoline = viewer.entities.add({
    name : 'Blue dashed line',
    polyline : {
        positions : Cesium.Cartesian3.fromDegreesArrayHeights(
            [loan, 0, h1,
             loan+90, inclination, appogee,
             loan+180, 0, h1,
             loan+270,inclination*-1 , parogee,
             loan, 0, h1,
            ]),
        width : 1,
        material : new Cesium.PolylineDashMaterialProperty({
            color: Cesium.Color.GRAY
        })
    }
});

As you can see in the attached screenshot, I'm not getting the ellipse I was hoping for. Any suggestions for a better way to accomplish this would be appreciated.

-Aaron
Screen Shot 2018-04-24 at 10.22.27 PM.png

Gabby Getz

unread,
Apr 26, 2018, 9:35:21 AM4/26/18
to cesium-dev
Hi Aaron,

AGI, the company that founded Cesium is an aerospace company, so we often visualize satellite trajectories and use polylines to do so. 

Your code looks correct, I;m guessing this may just be an issue with math and converting between Cartographic and Cartesian coordinates. Here is an example I put in a previous thread.

Hope that helps!
Gabby

Aaron Rich

unread,
Apr 26, 2018, 5:00:55 PM4/26/18
to cesiu...@googlegroups.com
That definitely helped. I did have a math issue.

I have just about everything working expect for the Argument of Perigee.

How do I get a transform so I can rotate around the orbit plane's Z axis and not Earth's? How to use the transform, and which one to use, properly is confusing me.

Example:

var inclination = 30;
var parogee = 1000000;
var appogee = 5000000;
var loan = 0;
var argument_of_periapsis = 45;

var semi_major = parogee + appogee / 2;

var e = 1 - 2 / ( (appogee / parogee) + 1);

// altitude for minor vertix
var semi_minor = semi_major * Math.sqrt(1 - Math.pow(e, 2));

var inclination_m = Cesium.Matrix3.fromRotationY(-1 * Cesium.Math.toRadians(inclination));

var raan_m = Cesium.Matrix3.fromRotationZ(Cesium.Math.toRadians(loan));

var aop_m = Cesium.Matrix3.fromRotationZ(Cesium.Math.toRadians(argument_of_periapsis));

var positions = [];
for ( var i = -180; i <= 180; i+=1) {
        //r = a(1-e^2)/ 1+e\cos \theta}
    var radius = semi_major * (1- Math.pow(e, 2)) / (1 + e * Math.cos(Cesium.Math.toRadians(i)));

    //create point
    var p = new Cesium.Cartesian3.fromDegrees(i-90, 0, radius);
    
    //rotate around earth Y axis to apply inclination
    var rotated = Cesium.Matrix3.multiplyByVector(inclination_m, p, new Cesium.Cartesian3());
    
    //rotate around earth Z to apply RAAN
    var raan = Cesium.Matrix3.multiplyByVector(raan_m, rotated, new Cesium.Cartesian3());
    
    //rotate around orbit plane Z to apply AOP  
    //transform to local orbit plane
    //??????
    var final = Cesium.Matrix3.multiplyByVector(aop_m, raan, new Cesium.Cartesian3());

    positions.push(final);

}


--
You received this message because you are subscribed to the Google Groups "cesium-dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email to cesium-dev+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Gabby Getz

unread,
Apr 30, 2018, 11:33:32 AM4/30/18
to cesium-dev
I'm not all that familiar with the calculations here (maybe someone on the forum here may know, otherwise asking a more math-related or orbit-related forum might help), but I see you do have the correct way of applying rotations using the Cesium API:

// Rotate a point 45 degrees counterclockwise around the x-axis.
var p = new Cesium.Cartesian3(5, 6, 7);
var m = Cesium.Matrix3.fromRotationX(Cesium.Math.toRadians(45.0));
var rotated = Cesium.Matrix3.multiplyByVector(m, p, new Cesium.Cartesian3());

Thanks,
Gabby
Reply all
Reply to author
Forward
0 new messages