|
JNISpice version 2.0.0 |
||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectspice.basic.Quaternion
spice.basic.SpiceQuaternion
public class SpiceQuaternion
Class SpiceQuaternion represents and supports operations on SPICE-style quaternions.
Let M be a rotation matrix such that for any vector V,
M*Vis the result of rotating V by theta radians in the counterclockwise direction about unit rotation axis vector A. Then the SPICE quaternions representing M are
(+/-) ( cos(theta/2), sin(theta/2) A(1), sin(theta/2) A(2), sin(theta/2) A(3) )
Version 1.0.0 22-DEC-2009 (NJB)
Constructor Summary | |
---|---|
SpiceQuaternion()
Zero-arguments constructor: this creates a quaternion initialized with zeros. |
|
SpiceQuaternion(double[] inArray)
Create a SpiceQuaternion from a double array of length 4. |
|
SpiceQuaternion(double q0,
double q1,
double q2,
double q3)
Create a SpiceQuaternion from a list of four scalars. |
|
SpiceQuaternion(Matrix33 m)
Create a unit SpiceQuaternion from a rotation matrix. |
|
SpiceQuaternion(SpiceQuaternion q)
Copy constructor. |
Method Summary | |
---|---|
SpiceQuaternion |
add(SpiceQuaternion q2)
Add a second SpiceQuaternion to this instance. |
SpiceQuaternion |
conjugate()
Return the conjugate of this SpiceQuaternion. |
double |
dist(SpiceQuaternion q2)
Return the distance (L2) between this quaternion and another. |
Vector3 |
getAngularVelocity(SpiceQuaternion dq)
Map this SpiceQuaternion and its derivative with respect to time to an angular velocity vector. |
double |
getElt(int i)
Return the element of this quaternion at index [i]. |
double |
getScalar()
Return the scalar (real) portion of this instance. |
Vector3 |
getVector()
Return the vector (imaginary) portion of this instance. |
SpiceQuaternion |
mult(SpiceQuaternion q2)
Left-multiply a SpiceQuaternion by this SpiceQuaternion. |
SpiceQuaternion |
negate()
Negate this SpiceQuaternion. |
double |
norm()
Return the norm of this SpiceQuaternion. |
SpiceQuaternion |
scale(double s)
Scale this SpiceQuaternion. |
SpiceQuaternion |
sub(SpiceQuaternion q2)
Subtract a second SpiceQuaternion from this instance. |
double[] |
toArray()
Return the contents of this quaternion in a double array. |
Matrix33 |
toMatrix()
Convert this quaternion to a matrix. |
java.lang.String |
toString()
Convert a SpiceQuaternion to a String. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Constructor Detail |
---|
public SpiceQuaternion()
public SpiceQuaternion(SpiceQuaternion q)
public SpiceQuaternion(double[] inArray) throws SpiceException
SpiceException
public SpiceQuaternion(double q0, double q1, double q2, double q3)
public SpiceQuaternion(Matrix33 m) throws SpiceException
SpiceException
Method Detail |
---|
public SpiceQuaternion add(SpiceQuaternion q2)
public SpiceQuaternion conjugate()
public double dist(SpiceQuaternion q2)
public Vector3 getAngularVelocity(SpiceQuaternion dq) throws SpiceException
SpiceException
public double getElt(int i) throws SpiceException
SpiceException
public double getScalar()
public Vector3 getVector()
public SpiceQuaternion mult(SpiceQuaternion q2) throws SpiceException
Let this instance be represented by q1. The returned SpiceQuaternion `qout' is the quaternion product q1 * q2 Representing q(i) as the sum of scalar (real) part s(i) and vector (imaginary) part v(i) respectively, q1 = s1 + v1 q2 = s2 + v2 `qout' has scalar part s3 defined by s3 = s1 * s2 - <v1, v2> and vector part v3 defined by v3 = s1 * v2 + s2 * v1 + v1 x v2 where the notation < , > denotes the inner product operator and x indicates the cross product operator.
SpiceException
public SpiceQuaternion negate()
public double norm()
public SpiceQuaternion scale(double s)
public SpiceQuaternion sub(SpiceQuaternion q2)
public double[] toArray()
public Matrix33 toMatrix() throws SpiceException
Let FROM and TO be two right-handed reference frames, for example, an inertial frame and a spacecraft-fixed frame. Let the symbols V , V FROM TO denote, respectively, an arbitrary vector expressed relative to the FROM and TO frames. Let M denote the transformation matrix that transforms vectors from frame FROM to frame TO; then V = M * V TO FROM where the expression on the right hand side represents left multiplication of the vector by the matrix. Then if the unit-length SPICE quaternion q represents M, where q = (q0, q1, q2, q3) the elements of M are derived from the elements of q as follows: +- -+ | 2 2 | | 1 - 2*( q2 + q3 ) 2*(q1*q2 - q0*q3) 2*(q1*q3 + q0*q2) | | | | | | 2 2 | M = | 2*(q1*q2 + q0*q3) 1 - 2*( q1 + q3 ) 2*(q2*q3 - q0*q1) | | | | | | 2 2 | | 2*(q1*q3 - q0*q2) 2*(q2*q3 + q0*q1) 1 - 2*( q1 + q2 ) | | | +- -+ Note that substituting the elements of -q for those of q in the right hand side leaves each element of M unchanged; this shows that if a quaternion q represents a matrix M, then so does the quaternion -q.
SpiceException
public java.lang.String toString()
toString
in class java.lang.Object
|
JNISpice version 2.0.0 |
||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |