Minor adjustments
This commit is contained in:
@@ -50,46 +50,46 @@ public:
|
||||
};
|
||||
|
||||
public:
|
||||
// Vector with all components equal zero (0, 0, 0)
|
||||
// Vector with all components equal zero (0, 0, 0).
|
||||
static const Vector3 Zero;
|
||||
|
||||
// Vector with all components equal one (1, 1, 1)
|
||||
// Vector with all components equal one (1, 1, 1).
|
||||
static const Vector3 One;
|
||||
|
||||
// Vector with all components equal half (0.5, 0.5, 0.5)
|
||||
// Vector with all components equal half (0.5, 0.5, 0.5).
|
||||
static const Vector3 Half;
|
||||
|
||||
// The X unit vector (1, 0, 0)
|
||||
// The X unit vector (1, 0, 0).
|
||||
static const Vector3 UnitX;
|
||||
|
||||
// The Y unit vector (0, 1, 0)
|
||||
// The Y unit vector (0, 1, 0).
|
||||
static const Vector3 UnitY;
|
||||
|
||||
// The Z unit vector (0, 0, 1)
|
||||
// The Z unit vector (0, 0, 1).
|
||||
static const Vector3 UnitZ;
|
||||
|
||||
// A unit vector designating up (0, 1, 0)
|
||||
// A unit vector designating up (0, 1, 0).
|
||||
static const Vector3 Up;
|
||||
|
||||
// A unit vector designating down (0, -1, 0)
|
||||
// A unit vector designating down (0, -1, 0).
|
||||
static const Vector3 Down;
|
||||
|
||||
// A unit vector designating a (-1, 0, 0)
|
||||
// A unit vector designating a (-1, 0, 0).
|
||||
static const Vector3 Left;
|
||||
|
||||
// A unit vector designating b (1, 0, 0)
|
||||
// A unit vector designating b (1, 0, 0).
|
||||
static const Vector3 Right;
|
||||
|
||||
// A unit vector designating forward in a a-handed coordinate system (0, 0, 1)
|
||||
// A unit vector designating forward in a a-handed coordinate system (0, 0, 1).
|
||||
static const Vector3 Forward;
|
||||
|
||||
// A unit vector designating backward in a a-handed coordinate system (0, 0, -1)
|
||||
// A unit vector designating backward in a a-handed coordinate system (0, 0, -1).
|
||||
static const Vector3 Backward;
|
||||
|
||||
// A minimum Vector3
|
||||
// A minimum Vector3.
|
||||
static const Vector3 Minimum;
|
||||
|
||||
// A maximum Vector3
|
||||
// A maximum Vector3.
|
||||
static const Vector3 Maximum;
|
||||
|
||||
public:
|
||||
@@ -131,110 +131,75 @@ public:
|
||||
{
|
||||
}
|
||||
|
||||
// Init
|
||||
// @param xy Vector2 with X and Y components values
|
||||
// @param z Z component value
|
||||
|
||||
explicit Vector3(const Vector2& xy, float z);
|
||||
|
||||
// Init
|
||||
// @param xy Vector3 value
|
||||
explicit Vector3(const Vector2& xy);
|
||||
|
||||
// Init
|
||||
// @param xy Int22 with X and Y components values
|
||||
// @param z Z component value
|
||||
explicit Vector3(const Int2& xy, float z);
|
||||
|
||||
// Init
|
||||
// @param xyz Int3 value
|
||||
explicit Vector3(const Int3& xyz);
|
||||
|
||||
// Init
|
||||
// @param xyzw Int4 value
|
||||
explicit Vector3(const Int4& xyzw);
|
||||
|
||||
// Init
|
||||
// @param xyz Vector4 value
|
||||
explicit Vector3(const Vector4& xyz);
|
||||
|
||||
// Init
|
||||
// @param xy Double2 with X and Y components values
|
||||
// @param z Z component value
|
||||
explicit Vector3(const Double2& xy, float z);
|
||||
|
||||
// Init
|
||||
// @param xyz Double3 value
|
||||
Vector3(const Double3& xyz);
|
||||
|
||||
// Init
|
||||
// @param xyzw Double4 value
|
||||
explicit Vector3(const Double4& xyzw);
|
||||
|
||||
// Init
|
||||
// @param color Color value
|
||||
explicit Vector3(const Color& color);
|
||||
|
||||
public:
|
||||
String ToString() const;
|
||||
|
||||
public:
|
||||
// Gets a value indicting whether this instance is normalized
|
||||
// Gets a value indicting whether this instance is normalized.
|
||||
bool IsNormalized() const
|
||||
{
|
||||
return Math::IsOne(X * X + Y * Y + Z * Z);
|
||||
}
|
||||
|
||||
// Gets a value indicting whether this vector is zero
|
||||
// Gets a value indicting whether this vector is zero.
|
||||
bool IsZero() const
|
||||
{
|
||||
return Math::IsZero(X) && Math::IsZero(Y) && Math::IsZero(Z);
|
||||
}
|
||||
|
||||
// Gets a value indicting whether any vector component is zero
|
||||
// Gets a value indicting whether any vector component is zero.
|
||||
bool IsAnyZero() const
|
||||
{
|
||||
return Math::IsZero(X) || Math::IsZero(Y) || Math::IsZero(Z);
|
||||
}
|
||||
|
||||
// Gets a value indicting whether this vector is one
|
||||
// Gets a value indicting whether this vector is one.
|
||||
bool IsOne() const
|
||||
{
|
||||
return Math::IsOne(X) && Math::IsOne(Y) && Math::IsOne(Z);
|
||||
}
|
||||
|
||||
// Calculates length of the vector
|
||||
// @returns Length of the vector
|
||||
// Calculates the length of the vector.
|
||||
float Length() const
|
||||
{
|
||||
return Math::Sqrt(X * X + Y * Y + Z * Z);
|
||||
}
|
||||
|
||||
// Calculates the squared length of the vector
|
||||
// @returns The squared length of the vector
|
||||
// Calculates the squared length of the vector.
|
||||
float LengthSquared() const
|
||||
{
|
||||
return X * X + Y * Y + Z * Z;
|
||||
}
|
||||
|
||||
// Calculates inverted length of the vector (1 / Length())
|
||||
// Calculates inverted length of the vector (1 / length).
|
||||
float InvLength() const
|
||||
{
|
||||
return 1.0f / Length();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Calculates a vector with values being absolute values of that vector
|
||||
/// Calculates a vector with values being absolute values of that vector.
|
||||
/// </summary>
|
||||
/// <returns>Absolute vector</returns>
|
||||
Vector3 GetAbsolute() const
|
||||
{
|
||||
return Vector3(Math::Abs(X), Math::Abs(Y), Math::Abs(Z));
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Calculates a vector with values being opposite to values of that vector
|
||||
/// Calculates a vector with values being opposite to values of that vector.
|
||||
/// </summary>
|
||||
/// <returns>Negative vector</returns>
|
||||
Vector3 GetNegative() const
|
||||
{
|
||||
return Vector3(-X, -Y, -Z);
|
||||
@@ -243,7 +208,6 @@ public:
|
||||
/// <summary>
|
||||
/// Calculates a normalized vector that has length equal to 1.
|
||||
/// </summary>
|
||||
/// <returns>The normalized vector.</returns>
|
||||
Vector3 GetNormalized() const
|
||||
{
|
||||
const float rcp = 1.0f / Length();
|
||||
@@ -253,43 +217,38 @@ public:
|
||||
/// <summary>
|
||||
/// Returns average arithmetic of all the components
|
||||
/// </summary>
|
||||
/// <returns>Average arithmetic of all the components</returns>
|
||||
float AverageArithmetic() const
|
||||
{
|
||||
return (X + Y + Z) * 0.333333334f;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets sum of all vector components values
|
||||
/// Gets sum of all vector components values.
|
||||
/// </summary>
|
||||
/// <returns>Sum of X,Y and Z</returns>
|
||||
float SumValues() const
|
||||
{
|
||||
return X + Y + Z;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Returns minimum value of all the components
|
||||
/// Returns minimum value of all the components.
|
||||
/// </summary>
|
||||
/// <returns>Minimum value</returns>
|
||||
float MinValue() const
|
||||
{
|
||||
return Math::Min(X, Y, Z);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Returns maximum value of all the components
|
||||
/// Returns maximum value of all the components.
|
||||
/// </summary>
|
||||
/// <returns>Maximum value</returns>
|
||||
float MaxValue() const
|
||||
{
|
||||
return Math::Max(X, Y, Z);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Returns true if vector has one or more components is not a number (NaN)
|
||||
/// Returns true if vector has one or more components is not a number (NaN).
|
||||
/// </summary>
|
||||
/// <returns>True if one or more components is not a number (NaN)</returns>
|
||||
bool IsNaN() const
|
||||
{
|
||||
return isnan(X) || isnan(Y) || isnan(Z);
|
||||
@@ -305,9 +264,8 @@ public:
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Returns true if vector has one or more components equal to +/- infinity or NaN
|
||||
/// Returns true if vector has one or more components equal to +/- infinity or NaN.
|
||||
/// </summary>
|
||||
/// <returns>True if one or more components equal to +/- infinity or NaN</returns>
|
||||
bool IsNanOrInfinity() const
|
||||
{
|
||||
return IsInfinity() || IsNaN();
|
||||
@@ -315,7 +273,7 @@ public:
|
||||
|
||||
public:
|
||||
/// <summary>
|
||||
/// Performs vector normalization (scales vector up to unit length)
|
||||
/// Performs vector normalization (scales vector up to unit length).
|
||||
/// </summary>
|
||||
void Normalize()
|
||||
{
|
||||
@@ -330,7 +288,7 @@ public:
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Performs fast vector normalization (scales vector up to unit length)
|
||||
/// Performs fast vector normalization (scales vector up to unit length).
|
||||
/// </summary>
|
||||
void NormalizeFast()
|
||||
{
|
||||
@@ -341,7 +299,7 @@ public:
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Sets all vector components to the absolute values
|
||||
/// Sets all vector components to the absolute values.
|
||||
/// </summary>
|
||||
void Absolute()
|
||||
{
|
||||
@@ -351,7 +309,7 @@ public:
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Negates all components of that vector
|
||||
/// Negates all components of that vector.
|
||||
/// </summary>
|
||||
void Negate()
|
||||
{
|
||||
@@ -361,12 +319,11 @@ public:
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// When this vector contains Euler angles (degrees), ensure that angles are between +/-180
|
||||
/// When this vector contains Euler angles (degrees), ensure that angles are between +/-180.
|
||||
/// </summary>
|
||||
void UnwindEuler();
|
||||
|
||||
public:
|
||||
// Arithmetic operators with Vector3
|
||||
Vector3 operator+(const Vector3& b) const
|
||||
{
|
||||
return Vector3(X + b.X, Y + b.Y, Z + b.Z);
|
||||
@@ -401,8 +358,7 @@ public:
|
||||
{
|
||||
return Dot(*this, b);
|
||||
}
|
||||
|
||||
// op= operators with Vector3
|
||||
|
||||
Vector3& operator+=(const Vector3& b)
|
||||
{
|
||||
X += b.X;
|
||||
@@ -434,8 +390,7 @@ public:
|
||||
Z /= b.Z;
|
||||
return *this;
|
||||
}
|
||||
|
||||
// Arithmetic operators with float
|
||||
|
||||
Vector3 operator+(float b) const
|
||||
{
|
||||
return Vector3(X + b, Y + b, Z + b);
|
||||
@@ -455,8 +410,7 @@ public:
|
||||
{
|
||||
return Vector3(X / b, Y / b, Z / b);
|
||||
}
|
||||
|
||||
// op= operators with float
|
||||
|
||||
Vector3& operator+=(float b)
|
||||
{
|
||||
*this = Add(*this, b);
|
||||
@@ -480,8 +434,7 @@ public:
|
||||
*this = Divide(*this, b);
|
||||
return *this;
|
||||
}
|
||||
|
||||
// Comparison operators
|
||||
|
||||
bool operator==(const Vector3& b) const
|
||||
{
|
||||
return X == b.X && Y == b.Y && Z == b.Z;
|
||||
@@ -703,10 +656,6 @@ public:
|
||||
// <summary>
|
||||
// Performs a linear interpolation between two vectors.
|
||||
// </summary>
|
||||
// @param start Start vector,
|
||||
// @param end End vector,
|
||||
// @param amount Value between 0 and 1 indicating the weight of @paramref end"/>,
|
||||
// @returns The linear interpolation of the two vectors
|
||||
static Vector3 Lerp(const Vector3& start, const Vector3& end, float amount)
|
||||
{
|
||||
Vector3 result;
|
||||
|
||||
Reference in New Issue
Block a user