Removed Vector2.tofactor

This commit is contained in:
Pascal Serrarens 2024-03-14 12:06:07 +01:00
parent 159bdaec8e
commit dc601a1746
3 changed files with 201 additions and 209 deletions

View File

@ -140,7 +140,3 @@ Vector2 Vector2::Lerp(Vector2 from, Vector2 to, float f) {
Vector2 v = from + (to - from) * f;
return v;
}
float Vector2::ToFactor(Vector2 a, Vector2 b) {
return (1 - Vector2::Dot(a, b)) / 2;
}

View File

@ -6,12 +6,12 @@
#define VECTOR2_H
extern "C" {
/// <summary>
/// 2-dimensional Vector representation
/// </summary>
/// This is a C-style implementation
/// This uses the right-handed coordinate system.
typedef struct Vec2 {
/// <summary>
/// 2-dimensional Vector representation
/// </summary>
/// This is a C-style implementation
/// This uses the right-handed coordinate system.
typedef struct Vec2 {
/// <summary>
/// The right axis of the vector
/// </summary>
@ -21,7 +21,7 @@ extern "C" {
/// </summary>
float y;
} Vec2;
} Vec2;
}
/// <summary>
@ -59,7 +59,7 @@ public:
/// <summary>
/// A vector with values (1, 0)
/// </summary>
///
///
const static Vector2 right;
/// <summary>
/// A vector3 with values (-1, 0)
@ -87,7 +87,7 @@ public:
/// </summary>
/// <param name="vector">The vector for which you need the length</param>
/// <returns>The length of the given vector</returns>
static float Magnitude(const Vector2& vector);
static float Magnitude(const Vector2 &vector);
/// <summary>
/// The length of this vector
/// </summary>
@ -100,7 +100,7 @@ public:
/// length</param> <returns>The squatred length</returns> The squared length
/// is computationally simpler than the real length. Think of Pythagoras A^2 +
/// B^2 = C^2. This leaves out the calculation of the squared root of C.
static float SqrMagnitude(const Vector2& vector);
static float SqrMagnitude(const Vector2 &vector);
/// <summary>
/// The squared length of this vector
/// </summary>
@ -132,14 +132,14 @@ public:
/// </summary>
/// <param name="vector">The vector to subtract from this vector</param>
/// <returns>The result of the subtraction</returns>
Vector2 operator-(const Vector2& vector) const;
Vector2 operator-(const Vector2 &vector) const;
/// <summary>
/// Add another vector to this vector
/// </summary>
/// <param name="vector2">The vector to add</param>
/// <returns>The result of adding the vector</returns>
Vector2 operator+(const Vector2& vector2) const;
Vector2 operator+(const Vector2 &vector2) const;
/// <summary>
/// Scale a vector using another vector
@ -149,7 +149,7 @@ public:
/// <returns>The scaled vector</returns>
/// Each component of the vector v1 will be multiplied with the
/// component from the scaling vector v2.
static Vector2 Scale(const Vector2& vector1, const Vector2& vector2);
static Vector2 Scale(const Vector2 &vector1, const Vector2 &vector2);
/// <summary>
/// Scale a vector uniformly up
/// </summary>
@ -163,7 +163,7 @@ public:
/// <param name="factor">The scaling factor</param>
/// <returns>The scaled vector</returns>
/// Each componet of the vector will be divided by the same factor.
Vector2 operator/(const float& factor);
Vector2 operator/(const float &factor);
/// <summary>
/// The dot product of two vectors
@ -171,7 +171,7 @@ public:
/// <param name="vector1">The first vector</param>
/// <param name="vector2">The second vector</param>
/// <returns>The dot product of the two vectors</returns>
static float Dot(const Vector2& vector1, const Vector2& vector2);
static float Dot(const Vector2 &vector1, const Vector2 &vector2);
/// <summary>
/// Check is this vector is equal to the given vector
@ -180,7 +180,7 @@ public:
/// <returns>True if it is identical to the given vector</returns>
/// Note this uses float comparison to check equality which
/// may have strange effects. Equality on float should be avoided.
bool operator==(const Vector2& vector);
bool operator==(const Vector2 &vector);
/// <summary>
/// The distance between two vectors
@ -188,7 +188,7 @@ public:
/// <param name="vector1">The first vector</param>
/// <param name="vector2">The second vectors</param>
/// <returns>The distance between the two vectors</returns>
static float Distance(const Vector2& vector1, const Vector2& vector2);
static float Distance(const Vector2 &vector1, const Vector2 &vector2);
/// <summary>
/// Calculate the angle between two vectors
@ -229,8 +229,6 @@ public:
/// matches the *to* vector Value -1 is *from* vector minus the difference
/// between *from* and *to* etc.
static Vector2 Lerp(Vector2 from, Vector2 to, float f);
static float ToFactor(Vector2 a, Vector2 b);
};
#endif

View File

@ -460,6 +460,4 @@ TEST(Vector2, Lerp) {
EXPECT_FLOAT_EQ(Vector2::Distance(r, Vector2(-2.0, -1.0f)), 0);
}
TEST(Vector2, DISABLED_ToFactor) {}
#endif