summaryrefslogtreecommitdiffstats
path: root/core/math/vector3.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'core/math/vector3.cpp')
-rw-r--r--core/math/vector3.cpp74
1 files changed, 37 insertions, 37 deletions
diff --git a/core/math/vector3.cpp b/core/math/vector3.cpp
index 3eb978333d..2ab5fa0465 100644
--- a/core/math/vector3.cpp
+++ b/core/math/vector3.cpp
@@ -30,12 +30,12 @@
#include "matrix3.h"
-void Vector3::rotate(const Vector3& p_axis,float p_phi) {
+void Vector3::rotate(const Vector3& p_axis,real_t p_phi) {
*this=Basis(p_axis,p_phi).xform(*this);
}
-Vector3 Vector3::rotated(const Vector3& p_axis,float p_phi) const {
+Vector3 Vector3::rotated(const Vector3& p_axis,real_t p_phi) const {
Vector3 r = *this;
r.rotate(p_axis,p_phi);
@@ -63,13 +63,13 @@ int Vector3::max_axis() const {
}
-void Vector3::snap(float p_val) {
+void Vector3::snap(real_t p_val) {
x=Math::stepify(x,p_val);
y=Math::stepify(y,p_val);
z=Math::stepify(z,p_val);
}
-Vector3 Vector3::snapped(float p_val) const {
+Vector3 Vector3::snapped(real_t p_val) const {
Vector3 v=*this;
v.snap(p_val);
@@ -77,7 +77,7 @@ Vector3 Vector3::snapped(float p_val) const {
}
-Vector3 Vector3::cubic_interpolaten(const Vector3& p_b,const Vector3& p_pre_a, const Vector3& p_post_b,float p_t) const {
+Vector3 Vector3::cubic_interpolaten(const Vector3& p_b,const Vector3& p_pre_a, const Vector3& p_post_b,real_t p_t) const {
Vector3 p0=p_pre_a;
Vector3 p1=*this;
@@ -87,9 +87,9 @@ Vector3 Vector3::cubic_interpolaten(const Vector3& p_b,const Vector3& p_pre_a, c
{
//normalize
- float ab = p0.distance_to(p1);
- float bc = p1.distance_to(p2);
- float cd = p2.distance_to(p3);
+ real_t ab = p0.distance_to(p1);
+ real_t bc = p1.distance_to(p2);
+ real_t cd = p2.distance_to(p3);
if (ab>0)
p0 = p1+(p0-p1)*(bc/ab);
@@ -98,41 +98,41 @@ Vector3 Vector3::cubic_interpolaten(const Vector3& p_b,const Vector3& p_pre_a, c
}
- float t = p_t;
- float t2 = t * t;
- float t3 = t2 * t;
+ real_t t = p_t;
+ real_t t2 = t * t;
+ real_t t3 = t2 * t;
Vector3 out;
- out = 0.5f * ( ( p1 * 2.0f) +
+ out = 0.5 * ( ( p1 * 2.0) +
( -p0 + p2 ) * t +
- ( 2.0f * p0 - 5.0f * p1 + 4 * p2 - p3 ) * t2 +
- ( -p0 + 3.0f * p1 - 3.0f * p2 + p3 ) * t3 );
+ ( 2.0 * p0 - 5.0 * p1 + 4 * p2 - p3 ) * t2 +
+ ( -p0 + 3.0 * p1 - 3.0 * p2 + p3 ) * t3 );
return out;
}
-Vector3 Vector3::cubic_interpolate(const Vector3& p_b,const Vector3& p_pre_a, const Vector3& p_post_b,float p_t) const {
+Vector3 Vector3::cubic_interpolate(const Vector3& p_b,const Vector3& p_pre_a, const Vector3& p_post_b,real_t p_t) const {
Vector3 p0=p_pre_a;
Vector3 p1=*this;
Vector3 p2=p_b;
Vector3 p3=p_post_b;
- float t = p_t;
- float t2 = t * t;
- float t3 = t2 * t;
+ real_t t = p_t;
+ real_t t2 = t * t;
+ real_t t3 = t2 * t;
Vector3 out;
- out = 0.5f * ( ( p1 * 2.0f) +
+ out = 0.5 * ( ( p1 * 2.0) +
( -p0 + p2 ) * t +
- ( 2.0f * p0 - 5.0f * p1 + 4 * p2 - p3 ) * t2 +
- ( -p0 + 3.0f * p1 - 3.0f * p2 + p3 ) * t3 );
+ ( 2.0 * p0 - 5.0 * p1 + 4 * p2 - p3 ) * t2 +
+ ( -p0 + 3.0 * p1 - 3.0 * p2 + p3 ) * t3 );
return out;
}
#if 0
-Vector3 Vector3::cubic_interpolate(const Vector3& p_b,const Vector3& p_pre_a, const Vector3& p_post_b,float p_t) const {
+Vector3 Vector3::cubic_interpolate(const Vector3& p_b,const Vector3& p_pre_a, const Vector3& p_post_b,real_t p_t) const {
Vector3 p0=p_pre_a;
Vector3 p1=*this;
@@ -141,9 +141,9 @@ Vector3 Vector3::cubic_interpolate(const Vector3& p_b,const Vector3& p_pre_a, co
if (true) {
- float ab = p0.distance_to(p1);
- float bc = p1.distance_to(p2);
- float cd = p2.distance_to(p3);
+ real_t ab = p0.distance_to(p1);
+ real_t bc = p1.distance_to(p2);
+ real_t cd = p2.distance_to(p3);
//if (ab>bc) {
if (ab>0)
@@ -156,23 +156,23 @@ Vector3 Vector3::cubic_interpolate(const Vector3& p_b,const Vector3& p_pre_a, co
//}
}
- float t = p_t;
- float t2 = t * t;
- float t3 = t2 * t;
+ real_t t = p_t;
+ real_t t2 = t * t;
+ real_t t3 = t2 * t;
Vector3 out;
- out.x = 0.5f * ( ( 2.0f * p1.x ) +
+ out.x = 0.5 * ( ( 2.0 * p1.x ) +
( -p0.x + p2.x ) * t +
- ( 2.0f * p0.x - 5.0f * p1.x + 4 * p2.x - p3.x ) * t2 +
- ( -p0.x + 3.0f * p1.x - 3.0f * p2.x + p3.x ) * t3 );
- out.y = 0.5f * ( ( 2.0f * p1.y ) +
+ ( 2.0 * p0.x - 5.0 * p1.x + 4 * p2.x - p3.x ) * t2 +
+ ( -p0.x + 3.0 * p1.x - 3.0 * p2.x + p3.x ) * t3 );
+ out.y = 0.5 * ( ( 2.0 * p1.y ) +
( -p0.y + p2.y ) * t +
- ( 2.0f * p0.y - 5.0f * p1.y + 4 * p2.y - p3.y ) * t2 +
- ( -p0.y + 3.0f * p1.y - 3.0f * p2.y + p3.y ) * t3 );
- out.z = 0.5f * ( ( 2.0f * p1.z ) +
+ ( 2.0 * p0.y - 5.0 * p1.y + 4 * p2.y - p3.y ) * t2 +
+ ( -p0.y + 3.0 * p1.y - 3.0 * p2.y + p3.y ) * t3 );
+ out.z = 0.5 * ( ( 2.0 * p1.z ) +
( -p0.z + p2.z ) * t +
- ( 2.0f * p0.z - 5.0f * p1.z + 4 * p2.z - p3.z ) * t2 +
- ( -p0.z + 3.0f * p1.z - 3.0f * p2.z + p3.z ) * t3 );
+ ( 2.0 * p0.z - 5.0 * p1.z + 4 * p2.z - p3.z ) * t2 +
+ ( -p0.z + 3.0 * p1.z - 3.0 * p2.z + p3.z ) * t3 );
return out;
}
# endif