summaryrefslogtreecommitdiff
path: root/common/vector.cpp
diff options
context:
space:
mode:
authorleo2006-03-02 18:29:08 +0000
committerleo2006-03-02 18:29:08 +0000
commitb18cb77e8c9acf8c1d5ee351477e8adb4ffbae9f (patch)
treea8dc6089f661b0d099bfc095c64a7e423e413ca2 /common/vector.cpp
parentb7c522acf840dd211e54141f1dbda5b5c268971e (diff)
Removed a few old math functions.
git-svn-id: http://svn.leocad.org/trunk@504 c7d43263-9d01-0410-8a33-9dba5d9f93d6
Diffstat (limited to 'common/vector.cpp')
-rw-r--r--common/vector.cpp84
1 files changed, 7 insertions, 77 deletions
diff --git a/common/vector.cpp b/common/vector.cpp
index e0cfd4f..0495163 100644
--- a/common/vector.cpp
+++ b/common/vector.cpp
@@ -1,7 +1,3 @@
-// Vector.cpp: implementation of the Vector class.
-//
-//////////////////////////////////////////////////////////////////////
-
#include <math.h>
#include "vector.h"
#include "defines.h"
@@ -9,52 +5,37 @@
//////////////////////////////////////////////////////////////////////
// Construction/Destruction
-Vector::Vector ()
+Vector::Vector()
{
m_fPoint[0] = 0;
m_fPoint[1] = 0;
m_fPoint[2] = 0;
}
-Vector::Vector (float x, float y, float z)
+Vector::Vector(float x, float y, float z)
{
m_fPoint[0] = x;
m_fPoint[1] = y;
m_fPoint[2] = z;
}
-Vector::Vector (const float *point)
+Vector::Vector(const float *point)
{
m_fPoint[0] = point[0];
m_fPoint[1] = point[1];
m_fPoint[2] = point[2];
}
-Vector::Vector (const float *p1, const float *p2)
+Vector::Vector(const float *p1, const float *p2)
{
m_fPoint[0] = p2[0] - p1[0];
m_fPoint[1] = p2[1] - p1[1];
m_fPoint[2] = p2[2] - p1[2];
}
-Vector::~Vector ()
-{
-}
-
//////////////////////////////////////////////////////////////////////
// Operations
-bool Vector::operator==(Vector& vec)
-{
- if (m_fPoint[0] != vec.m_fPoint[0])
- return false;
- if (m_fPoint[1] != vec.m_fPoint[1])
- return false;
- if (m_fPoint[2] != vec.m_fPoint[2])
- return false;
- return true;
-}
-
Vector& Vector::operator*=(float scalar)
{
m_fPoint[0] *= scalar;
@@ -79,22 +60,6 @@ Vector& Vector::operator-=(Vector& sub)
return *this;
}
-Vector& Vector::operator=(Vector& source)
-{
- m_fPoint[0] = source.m_fPoint[0];
- m_fPoint[1] = source.m_fPoint[1];
- m_fPoint[2] = source.m_fPoint[2];
- return *this;
-}
-
-Vector& Vector::operator=(const float *point)
-{
- m_fPoint[0] = point[0];
- m_fPoint[1] = point[1];
- m_fPoint[2] = point[2];
- return *this;
-}
-
float Vector::Length()
{
return (float)sqrt(m_fPoint[0]*m_fPoint[0] + m_fPoint[1]*m_fPoint[1] + m_fPoint[2]*m_fPoint[2]);
@@ -102,33 +67,12 @@ float Vector::Length()
void Vector::Normalize()
{
- float inv = 1.0f/(float)sqrt(m_fPoint[0]*m_fPoint[0] + m_fPoint[1]*m_fPoint[1] + m_fPoint[2]*m_fPoint[2]);
+ float inv = 1.0f / Length();
m_fPoint[0] *= inv;
m_fPoint[1] *= inv;
m_fPoint[2] *= inv;
}
-void Vector::Add (const float *point)
-{
- m_fPoint[0] += point[0];
- m_fPoint[1] += point[1];
- m_fPoint[2] += point[2];
-}
-
-void Vector::Add (float x, float y, float z)
-{
- m_fPoint[0] += x;
- m_fPoint[1] += y;
- m_fPoint[2] += z;
-}
-
-void Vector::Scale(float scale)
-{
- m_fPoint[0] *= scale;
- m_fPoint[1] *= scale;
- m_fPoint[2] *= scale;
-}
-
Vector& Vector::Cross(Vector& v1, Vector& v2)
{
m_fPoint[0] = v1.m_fPoint[1]*v2.m_fPoint[2] - v1.m_fPoint[2]*v2.m_fPoint[1];
@@ -145,7 +89,7 @@ float Vector::Angle(Vector& vec)
m1 = sqrt(m_fPoint[0]*m_fPoint[0]+m_fPoint[1]*m_fPoint[1]+m_fPoint[2]*m_fPoint[2]);
m2 = sqrt(vec.m_fPoint[0]*vec.m_fPoint[0]+vec.m_fPoint[1]*vec.m_fPoint[1]+vec.m_fPoint[2]*vec.m_fPoint[2]);
- return (float) (RTOD * acos (d / (m1*m2)));
+ return (float)(RTOD * acos(d / (m1*m2)));
}
float Vector::Dot(Vector& vec)
@@ -153,23 +97,9 @@ float Vector::Dot(Vector& vec)
return m_fPoint[0]*vec.m_fPoint[0]+m_fPoint[1]*vec.m_fPoint[1]+m_fPoint[2]*vec.m_fPoint[2];
}
-void Vector::ToFloat (float *point)
+void Vector::ToFloat(float *point)
{
point[0] = m_fPoint[0];
point[1] = m_fPoint[1];
point[2] = m_fPoint[2];
}
-
-void Vector::FromFloat (const float *point)
-{
- m_fPoint[0] = point[0];
- m_fPoint[1] = point[1];
- m_fPoint[2] = point[2];
-}
-
-void Vector::FromFloat(float x, float y, float z)
-{
- m_fPoint[0] = x;
- m_fPoint[1] = y;
- m_fPoint[2] = z;
-}