Project::OSiRiON - Git repositories
Project::OSiRiON
News . About . Screenshots . Downloads . Forum . Wiki . Tracker . Git
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'src/math/vector3f.h')
-rw-r--r--src/math/vector3f.h86
1 files changed, 50 insertions, 36 deletions
diff --git a/src/math/vector3f.h b/src/math/vector3f.h
index 99a665f..09e6e84 100644
--- a/src/math/vector3f.h
+++ b/src/math/vector3f.h
@@ -23,81 +23,81 @@ class Vector3f
public:
/// default constructor, assigns (0,0,0)
Vector3f();
-
+
/// copy constructor
/** Create a new Vector3f that is a copy from an other
* @param other the vector to copy values from
*/
Vector3f(const Vector3f &other);
-
+
/// create a Vector3f with given coordinates
/** @param x the x-coordinate of the location
* @param y the y-coordinate of the location
* @param z the z-coordinate of the location
*/
Vector3f(const float x, const float y, const float z);
-
+
/// destructor
~Vector3f();
-
+
/* -- Assignment operators -- */
/// assign (0, 0, 0)
void clear();
-
+
/// assignment
void assign(const float x, const float y, const float z);
-
+
/// assignment
void assign(const Vector3f & other);
-
+
/// assignment operator
Vector3f& operator=(const Vector3f &other);
-
+
/// scalar multiplication assignment
/** @param scalar multiplication factor
*/
Vector3f& operator*=(const float scalar);
-
+
/// scalar division assignment
/** @param scalar divider
*/
Vector3f& operator/=(const float scalar);
-
+
/// vector sum assignment
Vector3f& operator+=(const Vector3f &other);
-
+
/// vector difference assignment
Vector3f& operator-=(const Vector3f &other);
-
+
/* -- Mathematical operators -- */
-
+
/// scalar multiplication
inline Vector3f operator*(const float scalar) const {
Vector3f v(coord[0] * scalar, coord[1] * scalar, coord[2] * scalar);
return v;
}
-
+
/// scalar division
Vector3f operator/(const float scalar) const {
Vector3f v(coord[0] / scalar, coord[1] / scalar, coord[2] / scalar);
return v;
}
-
+
/// vector sum
inline Vector3f operator+(const Vector3f &other) const {
Vector3f v(coord[0] + other.coord[0], coord[1] + other.coord[1], coord[2] + other.coord[2]);
return v;
}
-
+
/// vector difference
inline Vector3f operator-(const Vector3f &other) const {
Vector3f v(coord[0] - other.coord[0], coord[1] - other.coord[1], coord[2] - other.coord[2]);
return v;
}
-
+
/// comparison operator
bool operator==(const Vector3f &other) const;
-
+
/// assign a value to an element of this vector
/*! range is not checked
* @param index the index of the element to assign to ( 0 <= index < 3 )
@@ -105,7 +105,7 @@ public:
inline float& operator[](const size_t index) {
return coord[index];
}
-
+
/// returns the value of an element of this vector
/*! range is not checked
* @param index the index of the element to return ( 0 <= index < 3 )
@@ -113,61 +113,75 @@ public:
inline float operator[](const size_t index) const {
return coord[index];
}
-
+
/// x coordinate
- inline float x() const { return coord[0]; }
+ inline float x() const {
+ return coord[0];
+ }
/// y coordinate
- inline float y() const { return coord[1]; }
+ inline float y() const {
+ return coord[1];
+ }
/// z coordinate
- inline float z() const { return coord[2]; }
+ inline float z() const {
+ return coord[2];
+ }
- /// mutable reference to the x coordinate
- inline float & get_x() { return coord[0]; }
+ /// mutable reference to the x coordinate
+ inline float & get_x() {
+ return coord[0];
+ }
/// mutable reference to the y coordinate
- inline float & get_y() { return coord[1]; }
+ inline float & get_y() {
+ return coord[1];
+ }
/// mutable reference to the z coordinate
- inline float & get_z() { return coord[2]; }
+ inline float & get_z() {
+ return coord[2];
+ }
/// a pointer to the internal data
- inline float *ptr() const { return (float *) coord; }
+ inline float *ptr() const {
+ return (float *) coord;
+ }
/// cartesian length
float length() const;
-
+
/// cartesian length squared
float lengthsquared() const;
-
+
/// divide this Vector by its length
/// @see normalized()
/// vector must not be (0, 0, 0)
void normalize();
-
+
/* static functions */
-
+
/// Returns the unity vector on the X-axis
static inline Vector3f Xaxis() {
return Vector3f(1.0f, 0.0f, 0.0f);
}
-
+
/// Returns the unity vector on the Y-axis
static inline Vector3f Yaxis() {
return Vector3f(0.0f, 1.0f, 0.0f);
}
-
+
/// Returns the unity vector on the Z-axis
static inline Vector3f Zaxis() {
return Vector3f(0.0f, 0.0f, 1.0f);
}
-
+
/// cartesian lenght
static inline float length(const Vector3f & vector) {
return vector.length();
}
-
+
/// Return a vector divided by it's length
/// @see normalize()
/// WARNING: vector must not be (0, 0, 0)