2021-04-22 17:31:14 -04:00
|
|
|
// Copyright Epic Games, Inc. All Rights Reserved.
|
|
|
|
|
|
2024-06-28 11:21:20 -04:00
|
|
|
#include "Math/Point.h"
|
2021-04-22 17:31:14 -04:00
|
|
|
|
2024-06-28 11:21:20 -04:00
|
|
|
#include "Utils/Util.h"
|
|
|
|
|
#include "Math/MatrixH.h"
|
2021-04-22 17:31:14 -04:00
|
|
|
|
2022-08-29 11:47:01 -04:00
|
|
|
namespace UE::CADKernel
|
2021-11-18 14:37:34 -05:00
|
|
|
{
|
2021-04-22 17:31:14 -04:00
|
|
|
|
2021-11-18 14:37:34 -05:00
|
|
|
const FPoint FPoint::ZeroPoint(0.,0.,0.);
|
|
|
|
|
const FPoint FPoint::UnitPoint(1., 1., 1.);
|
|
|
|
|
const FPoint FPoint::FarawayPoint(HUGE_VALUE, HUGE_VALUE, HUGE_VALUE);
|
|
|
|
|
const int32 FPoint::Dimension = 3;
|
2021-06-08 17:45:06 -04:00
|
|
|
|
2021-11-18 14:37:34 -05:00
|
|
|
const FFPoint FFPoint::ZeroPoint(0.f, 0.f, 0.f);
|
|
|
|
|
const FFPoint FFPoint::FarawayPoint(HUGE_VALUE, HUGE_VALUE, HUGE_VALUE);
|
|
|
|
|
const int32 FFPoint::Dimension = 3;
|
2021-06-08 17:45:06 -04:00
|
|
|
|
2021-11-18 14:37:34 -05:00
|
|
|
const FPoint2D FPoint2D::ZeroPoint(0., 0.);
|
|
|
|
|
const FPoint2D FPoint2D::FarawayPoint(HUGE_VALUE, HUGE_VALUE);
|
|
|
|
|
const int32 FPoint2D::Dimension = 2;
|
2021-06-08 17:45:06 -04:00
|
|
|
|
2021-11-18 14:37:34 -05:00
|
|
|
const FPointH FPointH::ZeroPoint(0., 0., 0., 1.);
|
|
|
|
|
const FPointH FPointH::FarawayPoint(HUGE_VALUE, HUGE_VALUE, HUGE_VALUE, 1.);
|
|
|
|
|
const int32 FPointH::Dimension = 4;
|
|
|
|
|
|
|
|
|
|
double FPoint::SignedAngle(const FPoint & Other, const FPoint & Normal) const
|
2021-04-22 17:31:14 -04:00
|
|
|
{
|
|
|
|
|
FPoint Vector1 = *this;
|
|
|
|
|
FPoint Vector2 = Other;
|
|
|
|
|
FPoint Vector3 = Normal;
|
|
|
|
|
|
|
|
|
|
Vector1.Normalize();
|
|
|
|
|
Vector2.Normalize();
|
|
|
|
|
Vector3.Normalize();
|
|
|
|
|
|
|
|
|
|
double ScalarProduct = Vector1 * Vector2;
|
|
|
|
|
|
2022-06-23 17:50:34 -04:00
|
|
|
if (ScalarProduct >= 1 - DOUBLE_SMALL_NUMBER)
|
2021-04-22 17:31:14 -04:00
|
|
|
{
|
|
|
|
|
return 0.;
|
|
|
|
|
}
|
|
|
|
|
|
2022-06-23 17:50:34 -04:00
|
|
|
if (ScalarProduct <= -1 + DOUBLE_SMALL_NUMBER)
|
2021-04-22 17:31:14 -04:00
|
|
|
{
|
2022-06-23 17:50:34 -04:00
|
|
|
return DOUBLE_PI;
|
2021-04-22 17:31:14 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return MixedTripleProduct(Vector1, Vector2, Vector3) > 0 ? acos(ScalarProduct) : -acos(ScalarProduct);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2021-11-18 14:37:34 -05:00
|
|
|
}
|