diff options
author | Hans Lambermont <hans@lambermont.dyndns.org> | 2002-10-12 15:37:38 +0400 |
---|---|---|
committer | Hans Lambermont <hans@lambermont.dyndns.org> | 2002-10-12 15:37:38 +0400 |
commit | 12315f4d0e0ae993805f141f64cb8c73c5297311 (patch) | |
tree | 59b45827cd8293cfb727758989c7a74b40183974 /intern/moto/include/MT_Point2.inl |
Initial revisionv2.25
Diffstat (limited to 'intern/moto/include/MT_Point2.inl')
-rw-r--r-- | intern/moto/include/MT_Point2.inl | 54 |
1 files changed, 54 insertions, 0 deletions
diff --git a/intern/moto/include/MT_Point2.inl b/intern/moto/include/MT_Point2.inl new file mode 100644 index 00000000000..ec09a3260e2 --- /dev/null +++ b/intern/moto/include/MT_Point2.inl @@ -0,0 +1,54 @@ +#include "MT_Optimize.h" + +GEN_INLINE MT_Point2& MT_Point2::operator+=(const MT_Vector2& v) { + m_co[0] += v[0]; m_co[1] += v[1]; + return *this; +} + +GEN_INLINE MT_Point2& MT_Point2::operator-=(const MT_Vector2& v) { + m_co[0] -= v[0]; m_co[1] -= v[1]; + return *this; +} + +GEN_INLINE MT_Point2& MT_Point2::operator=(const MT_Vector2& v) { + m_co[0] = v[0]; m_co[1] = v[1]; + return *this; +} + +GEN_INLINE MT_Scalar MT_Point2::distance(const MT_Point2& p) const { + return (p - *this).length(); +} + +GEN_INLINE MT_Scalar MT_Point2::distance2(const MT_Point2& p) const { + return (p - *this).length2(); +} + +GEN_INLINE MT_Point2 MT_Point2::lerp(const MT_Point2& p, MT_Scalar t) const { + return MT_Point2(m_co[0] + (p[0] - m_co[0]) * t, + m_co[1] + (p[1] - m_co[1]) * t); +} + +GEN_INLINE MT_Point2 operator+(const MT_Point2& p, const MT_Vector2& v) { + return MT_Point2(p[0] + v[0], p[1] + v[1]); +} + +GEN_INLINE MT_Point2 operator-(const MT_Point2& p, const MT_Vector2& v) { + return MT_Point2(p[0] - v[0], p[1] - v[1]); +} + +GEN_INLINE MT_Vector2 operator-(const MT_Point2& p1, const MT_Point2& p2) { + return MT_Vector2(p1[0] - p2[0], p1[1] - p2[1]); +} + +GEN_INLINE MT_Scalar MT_distance(const MT_Point2& p1, const MT_Point2& p2) { + return p1.distance(p2); +} + +GEN_INLINE MT_Scalar MT_distance2(const MT_Point2& p1, const MT_Point2& p2) { + return p1.distance2(p2); +} + +GEN_INLINE MT_Point2 MT_lerp(const MT_Point2& p1, const MT_Point2& p2, MT_Scalar t) { + return p1.lerp(p2, t); +} + |