src/geometry.cpp

changeset 115
ed884a2fb009
parent 71
198d25fe4e21
child 122
b54b350dff5d
equal deleted inserted replaced
114:4e03b0e2a29f 115:ed884a2fb009
101 } 101 }
102 } 102 }
103 103
104 std::optional<glm::vec2> geom::rayLineSegmentIntersection(const Ray<2>& ray, const LineSegment2D& line) 104 std::optional<glm::vec2> geom::rayLineSegmentIntersection(const Ray<2>& ray, const LineSegment2D& line)
105 { 105 {
106 std::optional<glm::vec2> result = lineLineIntersection(rayToLine(ray), lineFromPoints(line.points[0], line.points[1])); 106 std::optional<glm::vec2> result = lineLineIntersection(
107 rayToLine(ray),
108 lineFromPoints(line.points[0], line.points[1]));
107 if (result.has_value()) 109 if (result.has_value())
108 { 110 {
109 const float d1 = glm::dot(*result - ray.anchor, ray.direction); 111 const float d1 = glm::dot(*result - ray.anchor, ray.direction);
110 if (d1 < 0) 112 if (d1 < 0)
111 { 113 {

mercurial