MCPcopy Create free account
hub / github.com/OneLoneCoder/olcPixelGameEngine / Vec_IntersectPlane

Method Vec_IntersectPlane

extensions/olcPGEX_Graphics3D.h:501–511  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

499 }
500
501 olc::GFX3D::vec3d olc::GFX3D::Math::Vec_IntersectPlane(olc::GFX3D::vec3d &plane_p, olc::GFX3D::vec3d &plane_n, olc::GFX3D::vec3d &lineStart, olc::GFX3D::vec3d &lineEnd, float &t)
502 {
503 plane_n = Vec_Normalise(plane_n);
504 float plane_d = -Vec_DotProduct(plane_n, plane_p);
505 float ad = Vec_DotProduct(lineStart, plane_n);
506 float bd = Vec_DotProduct(lineEnd, plane_n);
507 t = (-plane_d - ad) / (bd - ad);
508 olc::GFX3D::vec3d lineStartToEnd = Vec_Sub(lineEnd, lineStart);
509 olc::GFX3D::vec3d lineToIntersect = Vec_Mul(lineStartToEnd, t);
510 return Vec_Add(lineStart, lineToIntersect);
511 }
512
513
514 int olc::GFX3D::Math::Triangle_ClipAgainstPlane(vec3d plane_p, vec3d plane_n, triangle &in_tri, triangle &out_tri1, triangle &out_tri2)

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected