List of usage examples for org.apache.commons.math3.geometry.euclidean.threed Vector3D getNormSq
public double getNormSq()
From source file:org.orekit.forces.gravity.ThirdBodyAttraction.java
/** {@inheritDoc} */ public void addContribution(final SpacecraftState s, final TimeDerivativesEquations adder) throws OrekitException { // compute bodies separation vectors and squared norm final Vector3D centralToBody = body.getPVCoordinates(s.getDate(), s.getFrame()).getPosition(); final double r2Central = centralToBody.getNormSq(); final Vector3D satToBody = centralToBody.subtract(s.getPVCoordinates().getPosition()); final double r2Sat = satToBody.getNormSq(); // compute relative acceleration final Vector3D gamma = new Vector3D(gm / (r2Sat * FastMath.sqrt(r2Sat)), satToBody, -gm / (r2Central * FastMath.sqrt(r2Central)), centralToBody); // add contribution to the ODE second member adder.addXYZAcceleration(gamma.getX(), gamma.getY(), gamma.getZ()); }
From source file:org.orekit.forces.gravity.ThirdBodyAttraction.java
/** {@inheritDoc} */ public FieldVector3D<DerivativeStructure> accelerationDerivatives(final AbsoluteDate date, final Frame frame, final FieldVector3D<DerivativeStructure> position, final FieldVector3D<DerivativeStructure> velocity, final FieldRotation<DerivativeStructure> rotation, final DerivativeStructure mass) throws OrekitException { // compute bodies separation vectors and squared norm final Vector3D centralToBody = body.getPVCoordinates(date, frame).getPosition(); final double r2Central = centralToBody.getNormSq(); final FieldVector3D<DerivativeStructure> satToBody = position.subtract(centralToBody).negate(); final DerivativeStructure r2Sat = satToBody.getNormSq(); // compute relative acceleration final FieldVector3D<DerivativeStructure> satAcc = new FieldVector3D<DerivativeStructure>( r2Sat.sqrt().multiply(r2Sat).reciprocal().multiply(gm), satToBody); final Vector3D centralAcc = new Vector3D(gm / (r2Central * FastMath.sqrt(r2Central)), centralToBody); return satAcc.subtract(centralAcc); }
From source file:org.orekit.forces.gravity.ThirdBodyAttraction.java
/** {@inheritDoc} */ public FieldVector3D<DerivativeStructure> accelerationDerivatives(final SpacecraftState s, final String paramName) throws OrekitException { complainIfNotSupported(paramName);//from w w w. j a va 2 s . com // compute bodies separation vectors and squared norm final Vector3D centralToBody = body.getPVCoordinates(s.getDate(), s.getFrame()).getPosition(); final double r2Central = centralToBody.getNormSq(); final Vector3D satToBody = centralToBody.subtract(s.getPVCoordinates().getPosition()); final double r2Sat = satToBody.getNormSq(); final DerivativeStructure gmds = new DerivativeStructure(1, 1, 0, gm); // compute relative acceleration return new FieldVector3D<DerivativeStructure>(gmds.divide(r2Sat * FastMath.sqrt(r2Sat)), satToBody, gmds.divide(-r2Central * FastMath.sqrt(r2Central)), centralToBody); }
From source file:org.orekit.forces.radiation.SolarRadiationPressure.java
/** {@inheritDoc} */ public void addContribution(final SpacecraftState s, final TimeDerivativesEquations adder) throws OrekitException { final AbsoluteDate date = s.getDate(); final Frame frame = s.getFrame(); final Vector3D position = s.getPVCoordinates().getPosition(); final Vector3D sunSatVector = position.subtract(sun.getPVCoordinates(date, frame).getPosition()); final double r2 = sunSatVector.getNormSq(); // compute flux final double rawP = kRef * getLightningRatio(position, frame, date) / r2; final Vector3D flux = new Vector3D(rawP / FastMath.sqrt(r2), sunSatVector); final Vector3D acceleration = spacecraft.radiationPressureAcceleration(date, frame, position, s.getAttitude().getRotation(), s.getMass(), flux); // provide the perturbing acceleration to the derivatives adder adder.addAcceleration(acceleration, s.getFrame()); }
From source file:org.orekit.forces.radiation.SolarRadiationPressure.java
/** {@inheritDoc} */ public FieldVector3D<DerivativeStructure> accelerationDerivatives(final SpacecraftState s, final String paramName) throws OrekitException { complainIfNotSupported(paramName);// www . j a v a2s.c o m final AbsoluteDate date = s.getDate(); final Frame frame = s.getFrame(); final Vector3D position = s.getPVCoordinates().getPosition(); final Vector3D sunSatVector = position.subtract(sun.getPVCoordinates(date, frame).getPosition()); final double r2 = sunSatVector.getNormSq(); // compute flux final double rawP = kRef * getLightningRatio(position, frame, date) / r2; final Vector3D flux = new Vector3D(rawP / FastMath.sqrt(r2), sunSatVector); return spacecraft.radiationPressureAcceleration(date, frame, position, s.getAttitude().getRotation(), s.getMass(), flux, paramName); }
From source file:org.orekit.forces.SphericalSpacecraftTest.java
@Test public void testDrag() throws OrekitException { AbsoluteDate date = new AbsoluteDate(new DateComponents(2008, 04, 07), TimeComponents.H00, TimeScalesFactory.getTAI()); // Satellite position as circular parameters final double mu = 3.9860047e14; final double raan = 270.; Orbit circ = new CircularOrbit(7178000.0, 0.5e-4, -0.5e-4, FastMath.toRadians(50.), FastMath.toRadians(raan), FastMath.toRadians(5.300 - raan), PositionAngle.MEAN, FramesFactory.getEME2000(), date, mu); SpacecraftState state = new SpacecraftState(circ); double surface = 5.0; double cd = 2.0; SphericalSpacecraft s = new SphericalSpacecraft(surface, cd, 0.0, 0.0); Vector3D relativeVelocity = new Vector3D(36.0, 48.0, 80.0); double rho = 0.001; Vector3D computedAcceleration = s.dragAcceleration(state.getDate(), state.getFrame(), state.getPVCoordinates().getPosition(), state.getAttitude().getRotation(), state.getMass(), rho, relativeVelocity);//from www . ja v a 2 s . co m Vector3D d = relativeVelocity.normalize(); double v2 = relativeVelocity.getNormSq(); Vector3D expectedAcceleration = new Vector3D(rho * surface * cd * v2 / (2 * state.getMass()), d); Assert.assertEquals(0.0, computedAcceleration.subtract(expectedAcceleration).getNorm(), 1.0e-15); }
From source file:org.orekit.frames.LOFType.java
/** Get the transform from an inertial frame defining position-velocity and the local orbital frame. * @param date current date// w w w . j a va 2 s. co m * @param pv position-velocity of the spacecraft in some inertial frame * @return transform from the frame where position-velocity are defined to local orbital frame */ public Transform transformFromInertial(final AbsoluteDate date, final PVCoordinates pv) { // compute the translation part of the transform final Transform translation = new Transform(date, pv.negate()); // compute the rotation part of the transform final Rotation r = rotationFromInertial(pv); final Vector3D p = pv.getPosition(); final Vector3D momentum = pv.getMomentum(); final Transform rotation = new Transform(date, r, new Vector3D(1.0 / p.getNormSq(), r.applyTo(momentum))); return new Transform(date, translation, rotation); }
From source file:org.orekit.orbits.CartesianOrbit.java
/** {@inheritDoc} */ public double getE() { final Vector3D pvP = getPVCoordinates().getPosition(); final Vector3D pvV = getPVCoordinates().getVelocity(); final double rV2OnMu = pvP.getNorm() * pvV.getNormSq() / getMu(); final double eSE = Vector3D.dotProduct(pvP, pvV) / FastMath.sqrt(getMu() * getA()); final double eCE = rV2OnMu - 1; return FastMath.sqrt(eCE * eCE + eSE * eSE); }
From source file:org.orekit.orbits.CartesianOrbit.java
/** Compute shifted position and velocity in elliptic case. * @param dt time shift/*from w w w .j av a 2 s.c o m*/ * @return shifted position and velocity */ private PVCoordinates shiftPVElliptic(final double dt) { // preliminary computation final Vector3D pvP = getPVCoordinates().getPosition(); final Vector3D pvV = getPVCoordinates().getVelocity(); final double r = pvP.getNorm(); final double rV2OnMu = r * pvV.getNormSq() / getMu(); final double a = getA(); final double eSE = Vector3D.dotProduct(pvP, pvV) / FastMath.sqrt(getMu() * a); final double eCE = rV2OnMu - 1; final double e2 = eCE * eCE + eSE * eSE; // we can use any arbitrary reference 2D frame in the orbital plane // in order to simplify some equations below, we use the current position as the u axis final Vector3D u = pvP.normalize(); final Vector3D v = Vector3D.crossProduct(getPVCoordinates().getMomentum(), u).normalize(); // the following equations rely on the specific choice of u explained above, // some coefficients that vanish to 0 in this case have already been removed here final double ex = (eCE - e2) * a / r; final double ey = -FastMath.sqrt(1 - e2) * eSE * a / r; final double beta = 1 / (1 + FastMath.sqrt(1 - e2)); final double thetaE0 = FastMath.atan2(ey + eSE * beta * ex, r / a + ex - eSE * beta * ey); final double thetaM0 = thetaE0 - ex * FastMath.sin(thetaE0) + ey * FastMath.cos(thetaE0); // compute in-plane shifted eccentric argument final double thetaM1 = thetaM0 + getKeplerianMeanMotion() * dt; final double thetaE1 = meanToEccentric(thetaM1, ex, ey); final double cTE = FastMath.cos(thetaE1); final double sTE = FastMath.sin(thetaE1); // compute shifted in-plane cartesian coordinates final double exey = ex * ey; final double exCeyS = ex * cTE + ey * sTE; final double x = a * ((1 - beta * ey * ey) * cTE + beta * exey * sTE - ex); final double y = a * ((1 - beta * ex * ex) * sTE + beta * exey * cTE - ey); final double factor = FastMath.sqrt(getMu() / a) / (1 - exCeyS); final double xDot = factor * (-sTE + beta * ey * exCeyS); final double yDot = factor * (cTE - beta * ex * exCeyS); final Vector3D shiftedP = new Vector3D(x, u, y, v); final double r2 = x * x + y * y; final Vector3D shiftedV = new Vector3D(xDot, u, yDot, v); final Vector3D shiftedA = new Vector3D(-getMu() / (r2 * FastMath.sqrt(r2)), shiftedP); return new PVCoordinates(shiftedP, shiftedV, shiftedA); }
From source file:org.orekit.orbits.CartesianOrbit.java
/** Compute shifted position and velocity in hyperbolic case. * @param dt time shift/*from w w w . j a v a2 s. c om*/ * @return shifted position and velocity */ private PVCoordinates shiftPVHyperbolic(final double dt) { final PVCoordinates pv = getPVCoordinates(); final Vector3D pvP = pv.getPosition(); final Vector3D pvV = pv.getVelocity(); final Vector3D pvM = pv.getMomentum(); final double r = pvP.getNorm(); final double rV2OnMu = r * pvV.getNormSq() / getMu(); final double a = getA(); final double muA = getMu() * a; final double e = FastMath.sqrt(1 - Vector3D.dotProduct(pvM, pvM) / muA); final double sqrt = FastMath.sqrt((e + 1) / (e - 1)); // compute mean anomaly final double eSH = Vector3D.dotProduct(pvP, pvV) / FastMath.sqrt(-muA); final double eCH = rV2OnMu - 1; final double H0 = FastMath.log((eCH + eSH) / (eCH - eSH)) / 2; final double M0 = e * FastMath.sinh(H0) - H0; // find canonical 2D frame with p pointing to perigee final double v0 = 2 * FastMath.atan(sqrt * FastMath.tanh(H0 / 2)); final Vector3D p = new Rotation(pvM, -v0).applyTo(pvP).normalize(); final Vector3D q = Vector3D.crossProduct(pvM, p).normalize(); // compute shifted eccentric anomaly final double M1 = M0 + getKeplerianMeanMotion() * dt; final double H1 = meanToHyperbolicEccentric(M1, e); // compute shifted in-plane cartesian coordinates final double cH = FastMath.cosh(H1); final double sH = FastMath.sinh(H1); final double sE2m1 = FastMath.sqrt((e - 1) * (e + 1)); // coordinates of position and velocity in the orbital plane final double x = a * (cH - e); final double y = -a * sE2m1 * sH; final double factor = FastMath.sqrt(getMu() / -a) / (e * cH - 1); final double xDot = -factor * sH; final double yDot = factor * sE2m1 * cH; final Vector3D shiftedP = new Vector3D(x, p, y, q); final double r2 = x * x + y * y; final Vector3D shiftedV = new Vector3D(xDot, p, yDot, q); final Vector3D shiftedA = new Vector3D(-getMu() / (r2 * FastMath.sqrt(r2)), shiftedP); return new PVCoordinates(shiftedP, shiftedV, shiftedA); }