godot-cpp/include/core/Basis.hpp

139 lines
2.5 KiB
C++
Raw Normal View History

2017-03-03 02:14:34 +00:00
#ifndef BASIS_H
#define BASIS_H
2017-03-06 07:49:24 +00:00
#include "Defs.hpp"
2017-03-06 07:49:24 +00:00
#include "Vector3.hpp"
2017-03-03 02:14:34 +00:00
namespace godot {
class Quat;
class Basis {
2017-03-03 02:14:34 +00:00
public:
union {
Vector3 elements[3];
Vector3 x, y, z;
};
2017-03-03 02:14:34 +00:00
Basis(const Quat& p_quat); // euler
Basis(const Vector3& p_euler); // euler
Basis(const Vector3& p_axis, real_t p_phi);
Basis(const Vector3& row0, const Vector3& row1, const Vector3& row2);
2017-03-03 02:14:34 +00:00
Basis(real_t xx, real_t xy, real_t xz, real_t yx, real_t yy, real_t yz, real_t zx, real_t zy, real_t zz);
2017-03-03 02:14:34 +00:00
Basis();
2017-03-03 02:14:34 +00:00
const Vector3& operator[](int axis) const;
Vector3& operator[](int axis);
2017-03-03 02:14:34 +00:00
void invert();
2017-03-03 02:14:34 +00:00
bool isequal_approx(const Basis& a, const Basis& b) const;
2017-03-03 02:14:34 +00:00
bool is_orthogonal() const;
2017-03-03 02:14:34 +00:00
bool is_rotation() const;
2017-03-03 02:14:34 +00:00
void transpose();
2017-03-03 02:14:34 +00:00
Basis inverse() const;
2017-03-03 02:14:34 +00:00
Basis transposed() const;
2017-03-03 02:14:34 +00:00
real_t determinant() const;
2017-03-03 02:14:34 +00:00
Vector3 get_axis(int p_axis) const;
2017-03-03 02:14:34 +00:00
void set_axis(int p_axis, const Vector3& p_value);
2017-03-03 02:14:34 +00:00
void rotate(const Vector3& p_axis, real_t p_phi);
2017-03-03 02:14:34 +00:00
Basis rotated(const Vector3& p_axis, real_t p_phi) const;
2017-03-03 02:14:34 +00:00
void scale( const Vector3& p_scale );
2017-03-03 02:14:34 +00:00
Basis scaled( const Vector3& p_scale ) const;
2017-03-03 02:14:34 +00:00
Vector3 get_scale() const;
2017-03-03 02:14:34 +00:00
Vector3 get_euler() const;
2017-03-03 02:14:34 +00:00
void set_euler(const Vector3& p_euler);
2017-03-03 02:14:34 +00:00
// transposed dot products
real_t tdotx(const Vector3& v) const;
real_t tdoty(const Vector3& v) const;
real_t tdotz(const Vector3& v) const;
2017-03-03 02:14:34 +00:00
bool operator==(const Basis& p_matrix) const;
2017-03-03 02:14:34 +00:00
bool operator!=(const Basis& p_matrix) const;
2017-03-03 02:14:34 +00:00
Vector3 xform(const Vector3& p_vector) const;
2017-03-03 02:14:34 +00:00
Vector3 xform_inv(const Vector3& p_vector) const;
void operator*=(const Basis& p_matrix);
2017-03-03 02:14:34 +00:00
Basis operator*(const Basis& p_matrix) const;
2017-03-03 02:14:34 +00:00
void operator+=(const Basis& p_matrix);
2017-03-03 02:14:34 +00:00
Basis operator+(const Basis& p_matrix) const;
2017-03-03 02:14:34 +00:00
void operator-=(const Basis& p_matrix);
2017-03-03 02:14:34 +00:00
Basis operator-(const Basis& p_matrix) const;
2017-03-03 02:14:34 +00:00
void operator*=(real_t p_val);
2017-03-03 02:14:34 +00:00
Basis operator*(real_t p_val) const;
2017-03-03 02:14:34 +00:00
int get_orthogonal_index() const; // down below
2017-03-03 02:14:34 +00:00
void set_orthogonal_index(int p_index); // down below
2017-03-03 02:14:34 +00:00
operator String() const;
2017-03-03 02:14:34 +00:00
void get_axis_and_angle(Vector3 &r_axis,real_t& r_angle) const;
2017-03-03 02:14:34 +00:00
/* create / set */
2017-03-03 02:14:34 +00:00
void set(real_t xx, real_t xy, real_t xz, real_t yx, real_t yy, real_t yz, real_t zx, real_t zy, real_t zz);
2017-03-03 02:14:34 +00:00
Vector3 get_column(int i) const;
2017-03-03 02:14:34 +00:00
Vector3 get_row(int i) const;
Vector3 get_main_diagonal() const;
2017-03-03 02:14:34 +00:00
void set_row(int i, const Vector3& p_row);
2017-03-03 02:14:34 +00:00
Basis transpose_xform(const Basis& m) const;
2017-03-03 02:14:34 +00:00
void orthonormalize();
Basis orthonormalized() const;
bool is_symmetric() const;
2017-03-03 02:14:34 +00:00
Basis diagonalize();
2017-03-03 02:14:34 +00:00
operator Quat() const;
};
2017-03-03 02:14:34 +00:00
}
#endif // BASIS_H