src/geometry.cpp

changeset 58
b7841cd31fb7
parent 55
cb81ecb5fb23
child 64
f99d52b1646b
equal deleted inserted replaced
57:5c0005f63319 58:b7841cd31fb7
15 * @brief Computes line-plane intersection 15 * @brief Computes line-plane intersection
16 * @param line 16 * @param line
17 * @param plane 17 * @param plane
18 * @return point of intersection. Does not return a value if the line is in parallel to the plane. 18 * @return point of intersection. Does not return a value if the line is in parallel to the plane.
19 */ 19 */
20 std::optional<glm::vec3> geom::linePlaneIntersection(const geom::Line& line, const geom::Plane& plane) 20 std::optional<glm::vec3> geom::linePlaneIntersection(const geom::Line& line, const geom::Plane& plane, const float epsilon)
21 { 21 {
22 const float denominator = glm::dot(line.direction, plane.normal); 22 const float denominator = glm::dot(line.direction, plane.normal);
23 if (std::abs(denominator) < 1e-8f) 23 if (std::abs(denominator) < epsilon)
24 { 24 {
25 return {}; 25 return {};
26 } 26 }
27 else 27 else
28 { 28 {

mercurial