MCPcopy Create free account
hub / github.com/SakuraEngine/SakuraEngine / Vector2

Class Vector2

modules/gui/gui/src/backend/text_server/vector2.h:37–143  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

35
36namespace godot{
37struct Vector2 {
38 static const int AXIS_COUNT = 2;
39
40 enum Axis {
41 AXIS_X,
42 AXIS_Y,
43 };
44
45 union {
46 struct {
47 union {
48 real_t x;
49 real_t width;
50 };
51 union {
52 real_t y;
53 real_t height;
54 };
55 };
56
57 real_t coord[2] = { 0 };
58 };
59
60 void normalize()
61 {
62 real_t l = x * x + y * y;
63 if (l != 0) {
64 l = ::sqrt(l);
65 x /= l;
66 y /= l;
67 }
68 }
69
70 Vector2 ceil() const
71 {
72 return Vector2(::ceil(x), ::ceil(y));
73 }
74
75 Vector2 normalized() const
76 {
77 Vector2 v = *this;
78 v.normalize();
79 return v;
80 }
81
82 Vector2 round() const
83 {
84 return Vector2(std::round(x), std::round(y));
85 }
86
87 real_t dot(const Vector2 &p_other) const
88 {
89 return x * p_other.x + y * p_other.y;
90 }
91
92 real_t cross(const Vector2 &p_other) const
93 {
94 return x * p_other.y - y * p_other.x;

Callers 15

basis_xformMethod · 0.85
basis_xform_invMethod · 0.85
xformMethod · 0.85
xform_invMethod · 0.85
ceilMethod · 0.85
roundMethod · 0.85
rotatedMethod · 0.85
operator-Method · 0.85
operator/Method · 0.85
operator*Method · 0.85
operator+Method · 0.85
operator-Method · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected