Distances in Celestial browser screwed up

Report bugs, bug fixes and workarounds here.
Topic author
Peter

Distances in Celestial browser screwed up

Post #1by Peter » 30.07.2002, 07:32

Hi,

First of all, great program!!

I found the following bug though (running celestia 1.2.4 on Linux, graph.
card irrelevant as you will see...).

If you get the list of nearest stars in the celestial browser, it seems to
be screwed up completely. I suppose that when you are hovering over
the Earth, the nearest star should be Sol, then Proxima Centauri,
etc. but it usually gives a star some 250-odd lightyears away...

If you empty the start.cel script (i.e. no movement at startup), the list
shows up correctly as long as you don't move yet, so it seems to be a
problem with wrongly updating the observer's position for some
circumstances. Then I started digging deeper in the code to see what
could be the problem.

Now, I'm afraid I'm opening a can of worms here, because I couldn't
get the units of the several variables right...

If I understand correctly, you have the following:
Observer::getPosition() -> 3D vector position in lightyears,
Observer::getVelocity() -> 3D vector velocity in microlightyears/s,
dt -> seconds (see getTime)
transform.translation -> same as getPosition() (is assigned to it)

I started printing out the observer position while the simulation was
running. When going from the initial position (observer position 0,0,0)
to Sol, the x coordinate went from 0 to 3254 ly, although initially Sol
was only 206 AU away. So here already there is something wrong
in the observer position kept internally in the program.

Further, there is a formula in Simulation::update:

transform.translation = transform.translation + observer.getVelocity() * dt

which works out as ly = ly + microly/s * s ???

Could this be the source of the problem ? I'll keep looking further, but
I guess other people here can pinpoint the problem much quicker.

Topic author
Peter

Re: Distances in Celestial browser screwed up

Post #2by Peter » 30.07.2002, 08:58

OK, I think I have it...

The observer location is in microly, but the star positions are in ly, so
it's the starbrowser for linux that is wrong...

With the following changes I could get correct results (recursive diff
of the original and modified sources):

diff -r celestia-1.2.4/src/celengine/starbrowser.cpp celestia-1.2.4.orig/src/celengine/starbrowser.cpp
18,28d17
< static Point3f toMicroLY(const Point3f& p)
< {
< return Point3f(p.x * 1e6f, p.y * 1e6f, p.z * 1e6f);
< }
<
< static Point3f fromMicroLY(const Point3f& p)
< {
< return Point3f(p.x * 1e-6f, p.y * 1e-6f, p.z * 1e-6f);
< }
<
<
37,38c26,27
< return ((pos - toMicroLY(star0->getPosition())).lengthSquared() <
< (pos - toMicroLY(star1->getPosition())).lengthSquared());
---
> return ((pos - star0->getPosition()).lengthSquared() <
> (pos - star1->getPosition()).lengthSquared());
50,51c39,40
< float d0 = pos.distanceTo(toMicroLY(star0->getPosition()));
< float d1 = pos.distanceTo(toMicroLY(star1->getPosition()));
---
> float d0 = pos.distanceTo(star0->getPosition());
> float d1 = pos.distanceTo(star1->getPosition());
56c45
< d0 = (toMicroLY(star0->getPosition()) - ucPos).length();
---
> d0 = (star0->getPosition() - ucPos).length();
58c47
< d1 = (toMicroLY(star1->getPosition()) - ucPos).length();
---
> d1 = (star1->getPosition() - ucPos).length();
68d56
< Point3f pos;
92,93c80,81
< return ((pos - toMicroLY(star0->getPosition())).lengthSquared() <
< (pos - toMicroLY(star1->getPosition())).lengthSquared());
---
> return ((pos - star0->getPosition()).lengthSquared() <
> (pos - star1->getPosition()).lengthSquared());
diff -r celestia-1.2.4/src/celestia/celestiacore.cpp celestia-1.2.4.orig/src/celestia/celestiacore.cpp
1234,1240d1233
< else {
< UniversalCoord p = sim->getObserver().getPosition();
< *overlay << "Pos: "
< << double(p.x) * 1e-6 << " , "
< << double(p.y) * 1e-6 << " , "
< << double(p.z) * 1e-6;
< }
diff -r celestia-1.2.4/src/celestia/gtkmain.cpp celestia-1.2.4.orig/src/celestia/gtkmain.cpp
1376,1381d1375
< static Point3f toMicroLY(const Point3f& p)
< {
< return Point3f(p.x * 1e6f, p.y * 1e6f, p.z * 1e6f);
< }
<
<
1400c1394
< sprintf(buf, " %.3f ", ucPos.distanceTo(toMicroLY(star->getPosition())) * 1e-6f);
---
> sprintf(buf, " %.3f ", ucPos.distanceTo(star->getPosition()));


Return to “Bugs”