diff --git a/panda3d_src/panda/src/linmath/lvector3_src.I b/panda3d_src/panda/src/linmath/lvector3_src.I index 0a920e9..5de9938 100644 --- a/panda3d_src/panda/src/linmath/lvector3_src.I +++ b/panda3d_src/panda/src/linmath/lvector3_src.I @@ -176,6 +176,16 @@ cross(const FLOATNAME(LVecBase3) &other) const { } //////////////////////////////////////////////////////////////////// +// Function: LVector3::project +// Access: Published +// Description: Returns a projection of this vector onto another one. +//////////////////////////////////////////////////////////////////// +INLINE_LINMATH FLOATNAME(LVector3) FLOATNAME(LVector3):: +project(const FLOATNAME(LVector3) &onto) const { + return onto * dot(onto) / onto.length_squared(); +} + +//////////////////////////////////////////////////////////////////// // Function: LVector::angle_rad // Access: Published // Description: Returns the angle between this vector and the other diff --git a/panda3d_src/panda/src/linmath/lvector3_src.h b/panda3d_src/panda/src/linmath/lvector3_src.h index 2b932dd..cfbeeb9 100644 --- a/panda3d_src/panda/src/linmath/lvector3_src.h +++ b/panda3d_src/panda/src/linmath/lvector3_src.h @@ -45,6 +45,7 @@ PUBLISHED: INLINE_LINMATH FLOATNAME(LVector3) operator - (const FLOATNAME(LVector3) &other) const; INLINE_LINMATH FLOATNAME(LVector3) cross(const FLOATNAME(LVecBase3) &other) const; + INLINE_LINMATH FLOATNAME(LVector3) project(const FLOATNAME(LVector3) &onto) const; INLINE_LINMATH FLOATTYPE angle_rad(const FLOATNAME(LVector3) &other) const; INLINE_LINMATH FLOATTYPE angle_deg(const FLOATNAME(LVector3) &other) const;