Welcome to mirror list, hosted at ThFree Co, Russian Federation.

MT_Point2.inl « include « moto « intern - git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: ec09a3260e23573f7cf54c20c6db8e9ddecf25f3 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
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);
}