Page 1 of 1

Gotolonglat bug in SVN5063

Posted: 12.11.2010, 17:32
by Marco Klunder
Using Celestia SVN 5063, I experience the following bug, using the observer:gotolonglat() method in a celx script:

Code: Select all

obs=celestia:getobserver()
celestia:seturl("cel://PhaseLock/Sol:Earth/Sol:Earth:Moon/2009-12-11T01:02:21.01544?x=13iGcjN0OA&y=povOJMYO8////////////w&z=hir0Pqo15v///////////w&ow=0.498878&ox=-0.503754&oy=0.501514&oz=0.495819&fov=0.970781&ts=0&ltd=0&p=0&rf=3715&lm=52736&tsrc=0&ver=3", obs)
celestia:settimescale(1)
earth=celestia:find("Sol/Earth")
earthradius=earth:radius()
moon=celestia:find("Sol/Earth/Moon")
moonradius=moon:radius()
distance=220*earthradius
longitude=math.rad(166.7)
latitude=math.rad(63.7)
celestia:select(earth)
frame=celestia:newframe("ecliptic",earth)
obs=celestia:getobserver()
obs:setframe(frame)
obs:gotolonglat(earth, longitude, latitude, distance, 3.0 )
wait(2.0)
celestia:setrenderflags{atmospheres=true, cloudmaps=true, cloudshadows=true, orbits=true}
celestia:setorbitflags{Planet=false, Moon=true, Asteroid=false, Comet=false, Spacecraft=false, Invisible=false, Unknown=false, DwarfPlanet=false, MinorMoon=false, Star=false}
celestia:setambient (0.0)
celestia:getobserver():setfov(math.rad(38))
wait(1.0)


Traditional (and correct) result of the code above is:
Gotolonglat160.jpg


The Celestia SVN 5063 result however:
GotolonglatSVN.jpg

...ends up at the center of Earth (distance upper left corner: -6378,1 km).

Marco

Re: Gotolonglat bug in SVN5063

Posted: 13.11.2010, 11:04
by Vincent
Marco,

This bug appeared while the Celestia code was Eigenized. Thanks for reporting it.
The gotoSelectionLongLat method now requires distance to be in kilometers.
Commenting out line 363 in celx_observer.cpp, as below, should fixed it.

Code: Select all

static int observer_gotolonglat(lua_State* l)
{
    CelxLua celx(l);
    celx.checkArgs(2, 7, "One to five arguments expected to observer:gotolonglat");
   
    Observer* o = this_observer(l);
   
    Selection* sel = celx.toObject(2);
    if (sel == NULL)
    {
        celx.doError("First arg to observer:gotolonglat must be an object");
    }
    double defaultDistance = sel->radius() * 5.0;
   
    double longitude  = celx.safeGetNumber(3, WrongType, "Second arg to observer:gotolonglat must be a number", 0.0);
    double latitude   = celx.safeGetNumber(4, WrongType, "Third arg to observer:gotolonglat must be a number", 0.0);
    double distance   = celx.safeGetNumber(5, WrongType, "Fourth arg to observer:gotolonglat must be a number", defaultDistance);
    double travelTime = celx.safeGetNumber(6, WrongType, "Fifth arg to observer:gotolonglat must be a number", 5.0);
   
    //distance = distance / KM_PER_LY;
   
    Vector3f up = Vector3f::UnitY();
    if (lua_gettop(l) >= 7)
    {
        Vec3d* uparg = celx.toVector(7);
        if (uparg == NULL)
        {
            celx.doError("Sixth argument to observer:gotolonglat must be a vector");
        }
        up = toEigen(*uparg).cast<float>();
    }
    o->gotoSelectionLongLat(*sel, travelTime, distance, (float)longitude, (float)latitude, up);
   
    return 0;
}