|
|
@@ -40,50 +40,90 @@ public:
|
|
|
|
|
|
real x, y, z;
|
|
|
|
|
|
- Vec3(); //!< Constructor, does nothing for efficiency
|
|
|
- Vec3(real val); //!< Initializes all the components to val
|
|
|
- Vec3(real nx, real ny, real nz); //!< Constructs from three components
|
|
|
- Vec3(const real v[3]); //!< Constructs from array
|
|
|
- Vec3(const Vec3& a); //!< Copy constructor
|
|
|
- ~Vec3(); //!< Destructor
|
|
|
-
|
|
|
- real operator[](uint32_t i) const; //!< Random access by index
|
|
|
- real& operator[](uint32_t i); //!< Random access by index
|
|
|
-
|
|
|
- Vec3 operator+(const Vec3& a) const; //!< Addition
|
|
|
- Vec3& operator+=(const Vec3& a); //!< Addition
|
|
|
- Vec3 operator-(const Vec3& a) const; //!< Subtraction
|
|
|
- Vec3& operator-=(const Vec3& a); //!< Subtraction
|
|
|
- Vec3 operator*(real k) const; //!< Multiplication by scalar
|
|
|
- Vec3& operator*=(real k); //!< Multiplication by scalar
|
|
|
- Vec3 operator/(real k) const; //!< Division by scalar
|
|
|
- Vec3& operator/=(real k); //!< Division by scalar
|
|
|
- real dot(const Vec3& a) const; //!< Dot product
|
|
|
- Vec3 cross(const Vec3& a) const; //!< Cross product
|
|
|
-
|
|
|
- friend Vec3 operator*(real k, const Vec3& a); //!< For simmetry
|
|
|
-
|
|
|
- bool operator==(const Vec3& other) const; //!< Equality operator
|
|
|
- bool operator!=(const Vec3& other) const; //!< Disequality operator
|
|
|
- bool operator<(const Vec3& other) const; //!< Returns whether all the components of this vector are smaller than all of the "other" vector
|
|
|
- bool operator>(const Vec3& other) const; //!< Returns whether all the components of this vector are greater than all of the "other" vector
|
|
|
-
|
|
|
- real length() const; //!< Returns the vector's length
|
|
|
- real squared_length() const; //!< Returns the vector's squared length
|
|
|
- void set_length(real len); //!< Sets the vector's length
|
|
|
- Vec3& normalize(); //!< Normalizes the vector
|
|
|
- Vec3 get_normalized() const; //!< Returns the normalized vector
|
|
|
- Vec3& negate(); //!< Negates the vector (i.e. builds the inverse)
|
|
|
- Vec3 operator-() const; //!< Negates the vector (i.e. builds the inverse)
|
|
|
-
|
|
|
- real get_distance_to(const Vec3& a) const; //!< Returns the distance
|
|
|
- real get_angle_between(const Vec3& a) const; //!< Returns the angle in radians
|
|
|
-
|
|
|
- void zero(); //!< Builds the zero vector
|
|
|
-
|
|
|
- real* to_float_ptr(); //!< Returns the point32_ter to the vector's data
|
|
|
- const real* to_float_ptr() const; //!< Returns the point32_ter to the vector's data
|
|
|
- Vec2 to_vec2() const; //!< Returns a Vec2 with only x and y coordinates
|
|
|
+ /// Does nothing for efficiency.
|
|
|
+ Vec3();
|
|
|
+
|
|
|
+ /// Initializes all the components to val
|
|
|
+ Vec3(real val);
|
|
|
+
|
|
|
+ /// Constructs from three components
|
|
|
+ Vec3(real nx, real ny, real nz);
|
|
|
+
|
|
|
+ /// Constructs from array
|
|
|
+ Vec3(const real v[3]);
|
|
|
+ Vec3(const Vec3& a);
|
|
|
+
|
|
|
+ /// Random access by index
|
|
|
+ real operator[](uint32_t i) const;
|
|
|
+
|
|
|
+ /// Random access by index
|
|
|
+ real& operator[](uint32_t i);
|
|
|
+
|
|
|
+ Vec3 operator+(const Vec3& a) const;
|
|
|
+ Vec3& operator+=(const Vec3& a);
|
|
|
+ Vec3 operator-(const Vec3& a) const;
|
|
|
+ Vec3& operator-=(const Vec3& a);
|
|
|
+ Vec3 operator*(real k) const;
|
|
|
+ Vec3& operator*=(real k);
|
|
|
+ Vec3 operator/(real k) const;
|
|
|
+ Vec3& operator/=(real k);
|
|
|
+
|
|
|
+ /// Dot product
|
|
|
+ real dot(const Vec3& a) const;
|
|
|
+
|
|
|
+ /// Cross product
|
|
|
+ Vec3 cross(const Vec3& a) const;
|
|
|
+
|
|
|
+ /// For simmetry
|
|
|
+ friend Vec3 operator*(real k, const Vec3& a);
|
|
|
+
|
|
|
+ bool operator==(const Vec3& other) const;
|
|
|
+ bool operator!=(const Vec3& other) const;
|
|
|
+
|
|
|
+ /// Returns whether all the components of this vector are smaller than all of the "other" vector
|
|
|
+ bool operator<(const Vec3& other) const;
|
|
|
+
|
|
|
+ /// Returns whether all the components of this vector are greater than all of the "other" vector
|
|
|
+ bool operator>(const Vec3& other) const;
|
|
|
+
|
|
|
+ /// Returns the vector's length
|
|
|
+ real length() const;
|
|
|
+
|
|
|
+ /// Returns the vector's squared length
|
|
|
+ real squared_length() const;
|
|
|
+
|
|
|
+ /// Sets the vector's length
|
|
|
+ void set_length(real len);
|
|
|
+
|
|
|
+ /// Normalizes the vector
|
|
|
+ Vec3& normalize();
|
|
|
+
|
|
|
+ /// Returns the normalized vector
|
|
|
+ Vec3 get_normalized() const;
|
|
|
+
|
|
|
+ /// Negates the vector (i.e. builds the inverse)
|
|
|
+ Vec3& negate();
|
|
|
+
|
|
|
+ /// Negates the vector (i.e. builds the inverse)
|
|
|
+ Vec3 operator-() const;
|
|
|
+
|
|
|
+ /// Returns the distance
|
|
|
+ real get_distance_to(const Vec3& a) const;
|
|
|
+
|
|
|
+ /// Returns the angle in radians
|
|
|
+ real get_angle_between(const Vec3& a) const;
|
|
|
+
|
|
|
+ /// Sets all components to zero
|
|
|
+ void zero();
|
|
|
+
|
|
|
+ /// Returns the pointer to the vector's data
|
|
|
+ real* to_float_ptr();
|
|
|
+
|
|
|
+ /// Returns the pointer to the vector's data
|
|
|
+ const real* to_float_ptr() const;
|
|
|
+
|
|
|
+ /// Returns a Vec2 with only x and y coordinates
|
|
|
+ Vec2 to_vec2() const;
|
|
|
|
|
|
static const Vec3 ZERO;
|
|
|
static const Vec3 ONE;
|
|
|
@@ -117,11 +157,6 @@ inline Vec3::Vec3(const Vec3& a) : x(a.x), y(a.y), z(a.z)
|
|
|
{
|
|
|
}
|
|
|
|
|
|
-//-----------------------------------------------------------------------------
|
|
|
-inline Vec3::~Vec3()
|
|
|
-{
|
|
|
-}
|
|
|
-
|
|
|
//-----------------------------------------------------------------------------
|
|
|
inline real Vec3::operator[](uint32_t i) const
|
|
|
{
|
|
|
@@ -356,7 +391,7 @@ inline Vec2 Vec3::to_vec2() const
|
|
|
}
|
|
|
|
|
|
//-----------------------------------------------------------------------------
|
|
|
-//!< Returns the parallel portion of "v" projected onto "n"
|
|
|
+/// Returns the parallel portion of "v" projected onto "n"
|
|
|
inline Vec3 get_projected_parallel(const Vec3& v, const Vec3& n)
|
|
|
{
|
|
|
real n_len_q;
|
|
|
@@ -367,7 +402,7 @@ inline Vec3 get_projected_parallel(const Vec3& v, const Vec3& n)
|
|
|
}
|
|
|
|
|
|
//-----------------------------------------------------------------------------
|
|
|
-//!< Returns the perpendicular portion of "v" projected onto "n"
|
|
|
+/// Returns the perpendicular portion of "v" projected onto "n"
|
|
|
inline Vec3 get_projected_perpendicular(const Vec3& v, const Vec3& n)
|
|
|
{
|
|
|
return v - get_projected_parallel(v, n);
|