Merge pull request #851 from Zylann/quat_to_quaternion
Use `quaternion` instead of `quat` in method namespull/853/head
commit
d910b72cb7
|
@ -92,7 +92,7 @@ public:
|
||||||
Vector3 get_rotation_euler() const;
|
Vector3 get_rotation_euler() const;
|
||||||
void get_rotation_axis_angle(Vector3 &p_axis, real_t &p_angle) const;
|
void get_rotation_axis_angle(Vector3 &p_axis, real_t &p_angle) const;
|
||||||
void get_rotation_axis_angle_local(Vector3 &p_axis, real_t &p_angle) const;
|
void get_rotation_axis_angle_local(Vector3 &p_axis, real_t &p_angle) const;
|
||||||
Quaternion get_rotation_quat() const;
|
Quaternion get_rotation_quaternion() const;
|
||||||
Vector3 get_rotation() const { return get_rotation_euler(); };
|
Vector3 get_rotation() const { return get_rotation_euler(); };
|
||||||
|
|
||||||
Vector3 rotref_posscale_decomposition(Basis &rotref) const;
|
Vector3 rotref_posscale_decomposition(Basis &rotref) const;
|
||||||
|
@ -115,8 +115,8 @@ public:
|
||||||
Vector3 get_euler_zyx() const;
|
Vector3 get_euler_zyx() const;
|
||||||
void set_euler_zyx(const Vector3 &p_euler);
|
void set_euler_zyx(const Vector3 &p_euler);
|
||||||
|
|
||||||
Quaternion get_quat() const;
|
Quaternion get_quaternion() const;
|
||||||
void set_quat(const Quaternion &p_quat);
|
void set_quaternion(const Quaternion &p_quat);
|
||||||
|
|
||||||
Vector3 get_euler() const { return get_euler_yxz(); }
|
Vector3 get_euler() const { return get_euler_yxz(); }
|
||||||
void set_euler(const Vector3 &p_euler) { set_euler_yxz(p_euler); }
|
void set_euler(const Vector3 &p_euler) { set_euler_yxz(p_euler); }
|
||||||
|
@ -139,7 +139,7 @@ public:
|
||||||
|
|
||||||
void set_axis_angle_scale(const Vector3 &p_axis, real_t p_phi, const Vector3 &p_scale);
|
void set_axis_angle_scale(const Vector3 &p_axis, real_t p_phi, const Vector3 &p_scale);
|
||||||
void set_euler_scale(const Vector3 &p_euler, const Vector3 &p_scale);
|
void set_euler_scale(const Vector3 &p_euler, const Vector3 &p_scale);
|
||||||
void set_quat_scale(const Quaternion &p_quat, const Vector3 &p_scale);
|
void set_quaternion_scale(const Quaternion &p_quat, const Vector3 &p_scale);
|
||||||
|
|
||||||
// transposed dot products
|
// transposed dot products
|
||||||
inline real_t tdotx(const Vector3 &v) const {
|
inline real_t tdotx(const Vector3 &v) const {
|
||||||
|
@ -247,10 +247,10 @@ public:
|
||||||
#endif
|
#endif
|
||||||
Basis diagonalize();
|
Basis diagonalize();
|
||||||
|
|
||||||
operator Quaternion() const { return get_quat(); }
|
operator Quaternion() const { return get_quaternion(); }
|
||||||
|
|
||||||
Basis(const Quaternion &p_quat) { set_quat(p_quat); };
|
Basis(const Quaternion &p_quat) { set_quaternion(p_quat); };
|
||||||
Basis(const Quaternion &p_quat, const Vector3 &p_scale) { set_quat_scale(p_quat, p_scale); }
|
Basis(const Quaternion &p_quat, const Vector3 &p_scale) { set_quaternion_scale(p_quat, p_scale); }
|
||||||
|
|
||||||
Basis(const Vector3 &p_euler) { set_euler(p_euler); }
|
Basis(const Vector3 &p_euler) { set_euler(p_euler); }
|
||||||
Basis(const Vector3 &p_euler, const Vector3 &p_scale) { set_euler_scale(p_euler, p_scale); }
|
Basis(const Vector3 &p_euler, const Vector3 &p_scale) { set_euler_scale(p_euler, p_scale); }
|
||||||
|
|
|
@ -368,7 +368,7 @@ Vector3 Basis::get_rotation_euler() const {
|
||||||
return m.get_euler();
|
return m.get_euler();
|
||||||
}
|
}
|
||||||
|
|
||||||
Quaternion Basis::get_rotation_quat() const {
|
Quaternion Basis::get_rotation_quaternion() const {
|
||||||
// Assumes that the matrix can be decomposed into a proper rotation and scaling matrix as M = R.S,
|
// Assumes that the matrix can be decomposed into a proper rotation and scaling matrix as M = R.S,
|
||||||
// and returns the Euler angles corresponding to the rotation part, complementing get_scale().
|
// and returns the Euler angles corresponding to the rotation part, complementing get_scale().
|
||||||
// See the comment in get_scale() for further information.
|
// See the comment in get_scale() for further information.
|
||||||
|
@ -379,7 +379,7 @@ Quaternion Basis::get_rotation_quat() const {
|
||||||
m.scale(Vector3(-1, -1, -1));
|
m.scale(Vector3(-1, -1, -1));
|
||||||
}
|
}
|
||||||
|
|
||||||
return m.get_quat();
|
return m.get_quaternion();
|
||||||
}
|
}
|
||||||
|
|
||||||
void Basis::get_rotation_axis_angle(Vector3 &p_axis, real_t &p_angle) const {
|
void Basis::get_rotation_axis_angle(Vector3 &p_axis, real_t &p_angle) const {
|
||||||
|
@ -771,7 +771,7 @@ Basis::operator String() const {
|
||||||
return mtx;
|
return mtx;
|
||||||
}
|
}
|
||||||
|
|
||||||
Quaternion Basis::get_quat() const {
|
Quaternion Basis::get_quaternion() const {
|
||||||
#ifdef MATH_CHECKS
|
#ifdef MATH_CHECKS
|
||||||
ERR_FAIL_COND_V(!is_rotation(), Quaternion());
|
ERR_FAIL_COND_V(!is_rotation(), Quaternion());
|
||||||
#endif
|
#endif
|
||||||
|
@ -946,7 +946,7 @@ void Basis::get_axis_angle(Vector3 &r_axis, real_t &r_angle) const {
|
||||||
r_angle = angle;
|
r_angle = angle;
|
||||||
}
|
}
|
||||||
|
|
||||||
void Basis::set_quat(const Quaternion &p_quat) {
|
void Basis::set_quaternion(const Quaternion &p_quat) {
|
||||||
real_t d = p_quat.length_squared();
|
real_t d = p_quat.length_squared();
|
||||||
real_t s = 2.0 / d;
|
real_t s = 2.0 / d;
|
||||||
real_t xs = p_quat.x * s, ys = p_quat.y * s, zs = p_quat.z * s;
|
real_t xs = p_quat.x * s, ys = p_quat.y * s, zs = p_quat.z * s;
|
||||||
|
@ -998,7 +998,7 @@ void Basis::set_euler_scale(const Vector3 &p_euler, const Vector3 &p_scale) {
|
||||||
rotate(p_euler);
|
rotate(p_euler);
|
||||||
}
|
}
|
||||||
|
|
||||||
void Basis::set_quat_scale(const Quaternion &p_quat, const Vector3 &p_scale) {
|
void Basis::set_quaternion_scale(const Quaternion &p_quat, const Vector3 &p_scale) {
|
||||||
set_diagonal(p_scale);
|
set_diagonal(p_scale);
|
||||||
rotate(p_quat);
|
rotate(p_quat);
|
||||||
}
|
}
|
||||||
|
|
|
@ -113,15 +113,15 @@ Transform3D Transform3D::interpolate_with(const Transform3D &p_transform, real_t
|
||||||
/* not sure if very "efficient" but good enough? */
|
/* not sure if very "efficient" but good enough? */
|
||||||
|
|
||||||
Vector3 src_scale = basis.get_scale();
|
Vector3 src_scale = basis.get_scale();
|
||||||
Quaternion src_rot = basis.get_rotation_quat();
|
Quaternion src_rot = basis.get_rotation_quaternion();
|
||||||
Vector3 src_loc = origin;
|
Vector3 src_loc = origin;
|
||||||
|
|
||||||
Vector3 dst_scale = p_transform.basis.get_scale();
|
Vector3 dst_scale = p_transform.basis.get_scale();
|
||||||
Quaternion dst_rot = p_transform.basis.get_rotation_quat();
|
Quaternion dst_rot = p_transform.basis.get_rotation_quaternion();
|
||||||
Vector3 dst_loc = p_transform.origin;
|
Vector3 dst_loc = p_transform.origin;
|
||||||
|
|
||||||
Transform3D interp;
|
Transform3D interp;
|
||||||
interp.basis.set_quat_scale(src_rot.slerp(dst_rot, p_c).normalized(), src_scale.lerp(dst_scale, p_c));
|
interp.basis.set_quaternion_scale(src_rot.slerp(dst_rot, p_c).normalized(), src_scale.lerp(dst_scale, p_c));
|
||||||
interp.origin = src_loc.lerp(dst_loc, p_c);
|
interp.origin = src_loc.lerp(dst_loc, p_c);
|
||||||
|
|
||||||
return interp;
|
return interp;
|
||||||
|
|
Loading…
Reference in New Issue