Search code examples
c++unreal-engine5

Dot function in unreal c++


This is the code in Unreal C++

float GetT( float t, float alpha, const FVector& p0, const FVector& p1 )
{
    auto d  = p1 - p0;
    float a = d | d; // Dot product
    float b = FMath::Pow( a, alpha*.5f );
    return (b + t);
}

Does this line means "float a = d | d; // Dot product" dot product of FVector d with itself

https://en.wikipedia.org/wiki/Centripetal_Catmull%E2%80%93Rom_spline


Solution

  • Look for documentation of FVector. Search "operators". Look for |. Find:

    float     
    
    operator|
    
    (
        const FVector& V
    )     
    

    Calculate the dot product between this and another vector.

    Yes. d | d calculates the dot product of the vector with itself.