Quaternion class. More...
Public Member Functions | |
quaternion () | |
default constructor More... | |
quaternion (const vec3 &axis, float angle) | |
constructor from axis and angle More... | |
quaternion (const vec4 &v) | |
direct constructor More... | |
quaternion (float x, float y, float z, float w) | |
direct constructor More... | |
vec3 | axis () const |
get the unit axis corresponding to the quaternion More... | |
float | angle () const |
get the angle corresponding to the quaternion More... | |
matrix3 | matrix () const |
compute the rotation matrix associated to the current quaternion More... | |
quaternion | conjugated () const |
get the conjugate of the current quaterion More... | |
vec3 | rotate (const vec3 &vec) const |
apply a rotation (encoded by the quaternion) to the vector/point 3D More... | |
quaternion & | operator*= (const quaternion &q) |
internal multiplication by other quaternion More... | |
quaternion & | operator*= (float s) |
internal multiplication by a scalar More... | |
quaternion & | operator+= (const quaternion &q) |
internal addition with other quaternion More... | |
quaternion & | operator-= (const quaternion &q) |
internal substraction with other quaternion More... | |
quaternion & | operator/= (float s) |
internal division by a scalar More... | |
quaternion | operator* (const quaternion &q) const |
multiplication by other quaternion More... | |
quaternion | operator* (const vec3 &v) const |
multiplication with a v3 seen as a quaternion (v.w()=0) More... | |
quaternion | operator* (float s) const |
multiplication with scalar More... | |
quaternion | operator+ (const quaternion &q) const |
addition with other quaternionn More... | |
quaternion | operator- (const quaternion &q) const |
substraction with other quaternionn More... | |
quaternion | operator/ (float s) const |
division by a scalar More... | |
quaternion | operator- () const |
unary negation More... | |
![]() | |
vec4 () | |
empty constructor More... | |
vec4 (float x, float y, float z, float w) | |
direct constructor More... | |
float | x () const |
get x coordinate More... | |
float & | x () |
get x coordinate More... | |
float | y () const |
get y coordinate More... | |
float & | y () |
get y coordinate More... | |
float | z () const |
get z coordinate More... | |
float & | z () |
get z coordinate More... | |
float | w () const |
get w coordinate More... | |
float & | w () |
get w coordinate More... | |
float | operator[] (const size_t &k) const |
Access to the k_th entry (k in [0,3]) More... | |
float & | operator[] (const size_t &k) |
Access to the k_th entry (k in [0,3]) More... | |
float | operator() (const size_t &k) const |
Access to the k_th entry (k in [0,3]) More... | |
float & | operator() (const size_t &k) |
Access to the k_th entry (k in [0,3]) More... | |
void | set_zero () |
set every entry to 0 More... | |
const float * | pointer () const |
fast pointer access More... | |
vec3 | to_vec3 () const |
convert to v3 (x,y,z) More... | |
vec2 | to_vec2 () const |
convert to v2 (x,y) More... | |
float | dot (const vec4 &p) const |
perform dot product between two v4 More... | |
float | norm () const |
get the norm of the vector More... | |
float | norm2 () const |
get the square norm of the vector More... | |
vec4 | normalized () const |
normalize the vector to unit length More... | |
vec4 | operator+ (const vec4 &p2) const |
| |
vec4 | operator+ (float s) const |
| |
vec4 | operator- (const vec4 &p2) const |
| |
vec4 | operator- (float s) const |
| |
vec4 | operator* (float s) const |
multiply by a scalar operator More... | |
vec4 | operator/ (float s) const |
divide by a scalar operator More... | |
vec4 & | operator+= (const vec4 &p) |
internal + More... | |
vec4 & | operator+= (float s) |
internal + More... | |
vec4 & | operator-= (const vec4 &p) |
internal - More... | |
vec4 & | operator-= (float s) |
internal - More... | |
vec4 & | operator*= (float s) |
internal * More... | |
vec4 & | operator/= (float s) |
internal / More... | |
vec4 | operator- () const |
unary negation More... | |
vec4 | product_compontentwise (const vec4 &p) const |
does componentwise mutliplication More... | |
vec4 & | product_compontentwise_internal (const vec4 &p) |
does componentwise mutliplication More... | |
void | scale (float sx, float sy, float sz, float sw) |
internal scaling (similar to componentwise) More... | |
std::string | to_string () const |
export the value as string cout<<v4(2,3,6,7) => 2 3 6 7 More... | |
Static Public Member Functions | |
static quaternion | slerp (const quaternion &q0, const quaternion &q1, const float alpha) |
Spherical Linear Interpolation SLERP. More... | |
Quaternion class.
cpe::quaternion::quaternion | ( | ) |
default constructor
Referenced by conjugated(), operator*(), operator*=(), and operator-().
cpe::quaternion::quaternion | ( | const vec3 & | axis, |
float | angle | ||
) |
constructor from axis and angle
References cpe::vec3::normalized(), cpe::vec4::w(), cpe::vec4::x(), cpe::vec4::y(), and cpe::vec4::z().
cpe::quaternion::quaternion | ( | const vec4 & | v | ) |
direct constructor
cpe::quaternion::quaternion | ( | float | x, |
float | y, | ||
float | z, | ||
float | w | ||
) |
direct constructor
float cpe::quaternion::angle | ( | ) | const |
get the angle corresponding to the quaternion
References cpe::vec4::w().
vec3 cpe::quaternion::axis | ( | ) | const |
get the unit axis corresponding to the quaternion
References cpe::vec3::normalized(), cpe::vec4::x(), cpe::vec4::y(), and cpe::vec4::z().
quaternion cpe::quaternion::conjugated | ( | ) | const |
get the conjugate of the current quaterion
References quaternion(), cpe::vec4::vec4(), cpe::vec4::w(), cpe::vec4::x(), cpe::vec4::y(), and cpe::vec4::z().
matrix3 cpe::quaternion::matrix | ( | ) | const |
compute the rotation matrix associated to the current quaternion
References cpe::vec4::w(), cpe::vec4::x(), cpe::vec4::y(), and cpe::vec4::z().
quaternion cpe::quaternion::operator* | ( | const quaternion & | q | ) | const |
multiplication by other quaternion
quaternion cpe::quaternion::operator* | ( | const vec3 & | v | ) | const |
multiplication with a v3 seen as a quaternion (v.w()=0)
References quaternion(), cpe::vec4::w(), cpe::vec3::x(), cpe::vec4::x(), cpe::vec3::y(), cpe::vec4::y(), cpe::vec3::z(), and cpe::vec4::z().
quaternion cpe::quaternion::operator* | ( | float | s | ) | const |
multiplication with scalar
quaternion & cpe::quaternion::operator*= | ( | const quaternion & | q | ) |
internal multiplication by other quaternion
References quaternion(), cpe::vec4::w(), cpe::vec4::x(), cpe::vec4::y(), and cpe::vec4::z().
quaternion & cpe::quaternion::operator*= | ( | float | s | ) |
internal multiplication by a scalar
References cpe::vec4::w(), cpe::vec4::x(), cpe::vec4::y(), and cpe::vec4::z().
quaternion cpe::quaternion::operator+ | ( | const quaternion & | q | ) | const |
addition with other quaternionn
quaternion & cpe::quaternion::operator+= | ( | const quaternion & | q | ) |
internal addition with other quaternion
References cpe::vec4::w(), cpe::vec4::x(), cpe::vec4::y(), and cpe::vec4::z().
quaternion cpe::quaternion::operator- | ( | const quaternion & | q | ) | const |
substraction with other quaternionn
quaternion cpe::quaternion::operator- | ( | ) | const |
unary negation
References quaternion(), cpe::vec4::vec4(), cpe::vec4::w(), cpe::vec4::x(), cpe::vec4::y(), and cpe::vec4::z().
quaternion & cpe::quaternion::operator-= | ( | const quaternion & | q | ) |
internal substraction with other quaternion
References cpe::vec4::w(), cpe::vec4::x(), cpe::vec4::y(), and cpe::vec4::z().
quaternion cpe::quaternion::operator/ | ( | float | s | ) | const |
division by a scalar
quaternion & cpe::quaternion::operator/= | ( | float | s | ) |
internal division by a scalar
References cpe::vec4::w(), cpe::vec4::x(), cpe::vec4::y(), and cpe::vec4::z().
apply a rotation (encoded by the quaternion) to the vector/point 3D
References cpe::vec4::w(), cpe::vec3::x(), cpe::vec4::x(), cpe::vec3::y(), cpe::vec4::y(), cpe::vec3::z(), and cpe::vec4::z().
|
static |
Spherical Linear Interpolation SLERP.
Use (sin((1-t) theta )q0 +sin(t theta)q1)/sin(theta) But same results with (q1 q0^{-1})^{t} q0 (q1*q0.invert()).pow_q(t)*q0)
References cpe::vec4::dot(), cpe::vec4::norm(), cpe::vec4::w(), cpe::vec4::x(), cpe::vec4::y(), and cpe::vec4::z().