18#include "IException.h"
20#include "NaifStatus.h"
29 for(
int i = 0; i < 4; i++) {
58 if(rotation.size() == 9) {
63 else if(rotation.size() == 4) {
67 std::string msg =
"Input vector of unexpected size for matrix or quaternion";
76 std::vector<double> matrix(9);
77 q2m_c(&
p_quaternion[0], (SpiceDouble( *)[3]) &matrix[0]);
118 std::vector<double> qout(4);
121 (SpiceDouble *) & (quat.p_quaternion[0]),
122 (SpiceDouble *) & (qout[0]));
175 double scalar2 = scalar * scalar;
176 double unitizer = 1 + qout.p_quaternion[0] * qout.p_quaternion[0] * (scalar2 - 1);
179 unitizer = sqrt(unitizer);
182 std::string msg =
"Unable to make quaternion a unit quaternion";
186 qout.p_quaternion[0] = (qout.p_quaternion[0] * scalar) / unitizer;
188 for(
int i = 1; i < 4; i++) {
189 qout.p_quaternion[i] /= unitizer;
201 for(
int i = 1; i < 4; i++) {
216 if(vin.size() != 3) {
217 std::string msg =
"Unexpected vector size -- 3 expected";
223 qvin.p_quaternion[1] = vin[0];
224 qvin.p_quaternion[2] = vin[1];
225 qvin.p_quaternion[3] = vin[2];
230 qvout *= conj.Conjugate();
231 std::vector<double> vout(qvout.p_quaternion.begin() + 1, qvout.p_quaternion.end());
244 if(quat.p_quaternion[0] < 0) {
245 quat.p_quaternion[0] = -quat.p_quaternion[0];
246 quat.p_quaternion[1] = -quat.p_quaternion[1];
247 quat.p_quaternion[2] = -quat.p_quaternion[2];
248 quat.p_quaternion[3] = -quat.p_quaternion[3];
261 std::vector<double> rotationMatrix =
ToMatrix();
262 SpiceDouble ang1, ang2, ang3;
264 m2eul_c((SpiceDouble *) &rotationMatrix[0], axis3, axis2, axis1,
265 &ang3, &ang2, &ang1);
267 std::vector<double> angles;
268 angles.push_back(ang1);
269 angles.push_back(ang2);
270 angles.push_back(ang3);
@ Programmer
This error is for when a programmer made an API call that was illegal.
static void CheckErrors(bool resetNaif=true)
This method looks for any naif errors that might have occurred.
Provide operations for quaternion arithmetic.
Quaternion & operator=(const Quaternion &quat)
Assign value of quaternion class to another quaternion.
std::vector< double > ToMatrix()
Converts quaternion to 3x3 rotational matrix.
std::vector< double > ToAngles(int axis3, int axis2, int axis1)
Return the camera angles (right ascension, declination, and twist) for the quaternion.
void Polish(Quaternion &quat)
Polish the quaternion – make the first component positive.
Quaternion Conjugate()
Returns the conjugate of the quaternion.
Quaternion()
Constructs an empty quaternion.
Quaternion operator*(const Quaternion &quat) const
Multiply two Naif quaternions to create a new quaternion.
~Quaternion()
Destroys the Quaternion object.
std::vector< double > Qxv(const std::vector< double > &vin)
Multiply a vector by a quaternion (rotate the vector)
std::vector< double > p_quaternion
Quaternion.
void Set(std::vector< double >)
Sets the quaternion value.
Quaternion & operator*=(const Quaternion &quat)
Multiply current Naif quaternion by another Naif quaternion, replacing the current quaternion.
This is free and unencumbered software released into the public domain.