use of org.hipparchus.geometry.euclidean.threed.FieldVector3D in project Orekit by CS-SI.
the class BoxAndSolarArraySpacecraft method dragAcceleration.
/**
* {@inheritDoc}
*/
@Override
public FieldVector3D<DerivativeStructure> dragAcceleration(final AbsoluteDate date, final Frame frame, final Vector3D position, final Rotation rotation, final double mass, final double density, final Vector3D relativeVelocity, final double[] parameters, final String paramName) throws OrekitException {
final DerivativeStructure dragCoeffDS;
final DerivativeStructure liftRatioDS;
final DerivativeStructure oMrDS;
final Field<DerivativeStructure> field = factory.getDerivativeField();
if (dragParameterDriver.getName().equals(paramName)) {
final double liftRatio = liftParameterDriver == null ? 0.0 : parameters[1];
dragCoeffDS = factory.variable(0, parameters[0]);
liftRatioDS = factory.constant(liftRatio);
oMrDS = factory.constant(1 - liftRatio);
} else if (liftParameterDriver != null && liftParameterDriver.getName().equals(paramName)) {
dragCoeffDS = factory.constant(parameters[0]);
liftRatioDS = factory.variable(0, parameters[1]);
oMrDS = liftRatioDS.negate().add(1);
} else {
if (liftParameterDriver == null) {
throw new OrekitException(OrekitMessages.UNSUPPORTED_PARAMETER_NAME, paramName, dragParameterDriver.getName());
} else {
throw new OrekitException(OrekitMessages.UNSUPPORTED_PARAMETER_NAME, paramName, dragParameterDriver.getName(), liftParameterDriver.getName());
}
}
// relative velocity in spacecraft frame
final double vNorm2 = relativeVelocity.getNormSq();
final double vNorm = FastMath.sqrt(vNorm2);
final FieldVector3D<DerivativeStructure> vDir = new FieldVector3D<>(field, rotation.applyTo(relativeVelocity.scalarMultiply(1.0 / vNorm)));
final DerivativeStructure coeff = dragCoeffDS.multiply(0.5 * density * vNorm2 / mass);
// solar array facet contribution
final FieldVector3D<DerivativeStructure> frontNormal = new FieldVector3D<>(field, getNormal(date, frame, position, rotation));
final DerivativeStructure s = coeff.multiply(solarArrayArea).multiply(FieldVector3D.dotProduct(frontNormal, vDir));
FieldVector3D<DerivativeStructure> acceleration = new FieldVector3D<>(s.abs().multiply(oMrDS), vDir, s.multiply(liftRatioDS).multiply(2), frontNormal);
// body facets contribution
for (final Facet facet : facets) {
final DerivativeStructure dot = FieldVector3D.dotProduct(facet.getNormal(), vDir);
if (dot.getValue() < 0) {
// the facet intercepts the incoming flux
final DerivativeStructure f = coeff.multiply(facet.getArea()).multiply(dot);
acceleration = new FieldVector3D<>(field.getOne(), acceleration, f.abs().multiply(oMrDS), vDir, f.multiply(liftRatioDS).multiply(2), new FieldVector3D<>(field, facet.getNormal()));
}
}
// convert back to inertial frame
return new FieldRotation<>(field, rotation).applyInverseTo(acceleration);
}
use of org.hipparchus.geometry.euclidean.threed.FieldVector3D in project Orekit by CS-SI.
the class BoxAndSolarArraySpacecraft method getNormal.
/**
* Get solar array normal in spacecraft frame.
* @param date current date
* @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 lighting
* configuration
*/
public synchronized FieldVector3D<DerivativeStructure> getNormal(final AbsoluteDate date, final Frame frame, final FieldVector3D<DerivativeStructure> position, final FieldRotation<DerivativeStructure> rotation) throws OrekitException {
final DerivativeStructure zero = position.getX().getField().getZero();
if (referenceDate != null) {
// use a simple rotation at fixed rate
final DerivativeStructure alpha = zero.add(rotationRate * date.durationFrom(referenceDate));
return new FieldVector3D<>(alpha.cos(), saX, alpha.sin(), saY);
}
// compute orientation for best lighting
final FieldVector3D<DerivativeStructure> sunInert = position.subtract(sun.getPVCoordinates(date, frame).getPosition()).negate().normalize();
final FieldVector3D<DerivativeStructure> sunSpacecraft = rotation.applyTo(sunInert);
final DerivativeStructure d = FieldVector3D.dotProduct(sunSpacecraft, saZ);
final DerivativeStructure f = d.multiply(d).subtract(1).negate();
if (f.getValue() < Precision.EPSILON) {
// we set up an arbitrary normal
return new FieldVector3D<>(position.getX().getField(), saZ.orthogonal());
}
final DerivativeStructure s = f.sqrt().reciprocal();
return new FieldVector3D<>(s, sunSpacecraft, s.multiply(d).negate(), new FieldVector3D<>(zero.getField(), saZ));
}
use of org.hipparchus.geometry.euclidean.threed.FieldVector3D in project Orekit by CS-SI.
the class BoxAndSolarArraySpacecraft method radiationPressureAcceleration.
/**
* {@inheritDoc}
*/
@Override
public FieldVector3D<DerivativeStructure> radiationPressureAcceleration(final AbsoluteDate date, final Frame frame, final Vector3D position, final Rotation rotation, final double mass, final Vector3D flux, final double[] parameters, final String paramName) throws OrekitException {
if (flux.getNormSq() < Precision.SAFE_MIN) {
// null illumination (we are probably in umbra)
return FieldVector3D.getZero(factory.getDerivativeField());
}
final DerivativeStructure absorptionCoeffDS;
final DerivativeStructure specularReflectionCoeffDS;
if (ABSORPTION_COEFFICIENT.equals(paramName)) {
absorptionCoeffDS = factory.variable(0, parameters[0]);
specularReflectionCoeffDS = factory.constant(parameters[1]);
} else if (REFLECTION_COEFFICIENT.equals(paramName)) {
absorptionCoeffDS = factory.constant(parameters[0]);
specularReflectionCoeffDS = factory.variable(0, parameters[1]);
} else {
throw new OrekitException(OrekitMessages.UNSUPPORTED_PARAMETER_NAME, paramName, ABSORPTION_COEFFICIENT + ", " + REFLECTION_COEFFICIENT);
}
final DerivativeStructure diffuseReflectionCoeffDS = absorptionCoeffDS.add(specularReflectionCoeffDS).subtract(1).negate();
// radiation flux in spacecraft frame
final Vector3D fluxSat = rotation.applyTo(flux);
// solar array contribution
Vector3D normal = getNormal(date, frame, position, rotation);
double dot = Vector3D.dotProduct(normal, fluxSat);
if (dot > 0) {
// the solar array is illuminated backward,
// fix signs to compute contribution correctly
dot = -dot;
normal = normal.negate();
}
FieldVector3D<DerivativeStructure> force = facetRadiationAcceleration(normal, solarArrayArea, fluxSat, dot, specularReflectionCoeffDS, diffuseReflectionCoeffDS);
// body facets contribution
for (final Facet bodyFacet : facets) {
normal = bodyFacet.getNormal();
dot = Vector3D.dotProduct(normal, fluxSat);
if (dot < 0) {
// the facet intercepts the incoming flux
force = force.add(facetRadiationAcceleration(normal, bodyFacet.getArea(), fluxSat, dot, specularReflectionCoeffDS, diffuseReflectionCoeffDS));
}
}
// convert to inertial
return FieldRotation.applyInverseTo(rotation, new FieldVector3D<>(1.0 / mass, force));
}
use of org.hipparchus.geometry.euclidean.threed.FieldVector3D in project Orekit by CS-SI.
the class BoxAndSolarArraySpacecraft method facetRadiationAcceleration.
/**
* 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>
* @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)
* @param specularReflectionCoeffDS specular reflection coefficient
* @param diffuseReflectionCoeffDS diffuse reflection coefficient
* @return contribution of the facet to force in spacecraft frame
*/
private FieldVector3D<DerivativeStructure> facetRadiationAcceleration(final Vector3D normal, final double area, final Vector3D fluxSat, final double dot, final DerivativeStructure specularReflectionCoeffDS, final DerivativeStructure diffuseReflectionCoeffDS) {
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 DerivativeStructure cN = diffuseReflectionCoeffDS.divide(3).subtract(specularReflectionCoeffDS.multiply(dot / psr)).multiply(2 * area * dot);
final DerivativeStructure cS = specularReflectionCoeffDS.subtract(1).multiply(area * dot / psr);
return new FieldVector3D<>(cN, normal, cS, fluxSat);
}
use of org.hipparchus.geometry.euclidean.threed.FieldVector3D in project Orekit by CS-SI.
the class HolmesFeatherstoneAttractionModel method acceleration.
/**
* {@inheritDoc}
*/
public <T extends RealFieldElement<T>> FieldVector3D<T> acceleration(final FieldSpacecraftState<T> s, final T[] parameters) throws OrekitException {
final T mu = parameters[0];
// check for faster computation dedicated to derivatives with respect to state
if (isStateDerivative(s)) {
@SuppressWarnings("unchecked") final FieldVector3D<DerivativeStructure> p = (FieldVector3D<DerivativeStructure>) s.getPVCoordinates().getPosition();
@SuppressWarnings("unchecked") final FieldVector3D<T> a = (FieldVector3D<T>) accelerationWrtState(s.getDate().toAbsoluteDate(), s.getFrame(), p, (DerivativeStructure) mu);
return a;
}
// get the position in body frame
final FieldAbsoluteDate<T> date = s.getDate();
final Transform fromBodyFrame = bodyFrame.getTransformTo(s.getFrame(), date.toAbsoluteDate());
final Transform toBodyFrame = fromBodyFrame.getInverse();
final FieldVector3D<T> position = toBodyFrame.transformPosition(s.getPVCoordinates().getPosition());
// gradient of the non-central part of the gravity field
return fromBodyFrame.transformVector(new FieldVector3D<>(gradient(date, position, mu)));
}
Aggregations