Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

observerCoordsEcf, velocityEcf not defined #24

Closed
bdefore opened this issue Jul 14, 2016 · 7 comments
Closed

observerCoordsEcf, velocityEcf not defined #24

bdefore opened this issue Jul 14, 2016 · 7 comments

Comments

@bdefore
Copy link

bdefore commented Jul 14, 2016

Example in README references:

dopplerFactor = satellite.dopplerFactor(observerCoordsEcf, positionEcf, velocityEcf);

But neither of observerCoordsEcf or velocityEcf appear to be available.

@shashwatak
Copy link
Owner

shashwatak commented Mar 10, 2017

I apologize for the extreme delay in response.
You will have to define those yourself using the functions described in the README.

@nhamer
Copy link

nhamer commented Apr 24, 2018

The readme code doesn't quite run. velocityEcf and observerCoordsEcf just aren't defined.

velocityEcf = satellite.eciToEcf(velocityEci, gmst);
dopplerFactor = satellite.dopplerFactor(observerEcf, positionEcf, velocityEcf);

@thkruz
Copy link
Collaborator

thkruz commented Sep 16, 2018

Recommend using Eci for the dopplerFactor example in the readme. There is no available function to convert velocityEci to velocityEcf and the readme already explains you can use ecf if you have those values.

@nhamer
Copy link

nhamer commented Sep 16, 2018

satellite.eciToEcf converts it

@thkruz
Copy link
Collaborator

thkruz commented Sep 16, 2018

It converts ECI Position but it doesn't convert ECI Velocity because it doesn't account for the rotation of the earth.

There is a reference at http://www.dtic.mil/dtic/tr/fulltext/u2/a015815.pdf on page 29 and 30 that explains the math to convert ECI Velocity to ECF Velocity.

@ericsvendsen
Copy link

ericsvendsen commented Mar 3, 2022

I realize this issue thread is really old, but thought I would post my solution here for calculating ECF velocity in case others have the same question. If accuracy is vital and you're able to track down and decipher the math mentioned above, then great! I was not though, and this seemed to worked out pretty well for me. :)

Basically, you can determine ecf velocity using the eci data that satellite.js provides via the propagate or sgp4 methods (Note: I'm using dayjs elsewhere in my project, so that's why I'm using it here in this example. It is certainly not required)

const now = dayjs(); // date/time right now
const pv = propagate(satrec, now.toDate()); // eci position and velocity for a given satrec
if (pv.position && pv.velocity) {
    const ecfPosition = eciToEcf(pv.position, gstime(now.toDate())); // convert eci position to ecf
    const ecfMoved = eciToEcf( // add eci velocity to eci position, and convert the result to ecf
        {
            x: pv.position.x + pv.velocity.x,
            y: pv.position.y + pv.velocity.y,
            z: pv.position.z + pv.velocity.z,
        },
        gstime(now.add(1, 'second').toDate()) // be sure to use a time 1 second later, since velocity is km/s
    );
    const ecfVelocity = { // subtract original ecf from ecfMoved to obtain velocity in ecf
        x: ecfMoved.x - ecfPosition.x,
        y: ecfMoved.y - ecfPosition.y,
        z: ecfMoved.z - ecfPosition.z,
    };
}

@thkruz
Copy link
Collaborator

thkruz commented Mar 4, 2022

Slick idea. That should actually account for the rotation of the earth perfectly. Feels super obvious now that you post it - thanks for helping out!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

5 participants