Fixed bug in calculation of the position of locations. The bug only occurred

when the location was the child of an object with a frame parent star
different than its namespace parent star (most commonly occurring when the
orbit frame center is the solar system barycenter.) This is hopefully the last
of this class of bug.
ver1_6_1
Chris Laurel 2008-05-18 00:18:41 +00:00
parent 6a59ac8893
commit c4521a3c66
1 changed files with 10 additions and 7 deletions

View File

@ -8,6 +8,7 @@
// of the License, or (at your option) any later version.
#include <cstdio>
#include <cassert>
#include "astro.h"
#include "selection.h"
#include "frametree.h"
@ -59,16 +60,18 @@ UniversalCoord Selection::getPosition(double t) const
case Type_Location:
{
Body* body = location()->getParentBody();
const Star* sun = NULL;
if (body != NULL && body->getSystem() != NULL)
if (body != NULL)
{
sun = body->getSystem()->getStar();
Point3d planetocentricPos = location()->getPlanetocentricPosition(t) *
astro::kilometersToMicroLightYears(1.0);
return body->getPosition(t) + planetocentricPos;
}
if (sun != NULL)
return astro::universalPosition(location()->getHeliocentricPosition(t), sun->getPosition(t));
else
return astro::universalPosition(location()->getHeliocentricPosition(t), Point3f(0.0f, 0.0f, 0.0f));
{
// Bad location; all locations should have a parent.
assert(0);
return UniversalCoord(0.0, 0.0, 0.0);
}
}
default: