Search in sources :

Example 21 with Transform

use of org.orekit.frames.Transform 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);
}
Also used : Vector3D(org.hipparchus.geometry.euclidean.threed.Vector3D) FieldVector3D(org.hipparchus.geometry.euclidean.threed.FieldVector3D) Transform(org.orekit.frames.Transform) FieldTransform(org.orekit.frames.FieldTransform) TimeStampedPVCoordinates(org.orekit.utils.TimeStampedPVCoordinates)

Example 22 with Transform

use of org.orekit.frames.Transform in project Orekit by CS-SI.

the class OneAxisEllipsoid method getIntersectionPoint.

/**
 * {@inheritDoc}
 */
public GeodeticPoint getIntersectionPoint(final Line line, final Vector3D close, final Frame frame, final AbsoluteDate date) throws OrekitException {
    // transform line and close to body frame
    final Transform frameToBodyFrame = frame.getTransformTo(bodyFrame, date);
    final Line lineInBodyFrame = frameToBodyFrame.transformLine(line);
    final Vector3D closeInBodyFrame = frameToBodyFrame.transformPosition(close);
    final double closeAbscissa = lineInBodyFrame.getAbscissa(closeInBodyFrame);
    // compute some miscellaneous variables outside of the loop
    final Vector3D point = lineInBodyFrame.getOrigin();
    final double x = point.getX();
    final double y = point.getY();
    final double z = point.getZ();
    final double z2 = z * z;
    final double r2 = x * x + y * y;
    final Vector3D direction = lineInBodyFrame.getDirection();
    final double dx = direction.getX();
    final double dy = direction.getY();
    final double dz = direction.getZ();
    final double cz2 = dx * dx + dy * dy;
    // abscissa of the intersection as a root of a 2nd degree polynomial :
    // a k^2 - 2 b k + c = 0
    final double a = 1.0 - e2 * cz2;
    final double b = -(g2 * (x * dx + y * dy) + z * dz);
    final double c = g2 * (r2 - ae2) + z2;
    final double b2 = b * b;
    final double ac = a * c;
    if (b2 < ac) {
        return null;
    }
    final double s = FastMath.sqrt(b2 - ac);
    final double k1 = (b < 0) ? (b - s) / a : c / (b + s);
    final double k2 = c / (a * k1);
    // select the right point
    final double k = (FastMath.abs(k1 - closeAbscissa) < FastMath.abs(k2 - closeAbscissa)) ? k1 : k2;
    final Vector3D intersection = lineInBodyFrame.pointAt(k);
    final double ix = intersection.getX();
    final double iy = intersection.getY();
    final double iz = intersection.getZ();
    final double lambda = FastMath.atan2(iy, ix);
    final double phi = FastMath.atan2(iz, g2 * FastMath.sqrt(ix * ix + iy * iy));
    return new GeodeticPoint(phi, lambda, 0.0);
}
Also used : Line(org.hipparchus.geometry.euclidean.threed.Line) FieldLine(org.hipparchus.geometry.euclidean.threed.FieldLine) Vector3D(org.hipparchus.geometry.euclidean.threed.Vector3D) FieldVector3D(org.hipparchus.geometry.euclidean.threed.FieldVector3D) Transform(org.orekit.frames.Transform) FieldTransform(org.orekit.frames.FieldTransform)

Example 23 with Transform

use of org.orekit.frames.Transform in project Orekit by CS-SI.

the class OneAxisEllipsoid method projectToGround.

/**
 * {@inheritDoc}
 */
public Vector3D projectToGround(final Vector3D point, final AbsoluteDate date, final Frame frame) throws OrekitException {
    // transform point to body frame
    final Transform toBody = frame.getTransformTo(bodyFrame, date);
    final Vector3D p = toBody.transformPosition(point);
    final double z = p.getZ();
    final double r = FastMath.hypot(p.getX(), p.getY());
    // set up the 2D meridian ellipse
    final Ellipse meridian = new Ellipse(Vector3D.ZERO, new Vector3D(p.getX() / r, p.getY() / r, 0), Vector3D.PLUS_K, getA(), getC(), bodyFrame);
    // find the closest point in the meridian plane
    final Vector3D groundPoint = meridian.toSpace(meridian.projectToEllipse(new Vector2D(r, z)));
    // transform point back to initial frame
    return toBody.getInverse().transformPosition(groundPoint);
}
Also used : Vector2D(org.hipparchus.geometry.euclidean.twod.Vector2D) Vector3D(org.hipparchus.geometry.euclidean.threed.Vector3D) FieldVector3D(org.hipparchus.geometry.euclidean.threed.FieldVector3D) Transform(org.orekit.frames.Transform) FieldTransform(org.orekit.frames.FieldTransform)

Example 24 with Transform

use of org.orekit.frames.Transform in project Orekit by CS-SI.

the class CelestialBodyPointed method getAttitude.

/**
 * {@inheritDoc}
 */
public Attitude getAttitude(final PVCoordinatesProvider pvProv, final AbsoluteDate date, final Frame frame) throws OrekitException {
    final PVCoordinates satPV = pvProv.getPVCoordinates(date, celestialFrame);
    // compute celestial references at the specified date
    final PVCoordinates bodyPV = pointedBody.getPVCoordinates(date, celestialFrame);
    final PVCoordinates pointing = new PVCoordinates(satPV, bodyPV);
    final Vector3D pointingP = pointing.getPosition();
    final double r2 = Vector3D.dotProduct(pointingP, pointingP);
    // evaluate instant rotation axis due to sat and body motion only (no phasing yet)
    final Vector3D rotAxisCel = new Vector3D(1 / r2, Vector3D.crossProduct(pointingP, pointing.getVelocity()));
    // fix instant rotation to take phasing constraint into account
    // (adding a rotation around pointing axis ensuring the motion of the phasing axis
    // is constrained in the pointing-phasing plane)
    final Vector3D v1 = Vector3D.crossProduct(rotAxisCel, phasingCel);
    final Vector3D v2 = Vector3D.crossProduct(pointingP, phasingCel);
    final double compensation = -Vector3D.dotProduct(v1, v2) / v2.getNormSq();
    final Vector3D phasedRotAxisCel = new Vector3D(1.0, rotAxisCel, compensation, pointingP);
    // compute transform from celestial frame to satellite frame
    final Rotation celToSatRotation = new Rotation(pointingP, phasingCel, pointingSat, phasingSat);
    // build transform combining rotation and instant rotation axis
    Transform transform = new Transform(date, celToSatRotation, celToSatRotation.applyTo(phasedRotAxisCel));
    if (frame != celestialFrame) {
        // prepend transform from specified frame to celestial frame
        transform = new Transform(date, frame.getTransformTo(celestialFrame, date), transform);
    }
    // build the attitude
    return new Attitude(date, frame, transform.getRotation(), transform.getRotationRate(), transform.getRotationAcceleration());
}
Also used : Vector3D(org.hipparchus.geometry.euclidean.threed.Vector3D) FieldVector3D(org.hipparchus.geometry.euclidean.threed.FieldVector3D) FieldPVCoordinates(org.orekit.utils.FieldPVCoordinates) PVCoordinates(org.orekit.utils.PVCoordinates) Transform(org.orekit.frames.Transform) FieldTransform(org.orekit.frames.FieldTransform) FieldRotation(org.hipparchus.geometry.euclidean.threed.FieldRotation) Rotation(org.hipparchus.geometry.euclidean.threed.Rotation)

Example 25 with Transform

use of org.orekit.frames.Transform in project Orekit by CS-SI.

the class LofOffset method getAttitude.

/**
 * {@inheritDoc}
 */
public Attitude getAttitude(final PVCoordinatesProvider pvProv, final AbsoluteDate date, final Frame frame) throws OrekitException {
    // construction of the local orbital frame, using PV from inertial frame
    final PVCoordinates pv = pvProv.getPVCoordinates(date, inertialFrame);
    final Transform inertialToLof = type.transformFromInertial(date, pv);
    // take into account the specified start frame (which may not be an inertial one)
    final Transform frameToInertial = frame.getTransformTo(inertialFrame, date);
    final Transform frameToLof = new Transform(date, frameToInertial, inertialToLof);
    // compose with offset rotation
    return new Attitude(date, frame, offset.compose(frameToLof.getRotation(), RotationConvention.VECTOR_OPERATOR), offset.applyTo(frameToLof.getRotationRate()), offset.applyTo(frameToLof.getRotationAcceleration()));
}
Also used : FieldPVCoordinates(org.orekit.utils.FieldPVCoordinates) PVCoordinates(org.orekit.utils.PVCoordinates) Transform(org.orekit.frames.Transform) FieldTransform(org.orekit.frames.FieldTransform)

Aggregations

Transform (org.orekit.frames.Transform)75 Vector3D (org.hipparchus.geometry.euclidean.threed.Vector3D)56 AbsoluteDate (org.orekit.time.AbsoluteDate)33 Frame (org.orekit.frames.Frame)28 FieldTransform (org.orekit.frames.FieldTransform)26 SpacecraftState (org.orekit.propagation.SpacecraftState)26 FieldVector3D (org.hipparchus.geometry.euclidean.threed.FieldVector3D)25 PVCoordinates (org.orekit.utils.PVCoordinates)23 TimeStampedPVCoordinates (org.orekit.utils.TimeStampedPVCoordinates)21 Test (org.junit.Test)20 Rotation (org.hipparchus.geometry.euclidean.threed.Rotation)18 FieldAbsoluteDate (org.orekit.time.FieldAbsoluteDate)17 GeodeticPoint (org.orekit.bodies.GeodeticPoint)13 TopocentricFrame (org.orekit.frames.TopocentricFrame)12 OneAxisEllipsoid (org.orekit.bodies.OneAxisEllipsoid)11 OrekitException (org.orekit.errors.OrekitException)11 DerivativeStructure (org.hipparchus.analysis.differentiation.DerivativeStructure)10 FieldPVCoordinates (org.orekit.utils.FieldPVCoordinates)10 FieldRotation (org.hipparchus.geometry.euclidean.threed.FieldRotation)8 CircularOrbit (org.orekit.orbits.CircularOrbit)8