use of org.orekit.utils.TimeStampedPVCoordinates in project Orekit by CS-SI.
the class ElevationExtremumDetector method g.
/**
* Compute the value of the detection function.
* <p>
* The value is the spacecraft elevation first time derivative.
* </p>
* @param s the current state information: date, kinematics, attitude
* @return spacecraft elevation first time derivative
* @exception OrekitException if some specific error occurs
*/
public double g(final SpacecraftState s) throws OrekitException {
// get position, velocity acceleration of spacecraft in topocentric frame
final Transform inertToTopo = s.getFrame().getTransformTo(topo, s.getDate());
final TimeStampedPVCoordinates pvTopo = inertToTopo.transformPVCoordinates(s.getPVCoordinates());
// convert the coordinates to DerivativeStructure based vector
// instead of having vector position, then vector velocity then vector acceleration
// we get one vector and each coordinate is a DerivativeStructure containing
// value, first time derivative (we don't need second time derivative here)
final FieldVector3D<DerivativeStructure> pvDS = pvTopo.toDerivativeStructureVector(1);
// compute elevation and its first time derivative
final DerivativeStructure elevation = pvDS.getZ().divide(pvDS.getNorm()).asin();
// return elevation first time derivative
return elevation.getPartialDerivative(1);
}
use of org.orekit.utils.TimeStampedPVCoordinates in project Orekit by CS-SI.
the class Ellipse method projectToEllipse.
/**
* Project position-velocity-acceleration on an ellipse.
* @param pv position-velocity-acceleration to project, in the reference frame
* @return projected position-velocity-acceleration
*/
public TimeStampedPVCoordinates projectToEllipse(final TimeStampedPVCoordinates pv) {
// find the closest point in the meridian plane
final Vector2D p2D = toPlane(pv.getPosition());
final Vector2D e2D = projectToEllipse(p2D);
// tangent to the ellipse
final double fx = -a2 * e2D.getY();
final double fy = b2 * e2D.getX();
final double f2 = fx * fx + fy * fy;
final double f = FastMath.sqrt(f2);
final Vector2D tangent = new Vector2D(fx / f, fy / f);
// normal to the ellipse (towards interior)
final Vector2D normal = new Vector2D(-tangent.getY(), tangent.getX());
// center of curvature
final double x2 = e2D.getX() * e2D.getX();
final double y2 = e2D.getY() * e2D.getY();
final double eX = evoluteFactorX * x2;
final double eY = evoluteFactorY * y2;
final double omegaX = eX * e2D.getX();
final double omegaY = eY * e2D.getY();
// velocity projection ratio
final double rho = FastMath.hypot(e2D.getX() - omegaX, e2D.getY() - omegaY);
final double d = FastMath.hypot(p2D.getX() - omegaX, p2D.getY() - omegaY);
final double projectionRatio = rho / d;
// tangential velocity
final Vector2D pDot2D = new Vector2D(Vector3D.dotProduct(pv.getVelocity(), u), Vector3D.dotProduct(pv.getVelocity(), v));
final double pDotTangent = pDot2D.dotProduct(tangent);
final double pDotNormal = pDot2D.dotProduct(normal);
final double eDotTangent = projectionRatio * pDotTangent;
final Vector2D eDot2D = new Vector2D(eDotTangent, tangent);
final Vector2D tangentDot = new Vector2D(a2 * b2 * (e2D.getX() * eDot2D.getY() - e2D.getY() * eDot2D.getX()) / f2, normal);
// velocity of the center of curvature in the meridian plane
final double omegaXDot = 3 * eX * eDotTangent * tangent.getX();
final double omegaYDot = 3 * eY * eDotTangent * tangent.getY();
// derivative of the projection ratio
final double voz = omegaXDot * tangent.getY() - omegaYDot * tangent.getX();
final double vsz = -pDotNormal;
final double projectionRatioDot = ((rho - d) * voz - rho * vsz) / (d * d);
// acceleration
final Vector2D pDotDot2D = new Vector2D(Vector3D.dotProduct(pv.getAcceleration(), u), Vector3D.dotProduct(pv.getAcceleration(), v));
final double pDotDotTangent = pDotDot2D.dotProduct(tangent);
final double pDotTangentDot = pDot2D.dotProduct(tangentDot);
final double eDotDotTangent = projectionRatio * (pDotDotTangent + pDotTangentDot) + projectionRatioDot * pDotTangent;
final Vector2D eDotDot2D = new Vector2D(eDotDotTangent, tangent, eDotTangent, tangentDot);
// back to 3D
final Vector3D e3D = toSpace(e2D);
final Vector3D eDot3D = new Vector3D(eDot2D.getX(), u, eDot2D.getY(), v);
final Vector3D eDotDot3D = new Vector3D(eDotDot2D.getX(), u, eDotDot2D.getY(), v);
return new TimeStampedPVCoordinates(pv.getDate(), e3D, eDot3D, eDotDot3D);
}
use of org.orekit.utils.TimeStampedPVCoordinates in project Orekit by CS-SI.
the class OneAxisEllipsoid method projectToGround.
/**
* {@inheritDoc}
*/
public TimeStampedPVCoordinates projectToGround(final TimeStampedPVCoordinates pv, final Frame frame) throws OrekitException {
// transform point to body frame
final Transform toBody = frame.getTransformTo(bodyFrame, pv.getDate());
final TimeStampedPVCoordinates pvInBodyFrame = toBody.transformPVCoordinates(pv);
final Vector3D p = pvInBodyFrame.getPosition();
final double r = FastMath.hypot(p.getX(), p.getY());
// set up the 2D ellipse corresponding to first principal curvature along meridian
final Vector3D meridian = new Vector3D(p.getX() / r, p.getY() / r, 0);
final Ellipse firstPrincipalCurvature = new Ellipse(Vector3D.ZERO, meridian, Vector3D.PLUS_K, getA(), getC(), bodyFrame);
// project coordinates in the meridian plane
final TimeStampedPVCoordinates gpFirst = firstPrincipalCurvature.projectToEllipse(pvInBodyFrame);
final Vector3D gpP = gpFirst.getPosition();
final double gr = MathArrays.linearCombination(gpP.getX(), meridian.getX(), gpP.getY(), meridian.getY());
final double gz = gpP.getZ();
// topocentric frame
final Vector3D east = new Vector3D(-meridian.getY(), meridian.getX(), 0);
final Vector3D zenith = new Vector3D(gr * getC() / getA(), meridian, gz * getA() / getC(), Vector3D.PLUS_K).normalize();
final Vector3D north = Vector3D.crossProduct(zenith, east);
// set up the ellipse corresponding to second principal curvature in the zenith/east plane
final Ellipse secondPrincipalCurvature = getPlaneSection(gpP, north);
final TimeStampedPVCoordinates gpSecond = secondPrincipalCurvature.projectToEllipse(pvInBodyFrame);
final Vector3D gpV = gpFirst.getVelocity().add(gpSecond.getVelocity());
final Vector3D gpA = gpFirst.getAcceleration().add(gpSecond.getAcceleration());
// moving projected point
final TimeStampedPVCoordinates groundPV = new TimeStampedPVCoordinates(pv.getDate(), gpP, gpV, gpA);
// transform moving projected point back to initial frame
return toBody.getInverse().transformPVCoordinates(groundPV);
}
use of org.orekit.utils.TimeStampedPVCoordinates in project Orekit by CS-SI.
the class BodyCenterPointing method getTargetPV.
/**
* {@inheritDoc}
*/
@Override
public TimeStampedPVCoordinates getTargetPV(final PVCoordinatesProvider pvProv, final AbsoluteDate date, final Frame frame) throws OrekitException {
// spacecraft coordinates in body frame
final TimeStampedPVCoordinates scInBodyFrame = pvProv.getPVCoordinates(date, getBodyFrame());
// central projection to ground (NOT the classical nadir point)
final double u = scInBodyFrame.getPosition().getX() / ellipsoid.getA();
final double v = scInBodyFrame.getPosition().getY() / ellipsoid.getB();
final double w = scInBodyFrame.getPosition().getZ() / ellipsoid.getC();
final double d2 = u * u + v * v + w * w;
final double d = FastMath.sqrt(d2);
final double ratio = 1.0 / d;
final Vector3D projectedP = new Vector3D(ratio, scInBodyFrame.getPosition());
// velocity
final double uDot = scInBodyFrame.getVelocity().getX() / ellipsoid.getA();
final double vDot = scInBodyFrame.getVelocity().getY() / ellipsoid.getB();
final double wDot = scInBodyFrame.getVelocity().getZ() / ellipsoid.getC();
final double dDot = MathArrays.linearCombination(u, uDot, v, vDot, w, wDot) / d;
final double ratioDot = -dDot / d2;
final Vector3D projectedV = new Vector3D(ratio, scInBodyFrame.getVelocity(), ratioDot, scInBodyFrame.getPosition());
// acceleration
final double uDotDot = scInBodyFrame.getAcceleration().getX() / ellipsoid.getA();
final double vDotDot = scInBodyFrame.getAcceleration().getY() / ellipsoid.getB();
final double wDotDot = scInBodyFrame.getAcceleration().getZ() / ellipsoid.getC();
final double dDotDot = (MathArrays.linearCombination(u, uDotDot, v, vDotDot, w, wDotDot) + uDot * uDot + vDot * vDot + wDot * wDot - dDot * dDot) / d;
final double ratioDotDot = (2 * dDot * dDot - d * dDotDot) / (d * d2);
final Vector3D projectedA = new Vector3D(ratio, scInBodyFrame.getAcceleration(), 2 * ratioDot, scInBodyFrame.getVelocity(), ratioDotDot, scInBodyFrame.getPosition());
final TimeStampedPVCoordinates projected = new TimeStampedPVCoordinates(date, projectedP, projectedV, projectedA);
return getBodyFrame().getTransformTo(frame, date).transformPVCoordinates(projected);
}
use of org.orekit.utils.TimeStampedPVCoordinates in project Orekit by CS-SI.
the class LofOffsetPointing method getTargetPV.
/**
* {@inheritDoc}
*/
public TimeStampedPVCoordinates getTargetPV(final PVCoordinatesProvider pvProv, final AbsoluteDate date, final Frame frame) throws OrekitException {
// sample intersection points in current date neighborhood
final double h = 0.1;
final List<TimeStampedPVCoordinates> sample = new ArrayList<>();
Transform centralRefToBody = null;
for (int i = -1; i < 2; ++i) {
final AbsoluteDate shifted = date.shiftedBy(i * h);
// transform from specified reference frame to spacecraft frame
final Transform refToSc = new Transform(shifted, new Transform(shifted, pvProv.getPVCoordinates(shifted, frame).negate()), new Transform(shifted, attitudeLaw.getAttitude(pvProv, shifted, frame).getOrientation()));
// transform from specified reference frame to body frame
final Transform refToBody = frame.getTransformTo(shape.getBodyFrame(), shifted);
if (i == 0) {
centralRefToBody = refToBody;
}
sample.add(losIntersectionWithBody(new Transform(shifted, refToSc.getInverse(), refToBody)));
}
// use interpolation to compute properly the time-derivatives
final TimeStampedPVCoordinates targetBody = TimeStampedPVCoordinates.interpolate(date, CartesianDerivativesFilter.USE_P, sample);
// convert back to caller specified frame
return centralRefToBody.getInverse().transformPVCoordinates(targetBody);
}
Aggregations