![]() |
UDocumentation UE5.7 10.02.2026 (Source)
API documentation for Unreal Engine 5.7
|
"Slope" is a fast angle approximation.
This file propose all useful methods to use slope instead of angle.
The method "ComputeSlope(const FVector2d& StartPoint, const FVector2d& EndPoint) is the main method. It compute the slope between the input segment defined by two points and [0, u) axis. The return value is a real in the interval [0, 8] for an angle in the interval [0, 2Pi]
Warning, it's only an approximation... The conversion is not linear but the error is small near the integer value of slope (0, 1, 2, 3, ...8)
To compute an angle value between two segments, the call of acos (and asin for an oriented angle) is necessary while with this approximation, only a division is useful.
This approximation is very good when only comparison of angles is needed and more faster than acos and/or asin i.e. Slope approximation need only a division and few addition and test
[0 - 2Pi] is divide into 8 angular sector i.e. [0, Pi/4] = [0,1], [Pi/4, Pi/2] = [1,2], ...
The value of the slope for an angle in [0, Pi/4] = tan(angle)
Angle (Degree) to Slop 0 = 0 1 ~ 0.0175 2 ~ 0.035 5 ~ 0.0875 10 ~ 0.176
|
constexpr |
ThirdPiSlope i.e. Pi/4 angle (45 deg)
RightSlope i.e. Right angle i.e Pi / 2
ThirdPiSlope i.e. Pi/6 angle (30 deg)
ThirdPiSlope i.e. Pi/3 angle (60 deg)
ThreeQuaterPiSlope i.e. 3Pi/4 angle (135 deg)
|
constexpr |