Vector3: format properly, fix indents

(cherry picked from commit f468cfc379)
This commit is contained in:
J08nY 2016-10-01 20:54:31 +02:00 committed by Rémi Verschelde
parent f63b338e0f
commit 44ba542de6
2 changed files with 100 additions and 97 deletions

View file

@ -153,6 +153,7 @@ Vector3 Vector3::cross(const Vector3& p_b) const {
return ret;
}
real_t Vector3::dot(const Vector3& p_b) const {
return x*p_b.x + y*p_b.y + z*p_b.z;
@ -180,12 +181,12 @@ Vector3 Vector3::linear_interpolate(const Vector3& p_b,float p_t) const {
y+(p_t * (p_b.y-y)),
z+(p_t * (p_b.z-z))
);
}
real_t Vector3::distance_to(const Vector3& p_b) const {
return (p_b-*this).length();
}
real_t Vector3::distance_squared_to(const Vector3& p_b) const {
@ -202,6 +203,7 @@ Vector3& Vector3::operator+=(const Vector3& p_v) {
z+=p_v.z;
return *this;
}
Vector3 Vector3::operator+(const Vector3& p_v) const {
return Vector3(x+p_v.x, y+p_v.y, z+ p_v.z);
@ -240,20 +242,22 @@ Vector3& Vector3::operator/=(const Vector3& p_v) {
z/=p_v.z;
return *this;
}
Vector3 Vector3::operator/(const Vector3& p_v) const {
return Vector3(x/p_v.x, y/p_v.y, z/ p_v.z);
}
Vector3& Vector3::operator*=(real_t p_scalar) {
x*=p_scalar;
y*=p_scalar;
z*=p_scalar;
return *this;
}
_FORCE_INLINE_ Vector3 operator*(real_t p_scalar, const Vector3& p_vec) {
return p_vec * p_scalar;
}
@ -263,11 +267,11 @@ Vector3 Vector3::operator*(real_t p_scalar) const {
}
Vector3& Vector3::operator/=(real_t p_scalar) {
x/=p_scalar;
y/=p_scalar;
z/=p_scalar;
return *this;
}
Vector3 Vector3::operator/(real_t p_scalar) const {
@ -298,9 +302,9 @@ bool Vector3::operator<(const Vector3& p_v) const {
return z<p_v.z;
else
return y<p_v.y;
} else
} else {
return x<p_v.x;
}
}
bool Vector3::operator<=(const Vector3& p_v) const {
@ -310,9 +314,9 @@ bool Vector3::operator<=(const Vector3& p_v) const {
return z<=p_v.z;
else
return y<p_v.y;
} else
} else {
return x<p_v.x;
}
}
_FORCE_INLINE_ Vector3 vec3_cross(const Vector3& p_a, const Vector3& p_b) {
@ -333,6 +337,7 @@ real_t Vector3::length() const {
return Math::sqrt(x2+y2+z2);
}
real_t Vector3::length_squared() const {
real_t x2=x*x;
@ -340,22 +345,20 @@ real_t Vector3::length_squared() const {
real_t z2=z*z;
return x2+y2+z2;
}
void Vector3::normalize() {
real_t l=length();
if (l==0) {
x=y=z=0;
} else {
x/=l;
y/=l;
z/=l;
}
}
Vector3 Vector3::normalized() const {
Vector3 v=*this;
@ -377,10 +380,10 @@ Vector3 Vector3::slide(const Vector3& p_vec) const {
return p_vec - *this * this->dot(p_vec);
}
Vector3 Vector3::reflect(const Vector3& p_vec) const {
return p_vec - *this * this->dot(p_vec) * 2.0;
}
#endif