summaryrefslogtreecommitdiffstats
path: root/include/godot_cpp/core/Vector3.h
blob: 9f97172aa08dbeab81643cc2fdc7cc787d3c2170 (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
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
#ifndef VECTOR3_H
#define VECTOR3_H

#include "Defs.h"

#include "String.h"

namespace godot {


struct Vector3 {

	enum Axis {
		AXIS_X,
		AXIS_Y,
		AXIS_Z,
	};

	union {
		struct {
			real_t x;
			real_t y;
			real_t z;
		};

		real_t coord[3];
	};

	Vector3(real_t x, real_t y, real_t z);

	Vector3();

	Vector3(const Vector3& b);

	const real_t& operator[](int p_axis) const;

	real_t& operator[](int p_axis);

	Vector3& operator+=(const Vector3& p_v);

	Vector3 operator+(const Vector3& p_v) const;

	Vector3& operator-=(const Vector3& p_v);

	Vector3 operator-(const Vector3& p_v) const;

	Vector3& operator*=(const Vector3& p_v);

	Vector3 operator*(const Vector3& p_v) const;

	Vector3& operator/=(const Vector3& p_v);

	Vector3 operator/(const Vector3& p_v) const;


	Vector3& operator*=(real_t p_scalar);

	Vector3 operator*(real_t p_scalar) const;

	Vector3& operator/=(real_t p_scalar);

	Vector3 operator/(real_t p_scalar) const;

	Vector3 operator-() const;

	bool operator==(const Vector3& p_v) const;

	bool operator!=(const Vector3& p_v) const;

	bool operator<(const Vector3& p_v) const;

	bool operator<=(const Vector3& p_v) const;

	Vector3 abs() const;

	Vector3 ceil() const;

	Vector3 cross(const Vector3& b) const;

	Vector3 linear_interpolate(const Vector3& p_b,real_t p_t) const;

	Vector3 cubic_interpolate(const Vector3& b, const Vector3& pre_a, const Vector3& post_b, const real_t t) const;

	real_t length() const;

	real_t length_squared() const;

	real_t distance_squared_to(const Vector3& b) const;

	real_t distance_to(const Vector3& b) const;

	real_t dot(const Vector3& b) const;

	Vector3 floor() const;

	Vector3 inverse() const;




	int max_axis() const;

	int min_axis() const;

	void normalize();

	Vector3 normalized() const;

	Vector3 reflect(const Vector3& by) const;

	Vector3 rotated(const Vector3& axis, const real_t phi) const;

	void rotate(const Vector3& p_axis,real_t p_phi);

	Vector3 slide(const Vector3& by) const;

	void snap(real_t p_val);

	Vector3 snapped(const float by);

	operator String() const;
};

inline Vector3 operator*(real_t p_scalar, const Vector3& p_vec)
{
	return p_vec * p_scalar;
}

inline Vector3 vec3_cross(const Vector3& p_a, const Vector3& p_b) {

	return p_a.cross(p_b);
}

}

#endif // VECTOR3_H