Beispiel #1
0
 public void setOrientation(Quaternion orientation)
 {
     this._initial_orientation = orientation;
     this.orientation_given = true;
 }
Beispiel #2
0
        public Vector3D QuaternionRotate(Quaternion RotationQuaternion)
        {
            Quaternion RotationQuaternionConjugate = RotationQuaternion.conjugate();
            Quaternion vec = new Quaternion(0, this._x, this._y, this._z);

            Quaternion result = RotationQuaternion * vec * RotationQuaternionConjugate;

            return result.getVector();
        }
Beispiel #3
0
 public void setBatchSet(double time, Vector3D pos, Quaternion orientation)
 {
     Spacecraft sc = new Spacecraft();
     sc.setPosition(pos);
     if (orientation.Norm() > 0)
     {
         sc.setOrientation(orientation);
     }
     sc.setFixedTime(time);
     this.spacecrafts.Add(sc);
 }
Beispiel #4
0
        public Vector3D QuaternionRotate(Vector3D axis, double angle)
        {
            Quaternion RotationQuaternion = new RotationQuaternion(axis, angle);
            Quaternion RotationQuaternionConjugate = RotationQuaternion.conjugate();
            Quaternion vec = new Quaternion(0, this._x, this._y, this._z);

            Quaternion result = RotationQuaternion * vec * RotationQuaternionConjugate;

            return result.getVector();
        }
Beispiel #5
0
        public void setTime(double time)
        {
            this._time = time;
            if (this.fixedPositionGiven)
            {
                this._position = this._fixed_position;
            }
            else
            {
                this._position = this._kepler_orbit.getPosition(time);
            }
            this._sun_position = this.calculateSunPosition();

            if (this.isOrientationGiven())
            {
                // take orientation transition into account
                this._orientation = new RotationQuaternion(new Vector3D(0, 0, 1), this._orientation_transition.z()) *
                                    new RotationQuaternion(new Vector3D(0, 1, 0), this._orientation_transition.y()) *
                                    new RotationQuaternion(new Vector3D(1, 0, 0), this._orientation_transition.x()) *
                                    this._initial_orientation;
                this._POV_right = this._POV_right.QuaternionRotate(this._orientation);
                this._POV_direction = ((new Vector3D(-1, 0, 0).QuaternionRotate(this._orientation) / (new Vector3D(-1, 0, 0).QuaternionRotate(this._orientation).norm())) * ((0.5 * this._POV_right.norm()) / Math.Tan(tools.deg2rad(Program.sim.getFOV()) / 2)));
            }
            else
            {
                // calculate necessary orientation quaternion to look nadir
                double phi, theta, r;
                r = this.getPosition().norm();
                phi = Math.Atan2(this.getPosition().y(), this.getPosition().x());
                theta = Math.Acos(this.getPosition().z() / r);

                this._orientation = new RotationQuaternion(new Vector3D(0, 1, 0), theta) * new RotationQuaternion(new Vector3D(0, 0, 1), -phi);
                this._POV_right = this._POV_right.QuaternionRotate(this._orientation);
                this._POV_direction = ((new Vector3D(-this.getPosition().x(), -this.getPosition().y(), -this.getPosition().z()) / (new Vector3D(-this.getPosition().x(), -this.getPosition().y(), -this.getPosition().z()).norm())) * ((0.5 * this._POV_right.norm()) / Math.Tan(tools.deg2rad(Program.sim.getFOV()) / 2)));
            }

            this._POV_up = this._POV_right % this._POV_direction; // cross product
            this._POV_up = this._POV_up / this._POV_up.norm();
        }