I’m trying to do a Circular Line trace where the Start point is aligned to the Normal Vector and End points form a circle that is “around” the normal vector going through a ring. I’ve managed to get the trace to output the normal vector in green correctly, which means I have the mid point of the circle. How would I go about tracing a circle around any normal vector?
So basically using the Normal Vector as the new origin, using a transform could achieve this easier?
Someone on the Unreal Slackers discord solved this giving me the following code:
FVector const Origin = RV_Hit.ImpactPoint;
FVector const Normal = RV_Hit.ImpactNormal;
float const Radius = 40.0f;
FMatrix const Matrix = FRotationMatrix::MakeFromX(Normal);
FVector const Right = Matrix.GetUnitAxis(EAxis::Y);
int32 const PointCount = 16;
float const AngleDelta = 360.0f / PointCount;
for (int32 i = 0; i < PointCount; ++i)
{
float const RotationAngle = i * AngleDelta;
FVector const Vector = Right.RotateAngleAxis(RotationAngle, Normal);
FVector const Point = Origin + Vector * Radius;
DrawDebugSphere(GetWorld(), Point, 10.0f, 8, FColor::Red, true, 0.01f);
}