mirror of
https://github.com/panda3d/panda3d.git
synced 2025-10-04 19:08:55 -04:00
more robustification
This commit is contained in:
parent
4ea946cf40
commit
efd134a00e
@ -187,6 +187,32 @@ set_from_matrix(const FLOATNAME(LMatrix4) &m) {
|
|||||||
set_from_matrix(m.get_upper_3());
|
set_from_matrix(m.get_upper_3());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
////////////////////////////////////////////////////////////////////
|
||||||
|
// Function: LQuaternion::get_axis
|
||||||
|
// Access: Public
|
||||||
|
// Description: This, along with get_angle(), returns the rotation
|
||||||
|
// represented by the quaternion as an angle about an
|
||||||
|
// arbitrary axis. This returns the axis.
|
||||||
|
////////////////////////////////////////////////////////////////////
|
||||||
|
INLINE_LINMATH FLOATNAME(LVector3) FLOATNAME(LQuaternion)::
|
||||||
|
get_axis() const {
|
||||||
|
return ::normalize(FLOATNAME(LVector3)(_v.data[1], _v.data[2], _v.data[3]));
|
||||||
|
}
|
||||||
|
|
||||||
|
////////////////////////////////////////////////////////////////////
|
||||||
|
// Function: LQuaternion::get_angle
|
||||||
|
// Access: Public
|
||||||
|
// Description: This, along with get_axis(), returns the rotation
|
||||||
|
// represented by the quaternion as an angle about an
|
||||||
|
// arbitrary axis. This returns the angle, in degrees
|
||||||
|
// counterclockwise about the axis.
|
||||||
|
////////////////////////////////////////////////////////////////////
|
||||||
|
INLINE_LINMATH FLOATTYPE FLOATNAME(LQuaternion)::
|
||||||
|
get_angle() const {
|
||||||
|
return rad_2_deg(acos(_v.data[0]) * 2.0);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////
|
||||||
// Function: LQuaternion::get_r
|
// Function: LQuaternion::get_r
|
||||||
// Access: public
|
// Access: public
|
||||||
@ -304,7 +330,7 @@ normalize() {
|
|||||||
////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////
|
||||||
INLINE_LINMATH bool FLOATNAME(LQuaternion)::
|
INLINE_LINMATH bool FLOATNAME(LQuaternion)::
|
||||||
invert_from(const FLOATNAME(LQuaternion) &other) {
|
invert_from(const FLOATNAME(LQuaternion) &other) {
|
||||||
set(other._v.v._0, -other._v.v._1, -other._v.v._2, -other._v.v._3);
|
set(-other._v.v._0, other._v.v._1, other._v.v._2, other._v.v._3);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -317,12 +343,20 @@ invert_from(const FLOATNAME(LQuaternion) &other) {
|
|||||||
////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////
|
||||||
INLINE_LINMATH bool FLOATNAME(LQuaternion)::
|
INLINE_LINMATH bool FLOATNAME(LQuaternion)::
|
||||||
invert_in_place() {
|
invert_in_place() {
|
||||||
_v.v._1 = -_v.v._1;
|
_v.v._0 = -_v.v._0;
|
||||||
_v.v._2 = -_v.v._2;
|
|
||||||
_v.v._3 = -_v.v._3;
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
////////////////////////////////////////////////////////////////////
|
||||||
|
// Function: LQuaternion::is_identity
|
||||||
|
// Access: Public
|
||||||
|
// Description: Returns true if this quaternion represents the
|
||||||
|
// identity transformation: no rotation.
|
||||||
|
////////////////////////////////////////////////////////////////////
|
||||||
|
INLINE_LINMATH bool FLOATNAME(LQuaternion)::
|
||||||
|
is_identity() const {
|
||||||
|
return (IS_NEARLY_EQUAL(_v.v._0, -1.0f) || IS_NEARLY_EQUAL(_v.v._0, 1.0f));
|
||||||
|
}
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////
|
||||||
// Function: LQuaternion::ident_quat
|
// Function: LQuaternion::ident_quat
|
||||||
|
@ -55,6 +55,9 @@ PUBLISHED:
|
|||||||
void set_hpr(const FLOATNAME(LVecBase3) &hpr);
|
void set_hpr(const FLOATNAME(LVecBase3) &hpr);
|
||||||
FLOATNAME(LVecBase3) get_hpr() const;
|
FLOATNAME(LVecBase3) get_hpr() const;
|
||||||
|
|
||||||
|
INLINE_LINMATH FLOATNAME(LVector3) get_axis() const;
|
||||||
|
INLINE_LINMATH FLOATTYPE get_angle() const;
|
||||||
|
|
||||||
INLINE_LINMATH FLOATTYPE get_r() const;
|
INLINE_LINMATH FLOATTYPE get_r() const;
|
||||||
INLINE_LINMATH FLOATTYPE get_i() const;
|
INLINE_LINMATH FLOATTYPE get_i() const;
|
||||||
INLINE_LINMATH FLOATTYPE get_j() const;
|
INLINE_LINMATH FLOATTYPE get_j() const;
|
||||||
@ -70,6 +73,7 @@ PUBLISHED:
|
|||||||
INLINE_LINMATH bool invert_from(const FLOATNAME(LQuaternion) &other);
|
INLINE_LINMATH bool invert_from(const FLOATNAME(LQuaternion) &other);
|
||||||
INLINE_LINMATH bool invert_in_place();
|
INLINE_LINMATH bool invert_in_place();
|
||||||
|
|
||||||
|
INLINE_LINMATH bool is_identity() const;
|
||||||
INLINE_LINMATH static const FLOATNAME(LQuaternion) &ident_quat();
|
INLINE_LINMATH static const FLOATNAME(LQuaternion) &ident_quat();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
Loading…
x
Reference in New Issue
Block a user