mirror of
https://github.com/Mauler125/r5sdk.git
synced 2025-02-09 19:15:03 +01:00
Recast: add helper function to calculate slope angle from 2 points
This commit is contained in:
parent
24e09b4b6c
commit
1a393e6330
@ -386,6 +386,12 @@ inline bool rdOverlapBounds(const float* amin, const float* amax,
|
||||
return overlap;
|
||||
}
|
||||
|
||||
/// Derives the slope angle from 2 points.
|
||||
/// @param[in] v1 The start vector. [(x, y, z)]
|
||||
/// @param[in] v2 The end vector. [(x, y, z)]
|
||||
/// @return The slope angle between the 2 points.
|
||||
float rdCalcSlopeAngle(const float* v1, const float* v2);
|
||||
|
||||
/// Derives the closest point on a triangle from the specified reference point.
|
||||
/// @param[out] closest The closest point on the triangle.
|
||||
/// @param[in] p The reference point from which to test. [(x, y, z)]
|
||||
|
@ -21,6 +21,19 @@
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
float rdCalcSlopeAngle(const float* v1, const float* v2)
|
||||
{
|
||||
const float deltaX = v2[0] - v1[0];
|
||||
const float deltaY = v2[1] - v1[1];
|
||||
const float deltaZ = v2[2] - v1[2];
|
||||
|
||||
const float horizontalDistance = rdMathSqrtf((deltaX*deltaX)+(deltaY*deltaY));
|
||||
const float slopeAngleRadians = rdMathAtan2f(deltaZ, horizontalDistance);
|
||||
const float slopeAngleDegrees = slopeAngleRadians*(180.0f/RD_PI);
|
||||
|
||||
return slopeAngleDegrees;
|
||||
}
|
||||
|
||||
void rdClosestPtPointTriangle(float* closest, const float* p,
|
||||
const float* a, const float* b, const float* c)
|
||||
{
|
||||
|
Loading…
x
Reference in New Issue
Block a user