use of gaiasky.util.math.Vector3d in project gaiasky by langurmonkey.
the class AttitudeConverter method getQuaternionAndRate.
/**
* Converts heliotropic angles and rates to an attitude quaternion and its
* derivative
*
* @param gt
* GaiaTime
* @param h
* heliotropic angles and their rates in [rad] and [rad/day]
* @return
* @return an array of two quaternions, q (the attitude quaternion) and qDot
* (the time derivative of q, per day)
*/
public static Quaterniond[] getQuaternionAndRate(long gt, HeliotropicAnglesRates h) {
/**
* SOME AXES NEED TO BE SWAPPED TO ALIGN WITH OUR REF SYS:
* GLOBAL GAIASANDBOX
* Z -> Y
* X -> Z
* Y -> X
*/
NslSun sun = new NslSun();
sun.setTime(gt);
double lSun = sun.getSolarLongitude();
double lSunDot = sun.getSolarLongitudeDot();
/**
* Calculate the attitude quaternion *
*/
Quaterniond q = new Quaterniond(Z_AXIS, OBLIQUITY_DEG);
q.mul(new Quaterniond(Y_AXIS, Math.toDegrees(lSun)));
q.mul(new Quaterniond(Z_AXIS, Math.toDegrees(h.getNu() - PI_HALF)));
q.mul(new Quaterniond(X_AXIS, Math.toDegrees(PI_HALF - h.getXi())));
q.mul(new Quaterniond(Y_AXIS, Math.toDegrees(h.getOmega())));
/**
* Calculate the time derivative of the attitude quaternion using (A.17)
* in AGIS paper, based on the rates in the ICRS:
*/
double sinLSun = Math.sin(lSun);
double cosLSun = Math.cos(lSun);
Vector3d zInSrs = aux1;
zInSrs.set(Y_AXIS).mul(q);
Vector3d sz = aux2;
sz.set(sun.getSolarDirection(aux3)).crs(zInSrs).nor();
double rateX = h.getNuDot() * cosLSun + h.getOmegaDot() * zInSrs.x + h.getXiDot() * sz.x;
double rateY = -lSunDot * sinObliquity + h.getNuDot() * sinLSun * cosObliquity + h.getOmegaDot() * zInSrs.y + h.getXiDot() * sz.y;
double rateZ = lSunDot * cosObliquity + h.getNuDot() * sinLSun * sinObliquity + h.getOmegaDot() * zInSrs.z + h.getXiDot() * sz.z;
Quaterniond halfSpinInIcrs = new Quaterniond(0.5 * rateZ, 0.5 * rateX, 0.5 * rateY, 0.0);
Quaterniond qDot = halfSpinInIcrs.mul(q);
return new Quaterniond[] { q, qDot };
}
use of gaiasky.util.math.Vector3d in project gaiasky by langurmonkey.
the class ConcreteAttitude method getSpinVectorInIcrs.
/**
*/
@Override
public Vector3d getSpinVectorInIcrs() {
// Using (A.17) in AGIS paper (A&A 538, A78, 2012):
Quaterniond tmp = qDot.cpy();
tmp.mulInverse(q);
return new Vector3d(2. * tmp.x, 2. * tmp.y, 2. * tmp.z);
}
use of gaiasky.util.math.Vector3d in project gaiasky by langurmonkey.
the class ConcreteAttitude method getAlAcRates.
/**
*/
@Override
public double[] getAlAcRates(double alInstrumentAngle, double acFieldAngle) {
// Formulas (11) and (12) from GAIA-LL-056 : valid for any scanning law
double cphi = Math.cos(alInstrumentAngle);
double sphi = Math.sin(alInstrumentAngle);
double tzeta = Math.tan(acFieldAngle);
// The inertial rate in SRS in [rad/s]:
Vector3d spinRate = getSpinVectorInSrs().scl(86400.);
// Along scan speed in rad/s
double phip = -spinRate.z + (spinRate.x * cphi + spinRate.y * sphi) * tzeta;
// Across scan speed in rad/s
double zetap = -spinRate.x * sphi + spinRate.y * cphi;
return new double[] { phip, zetap };
}
use of gaiasky.util.math.Vector3d in project gaiasky by langurmonkey.
the class ConcreteAttitude method getFovDirections.
/**
*/
@Override
public Vector3d[] getFovDirections() {
// half the nominal basic angle:
double halfBasicAngle = 0.5 * Math.toRadians(BASICANGLE_DEGREE);
// xyz[0], xyz[1], xyz[2] are unit vectors (in ICRS) along the SRS axes:
getSrsAxes(xyz);
Vector3d xScaled = xyz[0].scl(Math.cos(halfBasicAngle));
Vector3d yScaled = xyz[1].scl(Math.sin(halfBasicAngle));
// PFoV = x * cos(halfBasicAngle) + y * sin(halfBasicAngle):
// .set(xScaled).add(yScaled);
fovDirections[0].set(xScaled).add(yScaled);
// FFoV = x * cos(halfBasicAngle) - y * sin(halfBasicAngle):
fovDirections[1].set(xScaled).sub(yScaled);
return fovDirections;
}
use of gaiasky.util.math.Vector3d in project gaiasky by langurmonkey.
the class Epsl method setDefault.
/**
* @see gaiasky.util.gaia.AnalyticalAttitudeDataServer#setDefault()
*/
@Override
public void setDefault() {
super.setDefault();
setTargetPrecessionRate(0.0);
switch(currentMode) {
case PRECEDING:
super.setNuRef(0.0);
break;
case FOLLOWING:
super.setNuRef(Math.PI);
break;
}
spinVector = new Vector3d();
setInitialized(true);
}
Aggregations