UE SC -kismetmathlibrary
project function:
KISMET_MATH_INLINE FVector UKismetMathLibrary::ProjectVectorOnToVector(FVector V, FVector Target) { if (Target.SizeSquared() > SMALL_NUMBER) { return V.ProjectOnTo(Target); } else { ReportError_ProjectVectorOnToVector(); return FVector::ZeroVector; } }
其中 ProjectOnTo:
FORCEINLINE FVector FVector::ProjectOnTo(const FVector& A) const { return (A * ((*this | A) / (A | A))); }
| 运算符号 override: (Vector.h里面)
FORCEINLINE float operator|(const FVector& V) const; /** * Calculate the dot product of two vectors. * * @param A The first vector. * @param B The second vector. * @return The dot product. */ FORCEINLINE float FVector::operator|(const FVector& V) const { return X*V.X + Y*V.Y + Z*V.Z; }