diff options
| author | raysan5 <[email protected]> | 2017-01-05 19:33:05 +0100 |
|---|---|---|
| committer | raysan5 <[email protected]> | 2017-01-05 19:33:05 +0100 |
| commit | 658c2806690ace34a0dae6b6ed12d0ea52d2d6e4 (patch) | |
| tree | e726d130c81f429e70d1c36b91aef5454658efb9 /src/raymath.h | |
| parent | 0369bb4c8cfe8988634a09d56c307b73be281452 (diff) | |
| download | raylib-658c2806690ace34a0dae6b6ed12d0ea52d2d6e4.tar.gz raylib-658c2806690ace34a0dae6b6ed12d0ea52d2d6e4.zip | |
Lattest PR review
Function names, code formatting...
Diffstat (limited to 'src/raymath.h')
| -rw-r--r-- | src/raymath.h | 25 |
1 files changed, 13 insertions, 12 deletions
diff --git a/src/raymath.h b/src/raymath.h index 5871e350..c073b72d 100644 --- a/src/raymath.h +++ b/src/raymath.h @@ -130,7 +130,7 @@ RMDEF void VectorTransform(Vector3 *v, Matrix mat); // Transforms a Ve RMDEF Vector3 VectorZero(void); // Return a Vector3 init to zero RMDEF Vector3 VectorMin(Vector3 vec1, Vector3 vec2); // Return min value for each pair of components RMDEF Vector3 VectorMax(Vector3 vec1, Vector3 vec2); // Return max value for each pair of components -RMDEF Vector3 Barycentric(Vector3 p, Vector3 a, Vector3 b, Vector3 c); // Barycentric coords for p in triangle abc +RMDEF Vector3 Barycenter(Vector3 p, Vector3 a, Vector3 b, Vector3 c); // Barycenter coords for p in triangle abc //------------------------------------------------------------------------------------ // Functions Declaration to work with Matrix @@ -383,26 +383,27 @@ RMDEF Vector3 VectorMax(Vector3 vec1, Vector3 vec2) return result; } -// Compute barycentric coordinates (u, v, w) for -// point p with respect to triangle (a, b, c) -// Assumes P is on the plane of the triangle -RMDEF Vector3 Barycentric(Vector3 p, Vector3 a, Vector3 b, Vector3 c) +// Compute barycenter coordinates (u, v, w) for point p with respect to triangle (a, b, c) +// NOTE: Assumes P is on the plane of the triangle +RMDEF Vector3 Barycenter(Vector3 p, Vector3 a, Vector3 b, Vector3 c) { - //Vector v0 = b - a, v1 = c - a, v2 = p - a; - Vector3 v0 = VectorSubtract( b, a ); - Vector3 v1 = VectorSubtract( c, a ); - Vector3 v2 = VectorSubtract( p, a ); + + Vector3 v0 = VectorSubtract(b, a); + Vector3 v1 = VectorSubtract(c, a); + Vector3 v2 = VectorSubtract(p, a); float d00 = VectorDotProduct(v0, v0); float d01 = VectorDotProduct(v0, v1); float d11 = VectorDotProduct(v1, v1); float d20 = VectorDotProduct(v2, v0); float d21 = VectorDotProduct(v2, v1); - float denom = d00 * d11 - d01 * d01; + + float denom = d00*d11 - d01*d01; Vector3 result; - result.y = (d11 * d20 - d01 * d21) / denom; - result.z = (d00 * d21 - d01 * d20) / denom; + + result.y = (d11*d20 - d01*d21)/denom; + result.z = (d00*d21 - d01*d20)/denom; result.x = 1.0f - (result.z + result.y); return result; |
