Search in sources :

Example 21 with Vector3d

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

Example 22 with Vector3d

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

Example 23 with Vector3d

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

Example 24 with Vector3d

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

Example 25 with Vector3d

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

Aggregations

Vector3d (gaiasky.util.math.Vector3d)120 IParticleRecord (gaiasky.scenegraph.particle.IParticleRecord)11 Array (com.badlogic.gdx.utils.Array)10 Vector3 (com.badlogic.gdx.math.Vector3)8 Vector3b (gaiasky.util.math.Vector3b)8 PointCloudData (gaiasky.data.util.PointCloudData)7 Keyframe (gaiasky.desktop.util.camera.Keyframe)5 Matrix4d (gaiasky.util.math.Matrix4d)5 Quaterniond (gaiasky.util.math.Quaterniond)5 ArrayList (java.util.ArrayList)5 BufferedReader (java.io.BufferedReader)4 InputStreamReader (java.io.InputStreamReader)4 PerspectiveCamera (com.badlogic.gdx.graphics.PerspectiveCamera)3 ChangeEvent (com.badlogic.gdx.scenes.scene2d.utils.ChangeListener.ChangeEvent)3 Vector2d (gaiasky.util.math.Vector2d)3 Path (java.nio.file.Path)3 Date (java.util.Date)3 Matrix4 (com.badlogic.gdx.math.Matrix4)2 OrbitComponent (gaiasky.scenegraph.component.OrbitComponent)2 ParticleRecord (gaiasky.scenegraph.particle.ParticleRecord)2