List of usage examples for org.apache.commons.math3.geometry.euclidean.threed Vector3D Vector3D
public Vector3D(double a1, Vector3D u1, double a2, Vector3D u2)
From source file:org.orekit.attitudes.GroundPointing.java
/** {@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); }//www . j ava 2 s .co m // 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); }
From source file:org.orekit.attitudes.YawCompensation.java
/** {@inheritDoc} */ @Override/* w w w . j a v a2 s .c o m*/ public Attitude getAttitude(final PVCoordinatesProvider pvProv, final AbsoluteDate date, final Frame frame) throws OrekitException { final Transform bodyToRef = getBodyFrame().getTransformTo(frame, date); // compute sliding target ground point final PVCoordinates slidingRef = getTargetPV(pvProv, date, frame); final PVCoordinates slidingBody = bodyToRef.getInverse().transformPVCoordinates(slidingRef); // compute relative position of sliding ground point with respect to satellite final PVCoordinates relativePosition = new PVCoordinates(pvProv.getPVCoordinates(date, frame), slidingRef); // compute relative velocity of fixed ground point with respect to sliding ground point // the velocity part of the transformPVCoordinates for the sliding point ps // from body frame to reference frame is: // d(ps_ref)/dt = r(d(ps_body)/dt + dq/dt) - ps_ref // where r is the rotation part of the transform, is the corresponding // angular rate, and dq/dt is the derivative of the translation part of the // transform (the translation itself, without derivative, is hidden in the // ps_ref part in the cross product). // The sliding point ps is co-located to a fixed ground point pf (i.e. they have the // same position at time of computation), but this fixed point as zero velocity // with respect to the ground. So the velocity part of the transformPVCoordinates // for this fixed point can be computed using the same formula as above: // from body frame to reference frame is: // d(pf_ref)/dt = r(0 + dq/dt) - pf_ref // so remembering that the two points are at the same location at computation time, // i.e. that at t=0 pf_ref=ps_ref, the relative velocity between the fixed point // and the sliding point is given by the simple expression: // d(ps_ref)/dt - d(pf_ref)/dt = r(d(ps_body)/dt) // the acceleration is computed by differentiating the expression, which gives: // d(ps_ref)/dt - d(pf_ref)/dt = r(d(ps_body)/dt) - [d(ps_ref)/dt - d(pf_ref)/dt] final Vector3D v = bodyToRef.getRotation().applyTo(slidingBody.getVelocity()); final Vector3D a = new Vector3D(+1, bodyToRef.getRotation().applyTo(slidingBody.getAcceleration()), -1, Vector3D.crossProduct(bodyToRef.getRotationRate(), v)); final PVCoordinates relativeVelocity = new PVCoordinates(v, a, Vector3D.ZERO); final PVCoordinates relativeNormal = PVCoordinates.crossProduct(relativePosition, relativeVelocity) .normalize(); // attitude definition : // . Z satellite axis points to sliding target // . target relative velocity is in (Z,X) plane, in the -X half plane part return new Attitude(frame, new TimeStampedAngularCoordinates(date, relativePosition.normalize(), relativeNormal.normalize(), PLUS_K, PLUS_J, 1.0e-9)); }
From source file:org.orekit.bodies.Ellipse.java
/** Project position-velocity-acceleration on an ellipse. * @param pv position-velocity-acceleration to project, in the reference frame * @return projected position-velocity-acceleration */// ww w .j a va 2 s. c om 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); }
From source file:org.orekit.forces.BoxAndSolarArraySpacecraft.java
/** Get solar array normal in spacecraft frame. * @param date current date/*from w ww.jav a 2 s.com*/ * @param frame inertial reference frame for state (both orbit and attitude) * @param position position of spacecraft in reference frame * @param rotation orientation (attitude) of the spacecraft with respect to reference frame * @return solar array normal in spacecraft frame * @exception OrekitException if sun direction cannot be computed in best lightning * configuration */ public synchronized Vector3D getNormal(final AbsoluteDate date, final Frame frame, final Vector3D position, final Rotation rotation) throws OrekitException { if (referenceDate != null) { // use a simple rotation at fixed rate final double alpha = rotationRate * date.durationFrom(referenceDate); return new Vector3D(FastMath.cos(alpha), saX, FastMath.sin(alpha), saY); } // compute orientation for best lightning final Vector3D sunInert = sun.getPVCoordinates(date, frame).getPosition().subtract(position).normalize(); final Vector3D sunSpacecraft = rotation.applyTo(sunInert); final double d = Vector3D.dotProduct(sunSpacecraft, saZ); final double f = 1 - d * d; if (f < Precision.EPSILON) { // extremely rare case: the sun is along solar array rotation axis // (there will not be much output power ...) // we set up an arbitrary normal return saZ.orthogonal(); } final double s = 1.0 / FastMath.sqrt(f); return new Vector3D(s, sunSpacecraft, -s * d, saZ); }
From source file:org.orekit.forces.BoxAndSolarArraySpacecraft.java
/** Compute contribution of one facet to force. * <p>This method implements equation 8-44 from David A. Vallado's * Fundamentals of Astrodynamics and Applications, third edition, * 2007, Microcosm Press.</p>//from www.j a va 2 s .c om * @param normal facet normal * @param area facet area * @param fluxSat radiation pressure flux in spacecraft frame * @param dot dot product of facet and fluxSat (must be negative) * @return contribution of the facet to force in spacecraft frame */ private Vector3D facetRadiationAcceleration(final Vector3D normal, final double area, final Vector3D fluxSat, final double dot) { final double psr = fluxSat.getNorm(); // Vallado's equation 8-44 uses different parameters which are related to our parameters as: // cos (phi) = -dot / (psr * area) // n = facet / area // s = -fluxSat / psr final double cN = 2 * area * dot * (diffuseReflectionCoeff / 3 - specularReflectionCoeff * dot / psr); final double cS = (area * dot / psr) * (specularReflectionCoeff - 1); return new Vector3D(cN, normal, cS, fluxSat); }
From source file:org.orekit.forces.gravity.Relativity.java
@Override public void addContribution(final SpacecraftState s, final TimeDerivativesEquations adder) throws OrekitException { final PVCoordinates pv = s.getPVCoordinates(); final Vector3D p = pv.getPosition(); final Vector3D v = pv.getVelocity(); //radius//from www . ja v a 2 s . co m final double r2 = p.getNormSq(); final double r = FastMath.sqrt(r2); //speed final double s2 = v.getNormSq(); final double c2 = Constants.SPEED_OF_LIGHT * Constants.SPEED_OF_LIGHT; //eq. 3.146 final Vector3D accel = new Vector3D(4 * this.gm / r - s2, p, 4 * p.dotProduct(v), v) .scalarMultiply(this.gm / (r2 * r * c2)); adder.addAcceleration(accel, s.getFrame()); }
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.frames.HelmertTransformation.java
/** Compute the transform at some date. * @param date date at which the transform is desired * @return computed transform at specified date *//* w w w . j a v a2 s . c o m*/ public Transform getTransform(final AbsoluteDate date) { // compute parameters evolution since reference epoch final double dt = date.durationFrom(epoch); final Vector3D dR = new Vector3D(1, rotationVector, dt, rotationRate); // build translation part final Transform translationTransform = new Transform(date, cartesian.shiftedBy(dt)); // build rotation part final double angle = dR.getNorm(); final Transform rotationTransform = new Transform(date, (angle < Precision.SAFE_MIN) ? Rotation.IDENTITY : new Rotation(dR, angle), rotationRate); // combine both parts return new Transform(date, translationTransform, rotationTransform); }
From source file:org.orekit.models.earth.tessellation.ConstantAzimuthAiming.java
/** {@inheritDoc} */ @Override/*from w ww. j a va2 s . c o m*/ public Vector3D alongTileDirection(final Vector3D point, final GeodeticPoint gp) { // compute the horizontal direction at fixed azimuth return new Vector3D(cos, gp.getNorth(), sin, gp.getEast()); }
From source file:org.orekit.models.earth.tessellation.EllipsoidTessellator.java
/** Extract tiles from a mesh. * @param mesh mesh from which tiles should be extracted * @param zone zone covered by the mesh//from ww w . j a v a2 s.c o m * @param lengthOverlap overlap between adjacent tiles * @param widthOverlap overlap between adjacent tiles * @param truncateLastWidth true if we can reduce last tile width * @param truncateLastLength true if we can reduce last tile length * @return extracted tiles * @exception OrekitException if tile direction cannot be computed */ private List<Tile> extractTiles(final Mesh mesh, final SphericalPolygonsSet zone, final double lengthOverlap, final double widthOverlap, final boolean truncateLastWidth, final boolean truncateLastLength) throws OrekitException { final List<Tile> tiles = new ArrayList<Tile>(); final List<RangePair> rangePairs = new ArrayList<RangePair>(); final int minAcross = mesh.getMinAcrossIndex(); final int maxAcross = mesh.getMaxAcrossIndex(); for (Range acrossPair : nodesIndices(minAcross, maxAcross, truncateLastWidth)) { int minAlong = mesh.getMaxAlongIndex() + 1; int maxAlong = mesh.getMinAlongIndex() - 1; for (int c = acrossPair.lower; c <= acrossPair.upper; ++c) { minAlong = FastMath.min(minAlong, mesh.getMinAlongIndex(c)); maxAlong = FastMath.max(maxAlong, mesh.getMaxAlongIndex(c)); } for (Range alongPair : nodesIndices(minAlong, maxAlong, truncateLastLength)) { // get the base vertex nodes final Mesh.Node node0 = mesh.addNode(alongPair.lower, acrossPair.lower); final Mesh.Node node1 = mesh.addNode(alongPair.upper, acrossPair.lower); final Mesh.Node node2 = mesh.addNode(alongPair.upper, acrossPair.upper); final Mesh.Node node3 = mesh.addNode(alongPair.lower, acrossPair.upper); // apply tile overlap final S2Point s2p0 = node0.move(new Vector3D(-0.5 * lengthOverlap, node0.getAlong(), -0.5 * widthOverlap, node0.getAcross())); final S2Point s2p1 = node1.move(new Vector3D(+0.5 * lengthOverlap, node1.getAlong(), -0.5 * widthOverlap, node1.getAcross())); final S2Point s2p2 = node2.move(new Vector3D(+0.5 * lengthOverlap, node2.getAlong(), +0.5 * widthOverlap, node2.getAcross())); final S2Point s2p3 = node3.move(new Vector3D(-0.5 * lengthOverlap, node2.getAlong(), +0.5 * widthOverlap, node2.getAcross())); // create a quadrilateral region corresponding to the candidate tile final SphericalPolygonsSet quadrilateral = new SphericalPolygonsSet(zone.getTolerance(), s2p0, s2p1, s2p2, s2p3); if (!new RegionFactory<Sphere2D>().intersection(zone.copySelf(), quadrilateral).isEmpty()) { // the tile does cover part of the zone, it contributes to the tessellation tiles.add(new Tile(toGeodetic(s2p0), toGeodetic(s2p1), toGeodetic(s2p2), toGeodetic(s2p3))); rangePairs.add(new RangePair(acrossPair, alongPair)); } } } // ensure the taxicab boundary follows the built tile sides // this is done outside of the previous loop because in order // to avoid one tile changing the min/max indices of the // neighboring tile as they share some nodes that will be enabled here for (final RangePair rangePair : rangePairs) { for (int c = rangePair.across.lower; c < rangePair.across.upper; ++c) { mesh.addNode(rangePair.along.lower, c + 1).setEnabled(); mesh.addNode(rangePair.along.upper, c).setEnabled(); } for (int l = rangePair.along.lower; l < rangePair.along.upper; ++l) { mesh.addNode(l, rangePair.across.lower).setEnabled(); mesh.addNode(l + 1, rangePair.across.upper).setEnabled(); } } return tiles; }