diff --git a/panda/src/linmath/lvector3_src.I b/panda/src/linmath/lvector3_src.I index dd3ae9651b..d330bd2ad7 100644 --- a/panda/src/linmath/lvector3_src.I +++ b/panda/src/linmath/lvector3_src.I @@ -199,6 +199,31 @@ angle_rad(const FLOATNAME(LVector3) &other) const { } } +//////////////////////////////////////////////////////////////////// +// Function: LVector::relative_angle_rad +// Access: Published +// Description: returns the signed angled between two vectors. +// normalization is NOT necessary +//////////////////////////////////////////////////////////////////// +INLINE_LINMATH FLOATTYPE FLOATNAME(LVector3):: +relative_angle_rad(const FLOATNAME(LVector3) &other) const { + //okay, we'll + return atan2((other._v.v._0*_v.v._1)-(other._v.v._1*_v.v._0), dot(other)); +} + +//////////////////////////////////////////////////////////////////// +// Function: LVector::relative_angle_deg +// Access: Published +// Description: returns the signed angled between two vectors. +// normalization is NOT necessary +//////////////////////////////////////////////////////////////////// +INLINE_LINMATH FLOATTYPE FLOATNAME(LVector3):: +relative_angle_deg(const FLOATNAME(LVector3) &other) const { + //okay, we'll + return relative_angle_rad(other)*180/3.1415926535; +} + + //////////////////////////////////////////////////////////////////// // Function: LVector::angle_deg // Access: Published diff --git a/panda/src/linmath/lvector3_src.h b/panda/src/linmath/lvector3_src.h index e0a2b79bb6..b594afd284 100644 --- a/panda/src/linmath/lvector3_src.h +++ b/panda/src/linmath/lvector3_src.h @@ -52,6 +52,10 @@ PUBLISHED: INLINE_LINMATH FLOATTYPE angle_rad(const FLOATNAME(LVector3) &other) const; INLINE_LINMATH FLOATTYPE angle_deg(const FLOATNAME(LVector3) &other) const; + INLINE_LINMATH FLOATTYPE relative_angle_rad(const FLOATNAME(LVector3) &other) const; + INLINE_LINMATH FLOATTYPE relative_angle_deg(const FLOATNAME(LVector3) &other) const; + + INLINE_LINMATH FLOATNAME(LVector3) operator * (FLOATTYPE scalar) const; INLINE_LINMATH FLOATNAME(LVector3) operator / (FLOATTYPE scalar) const;