2017-03-03 01:30:56 +00:00
|
|
|
#ifndef VECTOR3_H
|
|
|
|
#define VECTOR3_H
|
|
|
|
|
2017-03-06 07:49:24 +00:00
|
|
|
#include "Defs.hpp"
|
2017-03-03 01:30:56 +00:00
|
|
|
|
2017-03-06 07:49:24 +00:00
|
|
|
#include "String.hpp"
|
2017-03-03 01:30:56 +00:00
|
|
|
|
|
|
|
namespace godot {
|
|
|
|
|
2018-11-22 11:14:28 +00:00
|
|
|
class Basis;
|
2017-03-03 01:30:56 +00:00
|
|
|
|
2017-07-23 15:53:50 +00:00
|
|
|
struct Vector3 {
|
2017-03-03 01:30:56 +00:00
|
|
|
|
|
|
|
enum Axis {
|
|
|
|
AXIS_X,
|
|
|
|
AXIS_Y,
|
|
|
|
AXIS_Z,
|
|
|
|
};
|
|
|
|
|
|
|
|
union {
|
|
|
|
struct {
|
|
|
|
real_t x;
|
|
|
|
real_t y;
|
|
|
|
real_t z;
|
|
|
|
};
|
|
|
|
|
|
|
|
real_t coord[3];
|
|
|
|
};
|
|
|
|
|
2017-03-06 02:30:46 +00:00
|
|
|
Vector3(real_t x, real_t y, real_t z);
|
|
|
|
|
|
|
|
Vector3();
|
|
|
|
|
2018-11-23 22:09:41 +00:00
|
|
|
const real_t &operator[](int p_axis) const;
|
2017-03-06 02:30:46 +00:00
|
|
|
|
2018-11-23 22:09:41 +00:00
|
|
|
real_t &operator[](int p_axis);
|
2017-03-06 02:30:46 +00:00
|
|
|
|
2018-11-23 22:09:41 +00:00
|
|
|
Vector3 &operator+=(const Vector3 &p_v);
|
2017-03-06 02:30:46 +00:00
|
|
|
|
2018-11-23 22:09:41 +00:00
|
|
|
Vector3 operator+(const Vector3 &p_v) const;
|
2017-03-06 02:30:46 +00:00
|
|
|
|
2018-11-23 22:09:41 +00:00
|
|
|
Vector3 &operator-=(const Vector3 &p_v);
|
2017-03-06 02:30:46 +00:00
|
|
|
|
2018-11-23 22:09:41 +00:00
|
|
|
Vector3 operator-(const Vector3 &p_v) const;
|
2017-03-06 02:30:46 +00:00
|
|
|
|
2018-11-23 22:09:41 +00:00
|
|
|
Vector3 &operator*=(const Vector3 &p_v);
|
2017-03-06 02:30:46 +00:00
|
|
|
|
2018-11-23 22:09:41 +00:00
|
|
|
Vector3 operator*(const Vector3 &p_v) const;
|
2017-03-06 02:30:46 +00:00
|
|
|
|
2018-11-23 22:09:41 +00:00
|
|
|
Vector3 &operator/=(const Vector3 &p_v);
|
2017-03-06 02:30:46 +00:00
|
|
|
|
2018-11-23 22:09:41 +00:00
|
|
|
Vector3 operator/(const Vector3 &p_v) const;
|
2017-03-06 02:30:46 +00:00
|
|
|
|
2018-11-23 22:09:41 +00:00
|
|
|
Vector3 &operator*=(real_t p_scalar);
|
2017-03-06 02:30:46 +00:00
|
|
|
|
|
|
|
Vector3 operator*(real_t p_scalar) const;
|
|
|
|
|
2018-11-23 22:09:41 +00:00
|
|
|
Vector3 &operator/=(real_t p_scalar);
|
2017-03-06 02:30:46 +00:00
|
|
|
|
|
|
|
Vector3 operator/(real_t p_scalar) const;
|
|
|
|
|
|
|
|
Vector3 operator-() const;
|
|
|
|
|
2018-11-23 22:09:41 +00:00
|
|
|
bool operator==(const Vector3 &p_v) const;
|
2017-03-06 02:30:46 +00:00
|
|
|
|
2018-11-23 22:09:41 +00:00
|
|
|
bool operator!=(const Vector3 &p_v) const;
|
2017-03-06 02:30:46 +00:00
|
|
|
|
2018-11-23 22:09:41 +00:00
|
|
|
bool operator<(const Vector3 &p_v) const;
|
2017-03-06 02:30:46 +00:00
|
|
|
|
2018-11-23 22:09:41 +00:00
|
|
|
bool operator<=(const Vector3 &p_v) const;
|
2017-03-06 02:30:46 +00:00
|
|
|
|
|
|
|
Vector3 abs() const;
|
|
|
|
|
|
|
|
Vector3 ceil() const;
|
|
|
|
|
2018-11-23 22:09:41 +00:00
|
|
|
Vector3 cross(const Vector3 &b) const;
|
2017-03-06 02:30:46 +00:00
|
|
|
|
2018-11-23 22:09:41 +00:00
|
|
|
Vector3 linear_interpolate(const Vector3 &p_b, real_t p_t) const;
|
2017-03-06 02:30:46 +00:00
|
|
|
|
2018-11-23 22:09:41 +00:00
|
|
|
Vector3 cubic_interpolate(const Vector3 &b, const Vector3 &pre_a, const Vector3 &post_b, const real_t t) const;
|
2017-03-06 02:30:46 +00:00
|
|
|
|
2018-11-23 22:09:41 +00:00
|
|
|
Vector3 bounce(const Vector3 &p_normal) const;
|
2018-11-22 11:14:28 +00:00
|
|
|
|
2017-03-06 02:30:46 +00:00
|
|
|
real_t length() const;
|
|
|
|
|
|
|
|
real_t length_squared() const;
|
|
|
|
|
2018-11-23 22:09:41 +00:00
|
|
|
real_t distance_squared_to(const Vector3 &b) const;
|
2017-03-06 02:30:46 +00:00
|
|
|
|
2018-11-23 22:09:41 +00:00
|
|
|
real_t distance_to(const Vector3 &b) const;
|
2017-03-06 02:30:46 +00:00
|
|
|
|
2018-11-23 22:09:41 +00:00
|
|
|
real_t dot(const Vector3 &b) const;
|
2017-03-06 02:30:46 +00:00
|
|
|
|
2018-11-23 22:09:41 +00:00
|
|
|
real_t angle_to(const Vector3 &b) const;
|
2018-11-22 11:14:28 +00:00
|
|
|
|
2017-03-06 02:30:46 +00:00
|
|
|
Vector3 floor() const;
|
|
|
|
|
|
|
|
Vector3 inverse() const;
|
|
|
|
|
2018-11-22 11:14:28 +00:00
|
|
|
bool is_normalized() const;
|
|
|
|
|
2018-11-23 22:09:41 +00:00
|
|
|
Basis outer(const Vector3 &b) const;
|
2017-03-06 02:30:46 +00:00
|
|
|
|
|
|
|
int max_axis() const;
|
|
|
|
|
|
|
|
int min_axis() const;
|
|
|
|
|
|
|
|
void normalize();
|
|
|
|
|
|
|
|
Vector3 normalized() const;
|
|
|
|
|
2018-11-23 22:09:41 +00:00
|
|
|
Vector3 reflect(const Vector3 &by) const;
|
2017-03-06 02:30:46 +00:00
|
|
|
|
2018-11-23 22:09:41 +00:00
|
|
|
Vector3 rotated(const Vector3 &axis, const real_t phi) const;
|
2017-03-06 02:30:46 +00:00
|
|
|
|
2018-11-23 22:09:41 +00:00
|
|
|
void rotate(const Vector3 &p_axis, real_t p_phi);
|
2017-03-06 02:30:46 +00:00
|
|
|
|
2018-11-23 22:09:41 +00:00
|
|
|
Vector3 slide(const Vector3 &by) const;
|
2017-03-06 02:30:46 +00:00
|
|
|
|
|
|
|
void snap(real_t p_val);
|
|
|
|
|
|
|
|
Vector3 snapped(const float by);
|
|
|
|
|
|
|
|
operator String() const;
|
2017-03-03 01:30:56 +00:00
|
|
|
};
|
|
|
|
|
2018-11-23 22:09:41 +00:00
|
|
|
inline Vector3 operator*(real_t p_scalar, const Vector3 &p_vec) {
|
2017-03-03 01:30:56 +00:00
|
|
|
return p_vec * p_scalar;
|
|
|
|
}
|
|
|
|
|
2018-11-23 22:09:41 +00:00
|
|
|
inline Vector3 vec3_cross(const Vector3 &p_a, const Vector3 &p_b) {
|
2017-03-03 20:04:23 +00:00
|
|
|
|
|
|
|
return p_a.cross(p_b);
|
|
|
|
}
|
|
|
|
|
2018-11-23 22:09:41 +00:00
|
|
|
} // namespace godot
|
2017-03-03 01:30:56 +00:00
|
|
|
|
|
|
|
#endif // VECTOR3_H
|