light: add MakePlane function
This commit is contained in:
parent
6c529fb0c3
commit
d31d3621bc
|
|
@ -558,6 +558,11 @@ GLM_TriangleArea(const qvec3f &v0, const qvec3f &v1, const qvec3f &v2)
|
|||
return 0.5f * qv::length(qv::cross(v2 - v0, v1 - v0));
|
||||
}
|
||||
|
||||
qvec4f GLM_MakePlane(const qvec3f &normal, const qvec3f &point)
|
||||
{
|
||||
return qvec4f(normal[0], normal[1], normal[2], qv::dot(point, normal));
|
||||
}
|
||||
|
||||
float GLM_DistAbovePlane(const qvec4f &plane, const qvec3f &point)
|
||||
{
|
||||
return qv::dot(qvec3f(plane), point) - plane[3];
|
||||
|
|
|
|||
|
|
@ -322,6 +322,7 @@ bool GLM_EdgePlanes_PointInside(const std::vector<qvec4f> &edgeplanes, const qve
|
|||
float GLM_EdgePlanes_PointInsideDist(const std::vector<qvec4f> &edgeplanes, const qvec3f &point);
|
||||
qvec3f GLM_TriangleCentroid(const qvec3f &v0, const qvec3f &v1, const qvec3f &v2);
|
||||
float GLM_TriangleArea(const qvec3f &v0, const qvec3f &v1, const qvec3f &v2);
|
||||
qvec4f GLM_MakePlane(const qvec3f &normal, const qvec3f &point);
|
||||
float GLM_DistAbovePlane(const qvec4f &plane, const qvec3f &point);
|
||||
qvec3f GLM_ProjectPointOntoPlane(const qvec4f &plane, const qvec3f &point);
|
||||
float GLM_PolyArea(const std::vector<qvec3f> &points);
|
||||
|
|
|
|||
|
|
@ -282,6 +282,11 @@ TEST(mathlib, RotateFromUpToSurfaceNormal) {
|
|||
}
|
||||
}
|
||||
|
||||
TEST(mathlib, MakePlane) {
|
||||
EXPECT_EQ(qvec4f(0, 0, 1, 10), GLM_MakePlane(qvec3f(0,0,1), qvec3f(0,0,10)));
|
||||
EXPECT_EQ(qvec4f(0, 0, 1, 10), GLM_MakePlane(qvec3f(0,0,1), qvec3f(100,100,10)));
|
||||
}
|
||||
|
||||
TEST(mathlib, DistAbovePlane) {
|
||||
qvec4f plane(0, 0, 1, 10);
|
||||
qvec3f point(100, 100, 100);
|
||||
|
|
|
|||
Loading…
Reference in New Issue