use of org.orekit.utils.TimeStampedPVCoordinates in project Orekit by CS-SI.
the class JPLCelestialBody method getPVCoordinates.
/**
* {@inheritDoc}
*/
public TimeStampedPVCoordinates getPVCoordinates(final AbsoluteDate date, final Frame frame) throws OrekitException {
// apply the scale factor to raw position-velocity
final PVCoordinates rawPV = rawPVProvider.getRawPV(date);
final TimeStampedPVCoordinates scaledPV = new TimeStampedPVCoordinates(date, scale, rawPV);
// the raw PV are relative to the parent of the body centered inertially oriented frame
final Transform transform = getInertiallyOrientedFrame().getParent().getTransformTo(frame, date);
// convert to requested frame
return transform.transformPVCoordinates(scaledPV);
}
use of org.orekit.utils.TimeStampedPVCoordinates in project Orekit by CS-SI.
the class OneAxisEllipsoid method transform.
/**
* Transform a Cartesian point to a surface-relative point.
* @param point Cartesian point
* @param frame frame in which Cartesian point is expressed
* @param date date of the computation (used for frames conversions)
* @return point at the same location but as a surface-relative point,
* using time as the single derivation parameter
* @exception OrekitException if point cannot be converted to body frame
*/
public FieldGeodeticPoint<DerivativeStructure> transform(final PVCoordinates point, final Frame frame, final AbsoluteDate date) throws OrekitException {
// transform point to body frame
final Transform toBody = frame.getTransformTo(bodyFrame, date);
final PVCoordinates pointInBodyFrame = toBody.transformPVCoordinates(point);
final FieldVector3D<DerivativeStructure> p = pointInBodyFrame.toDerivativeStructureVector(2);
final DerivativeStructure pr2 = p.getX().multiply(p.getX()).add(p.getY().multiply(p.getY()));
final DerivativeStructure pr = pr2.sqrt();
final DerivativeStructure pz = p.getZ();
// project point on the ellipsoid surface
final TimeStampedPVCoordinates groundPoint = projectToGround(new TimeStampedPVCoordinates(date, pointInBodyFrame), bodyFrame);
final FieldVector3D<DerivativeStructure> gp = groundPoint.toDerivativeStructureVector(2);
final DerivativeStructure gpr2 = gp.getX().multiply(gp.getX()).add(gp.getY().multiply(gp.getY()));
final DerivativeStructure gpr = gpr2.sqrt();
final DerivativeStructure gpz = gp.getZ();
// relative position of test point with respect to its ellipse sub-point
final DerivativeStructure dr = pr.subtract(gpr);
final DerivativeStructure dz = pz.subtract(gpz);
final double insideIfNegative = g2 * (pr2.getReal() - ae2) + pz.getReal() * pz.getReal();
return new FieldGeodeticPoint<>(DerivativeStructure.atan2(gpz, gpr.multiply(g2)), DerivativeStructure.atan2(p.getY(), p.getX()), DerivativeStructure.hypot(dr, dz).copySign(insideIfNegative));
}
use of org.orekit.utils.TimeStampedPVCoordinates in project Orekit by CS-SI.
the class GroundPointing method getAttitude.
/**
* {@inheritDoc}
*/
public Attitude getAttitude(final PVCoordinatesProvider pvProv, final AbsoluteDate date, final Frame frame) throws OrekitException {
// satellite-target relative vector
final PVCoordinates pva = pvProv.getPVCoordinates(date, inertialFrame);
final TimeStampedPVCoordinates delta = new TimeStampedPVCoordinates(date, pva, getTargetPV(pvProv, date, inertialFrame));
// spacecraft and target should be away from each other to define a pointing direction
if (delta.getPosition().getNorm() == 0.0) {
throw new OrekitException(OrekitMessages.SATELLITE_COLLIDED_WITH_TARGET);
}
// attitude definition:
// line of sight -> +z satellite axis,
// orbital velocity -> (z, +x) half plane
final Vector3D p = pva.getPosition();
final Vector3D v = pva.getVelocity();
final Vector3D a = pva.getAcceleration();
final double r2 = p.getNormSq();
final double r = FastMath.sqrt(r2);
final Vector3D keplerianJerk = new Vector3D(-3 * Vector3D.dotProduct(p, v) / r2, a, -a.getNorm() / r, v);
final PVCoordinates velocity = new PVCoordinates(v, a, keplerianJerk);
final PVCoordinates los = delta.normalize();
final PVCoordinates normal = PVCoordinates.crossProduct(delta, velocity).normalize();
AngularCoordinates ac = new AngularCoordinates(los, normal, PLUS_K, PLUS_J, 1.0e-9);
if (frame != inertialFrame) {
// prepend transform from specified frame to inertial frame
ac = ac.addOffset(frame.getTransformTo(inertialFrame, date).getAngular());
}
// build the attitude
return new Attitude(date, frame, ac);
}
use of org.orekit.utils.TimeStampedPVCoordinates in project Orekit by CS-SI.
the class LofOffsetPointing method losIntersectionWithBody.
/**
* Compute line of sight intersection with body.
* @param scToBody transform from spacecraft frame to body frame
* @return intersection point in body frame (only the position is set!)
* @exception OrekitException if line of sight does not intersect body
*/
private TimeStampedPVCoordinates losIntersectionWithBody(final Transform scToBody) throws OrekitException {
// compute satellite pointing axis and position/velocity in body frame
final Vector3D pointingBodyFrame = scToBody.transformVector(satPointingVector);
final Vector3D pBodyFrame = scToBody.transformPosition(Vector3D.ZERO);
// Line from satellite following pointing direction
// we use arbitrarily the Earth radius as a scaling factor, it could be anything else
final Line pointingLine = new Line(pBodyFrame, pBodyFrame.add(Constants.WGS84_EARTH_EQUATORIAL_RADIUS, pointingBodyFrame), 1.0e-10);
// Intersection with body shape
final GeodeticPoint gpIntersection = shape.getIntersectionPoint(pointingLine, pBodyFrame, shape.getBodyFrame(), scToBody.getDate());
final Vector3D pIntersection = (gpIntersection == null) ? null : shape.transform(gpIntersection);
// Check there is an intersection and it is not in the reverse pointing direction
if ((pIntersection == null) || (Vector3D.dotProduct(pIntersection.subtract(pBodyFrame), pointingBodyFrame) < 0)) {
throw new OrekitException(OrekitMessages.ATTITUDE_POINTING_LAW_DOES_NOT_POINT_TO_GROUND);
}
return new TimeStampedPVCoordinates(scToBody.getDate(), pIntersection, Vector3D.ZERO, Vector3D.ZERO);
}
use of org.orekit.utils.TimeStampedPVCoordinates in project Orekit by CS-SI.
the class TargetPointing method getTargetPV.
/**
* {@inheritDoc}
*/
@Override
public TimeStampedPVCoordinates getTargetPV(final PVCoordinatesProvider pvProv, final AbsoluteDate date, final Frame frame) throws OrekitException {
final Transform t = getBodyFrame().getTransformTo(frame, date);
final TimeStampedPVCoordinates pv = new TimeStampedPVCoordinates(date, target, Vector3D.ZERO, Vector3D.ZERO);
return t.transformPVCoordinates(pv);
}
Aggregations