| 100 | namespace geode |
| 101 | { |
| 102 | IntersectionResult< Point3D > line_plane_intersection( |
| 103 | const InfiniteLine3D& line, const Plane& plane ) |
| 104 | { |
| 105 | const auto dot_directions = line.direction().dot( plane.normal() ); |
| 106 | if( std::fabs( dot_directions ) <= GLOBAL_EPSILON ) |
| 107 | { |
| 108 | // line is parallel to the plane |
| 109 | return { INTERSECTION_TYPE::parallel }; |
| 110 | } |
| 111 | const auto signed_distance = |
| 112 | plane.normal().dot( Vector3D{ line.origin() } ) |
| 113 | + plane.plane_constant(); |
| 114 | auto result = |
| 115 | line.origin() - line.direction() * signed_distance / dot_directions; |
| 116 | CorrectnessInfo< Point3D >::Correctness first_correctness{ |
| 117 | point_line_distance( result, line ) <= GLOBAL_EPSILON, |
| 118 | point_line_projection( result, line ) |
| 119 | }; |
| 120 | const auto plane_distance = point_plane_distance( result, plane ); |
| 121 | CorrectnessInfo< Point3D >::Correctness second_correctness{ |
| 122 | std::get< 0 >( plane_distance ) <= GLOBAL_EPSILON, |
| 123 | std::get< 1 >( plane_distance ) |
| 124 | }; |
| 125 | return { std::move( result ), |
| 126 | { first_correctness, second_correctness } }; |
| 127 | } |
| 128 | |
| 129 | template < index_t dimension > |
| 130 | IntersectionResult< absl::InlinedVector< Point< dimension >, 2 > > |
no test coverage detected