KLingo Project Documentation 1.0.0
Unreal Engine 5.6 C++ Project Documentation
로딩중...
검색중...
일치하는것 없음
FMathHelper.h
이 파일의 문서화 페이지로 가기
1
5#pragma once
6
8{
9
24 static FVector SolveV0ForProjectile(
25 const FVector& Start,
26 const FVector& End,
27 float Time,
28 float GravityZ = -980.f)
29 {
30 if (Time <= KINDA_SMALL_NUMBER)
31 return FVector::ZeroVector;
32
33 const FVector g(0, 0, GravityZ);
34 return (End - Start - 0.5f * g * Time * Time) / Time;
35 }
36
52 static FVector InterpArcSin(
53 const FVector& Start,
54 const FVector& End,
55 float Height,
56 float Alpha)
57 {
58 FVector Base = FMath::Lerp(Start, End, Alpha);
59 float OffsetZ = FMath::Sin(Alpha * PI) * Height; // (0→Height→0)
60 return Base + FVector(0, 0, OffsetZ);
61 }
62
85 UWorld* World,
86 const FVector& Start,
87 const FVector& V0,
88 float GravityZ = -980.f,
89 int32 NumSegments = 20,
90 float StepTime = 0.1f,
91 float LifeTime = 2.0f,
92 FColor Color = FColor::Red)
93 {
94 if (!World) return;
95
96 const FVector g(0, 0, GravityZ);
97
98 FVector PrevPos = Start;
99 for (int32 i = 1; i <= NumSegments; ++i)
100 {
101 float t = StepTime * i;
102 FVector CurrPos = SolveV0ForProjectile(PrevPos, CurrPos, t, GravityZ);
103 // Start + V0 * t + 0.5f * g * t * t;
104
105 DrawDebugLine(World, PrevPos, CurrPos, Color, false, LifeTime, 0, 1.5f);
106 PrevPos = CurrPos;
107 }
108 }
109
130 static void DrawParabolaDebug(
131 UWorld* World,
132 const FVector& Start,
133 const FVector& End,
134 const float Height,
135 const int32 NumSegments = 20,
136 const float LifeTime = 2.0f,
137 const FColor Color = FColor::Green)
138 {
139 if (!World) return;
140
141 FVector PrevPos = Start;
142 for (int32 i = 1; i <= NumSegments; ++i)
143 {
144 const float Alpha = (float)i / (float)NumSegments;
145 FVector CurrPos = InterpArcSin(Start, End, Height, Alpha);
146
147 DrawDebugLine(World, PrevPos, CurrPos, Color, false, LifeTime, 0, 1.5f);
148 PrevPos = CurrPos;
149 }
150 }
151};
static void DrawParabolaDebug(UWorld *World, const FVector &Start, const FVector &End, const float Height, const int32 NumSegments=20, const float LifeTime=2.0f, const FColor Color=FColor::Green)
두 점(Start → End)을 잇는 곡선을 디버그 라인으로 그립니다.
static void DrawProjectileArcDebug(UWorld *World, const FVector &Start, const FVector &V0, float GravityZ=-980.f, int32 NumSegments=20, float StepTime=0.1f, float LifeTime=2.0f, FColor Color=FColor::Red)
초기 속도 V0를 이용해 물리 기반 포물선 궤적을 디버그 라인으로 그립니다.
Definition FMathHelper.h:84
static FVector InterpArcSin(const FVector &Start, const FVector &End, float Height, float Alpha)
선형 보간 경로에 사인 함수를 더해 아치 형태의 곡선을 생성합니다.
Definition FMathHelper.h:52
static FVector SolveV0ForProjectile(const FVector &Start, const FVector &End, float Time, float GravityZ=-980.f)
주어진 시간 안에 목표 지점에 도달하기 위한 초기 속도를 계산합니다.
Definition FMathHelper.h:24