@@ -320,8 +320,17 @@ float Float3::Angle(const Float3& from, const Float3& 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);
|
||||
return dot > 0.0f ? 0.0f : 180.0f;
|
||||
return Math::Acos(dot) * RadiansToDegrees;
|
||||
}
|
||||
|
||||
template<>
|
||||
float Float3::SignedAngle(const Float3& from, const Float3& to, const Float3& axis)
|
||||
{
|
||||
const float angle = Angle(from, to);
|
||||
const Float3 cross = Cross(from, to);
|
||||
const float sign = Math::Sign(axis.X * cross.X + axis.Y * cross.Y + axis.Z * cross.Z);
|
||||
return angle * sign;
|
||||
}
|
||||
|
||||
template<>
|
||||
@@ -648,8 +657,17 @@ 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);
|
||||
return dot > 0.0 ? 0.0 : 180.0;
|
||||
return Math::Acos(dot) * RadiansToDegrees;
|
||||
}
|
||||
|
||||
template<>
|
||||
double Double3::SignedAngle(const Double3& from, const Double3& to, const Double3& axis)
|
||||
{
|
||||
const double angle = Angle(from, to);
|
||||
const Double3 cross = Cross(from, to);
|
||||
const double sign = Math::Sign(axis.X * cross.X + axis.Y * cross.Y + axis.Z * cross.Z);
|
||||
return angle * sign;
|
||||
}
|
||||
|
||||
template<>
|
||||
@@ -881,6 +899,12 @@ int32 Int3::Angle(const Int3& from, const Int3& to)
|
||||
return 0;
|
||||
}
|
||||
|
||||
template<>
|
||||
int32 Int3::SignedAngle(const Int3& from, const Int3& to, const Int3& axis)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
template<>
|
||||
Int3 Int3::SnapToGrid(const Int3& pos, const Int3& gridSize)
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user