Moved the various Vector::Angle functions into their respective CPP files.
They didn't seem like prime candidates for inlining.
This commit is contained in:
@@ -1,4 +1,4 @@
|
||||
// Copyright (c) 2012-2021 Wojciech Figat. All rights reserved.
|
||||
// Copyright (c) 2012-2021 Wojciech Figat. All rights reserved.
|
||||
|
||||
#include "Double2.h"
|
||||
#include "Double3.h"
|
||||
@@ -107,3 +107,11 @@ double Double2::TriangleArea(const Double2& v0, const Double2& v1, const Double2
|
||||
{
|
||||
return Math::Abs((v0.X * (v1.Y - v2.Y) + v1.X * (v2.Y - v0.Y) + v2.X * (v0.Y - v1.Y)) / 2.);
|
||||
}
|
||||
|
||||
double Double2::Angle(const Double2& from, const Double2& to)
|
||||
{
|
||||
const double dot = Math::Clamp(Dot(Normalize(from), Normalize(to)), -1.0, 1.0);
|
||||
if (Math::Abs(dot) > (1.0 - ZeroTolerance))
|
||||
return dot > 0.0 ? 0.0 : PI;
|
||||
return Math::Acos(dot);
|
||||
}
|
||||
|
||||
@@ -632,13 +632,8 @@ public:
|
||||
/// <param name="from">The first vector.</param>
|
||||
/// <param name="to">The second vector.</param>
|
||||
/// <returns>The angle (in radians).</returns>
|
||||
static double Angle(const Double2& from, const Double2& to)
|
||||
{
|
||||
const double dot = Math::Clamp(Dot(Normalize(from), Normalize(to)), -1.0, 1.0);
|
||||
if (Math::Abs(dot) > (1.0 - ZeroTolerance))
|
||||
return dot > 0.0 ? 0.0 : PI;
|
||||
return Math::Acos(dot);
|
||||
}
|
||||
static double Angle(const Double2& from, const Double2& to);
|
||||
|
||||
};
|
||||
|
||||
inline Double2 operator+(double a, const Double2& b)
|
||||
|
||||
@@ -390,3 +390,11 @@ double Double3::TriangleArea(const Double3& v0, const Double3& v1, const Double3
|
||||
{
|
||||
return (v2 - v0 ^ v1 - v0).Length() * 0.5;
|
||||
}
|
||||
|
||||
double Double3::Angle(const Double3& from, const Double3& to)
|
||||
{
|
||||
const double dot = Math::Clamp(Dot(Normalize(from), Normalize(to)), -1.0, 1.0);
|
||||
if (Math::Abs(dot) > (1.0 - ZeroTolerance))
|
||||
return dot > 0.0 ? 0.0 : PI;
|
||||
return Math::Acos(dot);
|
||||
}
|
||||
|
||||
@@ -940,13 +940,8 @@ public:
|
||||
/// <param name="from">The first vector.</param>
|
||||
/// <param name="to">The second vector.</param>
|
||||
/// <returns>The angle (in radians).</returns>
|
||||
static double Angle(const Double3& from, const Double3& to)
|
||||
{
|
||||
const double dot = Math::Clamp(Dot(Normalize(from), Normalize(to)), -1.0, 1.0);
|
||||
if (Math::Abs(dot) > (1.0 - ZeroTolerance))
|
||||
return dot > 0.0 ? 0.0 : PI;
|
||||
return Math::Acos(dot);
|
||||
}
|
||||
static double Angle(const Double3& from, const Double3& to);
|
||||
|
||||
};
|
||||
|
||||
inline Double3 operator+(double a, const Double3& b)
|
||||
|
||||
@@ -107,3 +107,11 @@ float Vector2::TriangleArea(const Vector2& v0, const Vector2& v1, const Vector2&
|
||||
{
|
||||
return Math::Abs((v0.X * (v1.Y - v2.Y) + v1.X * (v2.Y - v0.Y) + v2.X * (v0.Y - v1.Y)) / 2);
|
||||
}
|
||||
|
||||
float Vector2::Angle(const Vector2& from, const Vector2& to)
|
||||
{
|
||||
const float dot = Math::Clamp(Dot(Normalize(from), Normalize(to)), -1.0f, 1.0f);
|
||||
if (Math::Abs(dot) > (1.0f - ZeroTolerance))
|
||||
return dot > 0.0f ? 0.0f : PI;
|
||||
return Math::Acos(dot);
|
||||
}
|
||||
|
||||
@@ -621,13 +621,8 @@ public:
|
||||
/// <param name="from">The first vector.</param>
|
||||
/// <param name="to">The second vector.</param>
|
||||
/// <returns>The angle (in radians).</returns>
|
||||
static float Angle(const Vector2& from, const Vector2& to)
|
||||
{
|
||||
const float dot = Math::Clamp(Dot(Normalize(from), Normalize(to)), -1.0f, 1.0f);
|
||||
if (Math::Abs(dot) > (1.0f - ZeroTolerance))
|
||||
return dot > 0.0f ? 0.0f : PI;
|
||||
return Math::Acos(dot);
|
||||
}
|
||||
static float Angle(const Vector2& from, const Vector2& to);
|
||||
|
||||
};
|
||||
|
||||
inline Vector2 operator+(float a, const Vector2& b)
|
||||
|
||||
@@ -383,3 +383,11 @@ float Vector3::TriangleArea(const Vector3& v0, const Vector3& v1, const Vector3&
|
||||
{
|
||||
return (v2 - v0 ^ v1 - v0).Length() * 0.5f;
|
||||
}
|
||||
|
||||
float Vector3::Angle(const Vector3& from, const Vector3& to)
|
||||
{
|
||||
const float dot = Math::Clamp(Dot(Normalize(from), Normalize(to)), -1.0f, 1.0f);
|
||||
if (Math::Abs(dot) > (1.0f - ZeroTolerance))
|
||||
return dot > 0.0f ? 0.0f : PI;
|
||||
return Math::Acos(dot);
|
||||
}
|
||||
|
||||
@@ -935,13 +935,8 @@ public:
|
||||
/// <param name="from">The first vector.</param>
|
||||
/// <param name="to">The second vector.</param>
|
||||
/// <returns>The angle (in radians).</returns>
|
||||
static float Angle(const Vector3& from, const Vector3& to)
|
||||
{
|
||||
const float dot = Math::Clamp(Dot(Normalize(from), Normalize(to)), -1.0f, 1.0f);
|
||||
if (Math::Abs(dot) > (1.0f - ZeroTolerance))
|
||||
return dot > 0.0f ? 0.0f : PI;
|
||||
return Math::Acos(dot);
|
||||
}
|
||||
static float Angle(const Vector3& from, const Vector3& to);
|
||||
|
||||
};
|
||||
|
||||
inline Vector3 operator+(float a, const Vector3& b)
|
||||
|
||||
Reference in New Issue
Block a user