• Print view

## Working with universal coordinate system

The place to discuss creating, porting and modifying Celestia's source code.
Topic author
Dandelion
Posts: 8
Joined: 23.06.2009
With us: 11 years 5 months

### Working with universal coordinate system

Hi,

I'm trying to figure out if the Observer is moving towards an object (e.g a star) or away from it. This is what I have so far. I not sure if the idea is correct.

I'm calculating a new orientation from from the stars position and the observers position : Quatd newOrientation = starPosition - myPosition;
Than I calculate the pot product: double potProduct= newOrientation.x * myOrientation.x + newOrientation.y * myOrientation.y + newOrientation.z * myOrientation.z; (UniversalCoord myPosition = observer.getPosition();)

If the pot product is negative the observer should be moving towards the object otherwise the observer should be moving away from the object.

Is this correct or is there a better way to do it?

Greetings,
Thomas

t00fri
Developer
Posts: 8772
Joined: 29.03.2002
Age: 18
With us: 18 years 8 months
Location: Hamburg, Germany

### Re: Working with universal coordinate system

I like your pot product

That must give interesting results...

Never mind.

Fridger

Topic author
Dandelion
Posts: 8
Joined: 23.06.2009
With us: 11 years 5 months

### Re: Working with universal coordinate system

Hello,

what exactly is the orientation of the observer? i thought it is the vector in which the observer is moving or looking!! And it doesn't seem to normalize correctly.

Quatd myOrientation = observer.getOrientation();
myOrientation.normalize();
double test2 = sqrt(pow(myOrientation.x,2.0) + pow(myOrientation.y,2.0) + pow(myOrientation.z,2.0));

new test2 should be 1 but it isn't

Thomas