Search in sources :

Example 1 with Quaterniond

use of gaiasky.util.math.Quaterniond in project gaiasky by langurmonkey.

the class AttitudeConverter method heliotropicToQuaternionSrsRates.

/**
 * Converts heliotropic angles and rates to the attitude quaternion
 * components and the inertial rates in SRS
 *
 * @param lSun
 *            longitude of the nominal sun [rad]
 * @param xi
 *            solar aspect angle [rad]
 * @param nu
 *            revolving phase angle [rad]
 * @param omega
 *            scan phase angle [rad]
 * @param lSunDot
 *            time derivative of lSun [rad/day]
 * @param nuDot
 *            time derivative of nu [rad/day]
 * @param omegaDot
 *            time derivative of omega [rad/day]
 * @return double[] array {qx, qy, qz, qw, rateX, rateY, rateZ} with rates in [rad/day]
 */
public static double[] heliotropicToQuaternionSrsRates(double lSun, double xi, double nu, double omega, double lSunDot, double nuDot, double omegaDot) {
    /**
     * SOME AXES NEED TO BE SWAPPED TO ALIGN WITH OUR REF SYS:
     * 	GLOBAL	GAIASANDBOX
     * 	Z -> Y
     * 	X -> Z
     * 	Y -> X
     */
    /**
     * 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(nu - PI_HALF)));
    q.mul(new Quaterniond(X_AXIS, Math.toDegrees(PI_HALF - xi)));
    q.mul(new Quaterniond(Y_AXIS, Math.toDegrees(omega)));
    /**
     * Calculate the inertial rate in SRS by adding the rotations around
     * k (ecliptic pole), s (solar direction), and z:
     */
    Vector3d k = new Vector3d(0, -sinObliquity, cosObliquity);
    k.mul(q);
    double sinLSun = Math.sin(lSun);
    double cosLSun = Math.cos(lSun);
    Vector3d sun = new Vector3d(cosLSun, cosObliquity * sinLSun, sinObliquity * sinLSun);
    sun.mul(q);
    double rateX = k.x * lSunDot + sun.x * nuDot;
    double rateY = k.y * lSunDot + sun.y * nuDot;
    double rateZ = k.z * lSunDot + sun.z * nuDot + omegaDot;
    return new double[] { q.z, q.x, q.y, q.w, rateZ, rateX, rateY };
}
Also used : Vector3d(gaiasky.util.math.Vector3d) Quaterniond(gaiasky.util.math.Quaterniond)

Example 2 with Quaterniond

use of gaiasky.util.math.Quaterniond in project gaiasky by langurmonkey.

the class AttitudeConverter method heliotropicToQuaternions.

/**
 * Converts heliotropic angles and rates to an attitude quaternion and its
 * derivative
 *
 * @param lSun
 *            longitude of the nominal sun [rad]
 * @param xi
 *            solar aspect angle [rad]
 * @param nu
 *            revolving phase angle [rad]
 * @param omega
 *            scan phase angle [rad]
 * @param lSunDot
 *            time derivative of lSun [rad/day]
 * @param nuDot
 *            time derivative of nu [rad/day]
 * @param omegaDot
 *            time derivative of omega [rad/day]
 * @return an array of two quaternions, q (the attitude quaternion) and qDot
 *         (the time derivative of q, per day)
 */
public static Quaterniond[] heliotropicToQuaternions(double lSun, double xi, double nu, double omega, double lSunDot, double nuDot, double omegaDot) {
    /**
     * SOME AXES NEED TO BE SWAPPED TO ALIGN WITH OUR REF SYS:
     * 	GLOBAL ->	GAIASANDBOX
     * 	Z -> Y
     * 	X -> Z
     * 	Y -> X
     */
    /**
     * 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(nu - PI_HALF)));
    q.mul(new Quaterniond(X_AXIS, Math.toDegrees(PI_HALF - xi)));
    q.mul(new Quaterniond(Y_AXIS, Math.toDegrees(omega)));
    /**
     * 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).rotateVectorByQuaternion(q);
    double rateX = nuDot * cosLSun + omegaDot * zInSrs.x;
    double rateY = -lSunDot * sinObliquity + nuDot * sinLSun * cosObliquity + omegaDot * zInSrs.y;
    double rateZ = lSunDot * cosObliquity + nuDot * sinLSun * sinObliquity + omegaDot * zInSrs.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 };
}
Also used : Vector3d(gaiasky.util.math.Vector3d) Quaterniond(gaiasky.util.math.Quaterniond)

Example 3 with Quaterniond

use of gaiasky.util.math.Quaterniond 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 };
}
Also used : NslSun(gaiasky.util.coord.NslSun) Vector3d(gaiasky.util.math.Vector3d) Quaterniond(gaiasky.util.math.Quaterniond)

Example 4 with Quaterniond

use of gaiasky.util.math.Quaterniond 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);
}
Also used : Vector3d(gaiasky.util.math.Vector3d) Quaterniond(gaiasky.util.math.Quaterniond)

Example 5 with Quaterniond

use of gaiasky.util.math.Quaterniond in project gaiasky by langurmonkey.

the class NslSun method heliotropicToQuaternion.

/**
 * Method to convert heliotropic angles to quaternion
 *
 * @param t
 *            time [ns]
 * @param xi
 *            revolving angle (solar aspect angle) [rad]
 * @param nu
 *            revolving phase [rad]
 * @param Omega
 *            spin phase [rad]
 * @return attitude quaternion
 */
public Quaterniond heliotropicToQuaternion(long t, double xi, double nu, double Omega) {
    setTime(t);
    double sLon = getSolarLongitude();
    /**
     * SOME AXES NEED TO BE SWAPPED TO ALIGN WITH OUR REF SYS:
     * 	GLOBAL ->	GAIASANDBOX
     * 	Z -> Y
     * 	X -> Z
     * 	Y -> X
     */
    Quaterniond q = new Quaterniond(Z_AXIS, OBLIQUITY_DEG);
    q.mul(new Quaterniond(Y_AXIS, Math.toDegrees(sLon)));
    q.mul(new Quaterniond(Z_AXIS, Math.toDegrees(nu - piHalf)));
    q.mul(new Quaterniond(X_AXIS, Math.toDegrees(piHalf - xi)));
    q.mul(new Quaterniond(Y_AXIS, Math.toDegrees(Omega)));
    return q;
}
Also used : Quaterniond(gaiasky.util.math.Quaterniond)

Aggregations

Quaterniond (gaiasky.util.math.Quaterniond)15 Vector3d (gaiasky.util.math.Vector3d)6 NslSun (gaiasky.util.coord.NslSun)2 Attitude (gaiasky.util.gaia.Attitude)1 Calendar (java.util.Calendar)1 Date (java.util.Date)1 GregorianCalendar (java.util.GregorianCalendar)1