MCPcopy Create free account
hub / github.com/Geode-solutions/OpenGeode / line_plane_intersection

Function line_plane_intersection

src/geode/geometry/intersection.cpp:102–127  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

100namespace 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 > >

Callers 1

Calls 7

point_line_distanceFunction · 0.85
point_line_projectionFunction · 0.85
point_plane_distanceFunction · 0.85
dotMethod · 0.80
plane_constantMethod · 0.80
directionMethod · 0.45
normalMethod · 0.45

Tested by

no test coverage detected