// Copyright Epic Games, Inc. All Rights Reserved. #include "FitCapsule3.h" #include "ThirdParty/GTEngine/Mathematics/GteCapsule.h" #include "ThirdParty/GTEngine/Mathematics/GteContCapsule3.h" using namespace UE::Geometry; using namespace UE::Math; template bool TFitCapsule3::Solve(int32 NumPoints, TFunctionRef(int32)> GetPointFunc) { using ComputeType = double; TArray> PointList; PointList.SetNum(NumPoints); for (int32 k = 0; k < NumPoints; ++k) { TVector Point = GetPointFunc(k); PointList[k] = { {(ComputeType)Point.X, (ComputeType)Point.Y, (ComputeType)Point.Z} }; } gte::Capsule3 FitCapsule; bResultValid = GetContainer(NumPoints, &PointList[0], FitCapsule); if (bResultValid) { gte::Vector3 Center, Direction; ComputeType Extent; FitCapsule.segment.GetCenteredForm(Center, Direction, Extent); Capsule.Segment = TSegment3( TVector((RealType)Center[0], (RealType)Center[1], (RealType)Center[2]), TVector((RealType)Direction[0], (RealType)Direction[1], (RealType)Direction[2]), (RealType)Extent); Capsule.Radius = (RealType)FitCapsule.radius; } return bResultValid; } namespace UE { namespace Geometry { template class GEOMETRYALGORITHMS_API TFitCapsule3; template class GEOMETRYALGORITHMS_API TFitCapsule3; } // end namespace UE::Geometry } // end namespace UE