|
30 | 30 | #include <geode/geometry/basic_objects/segment.hpp> |
31 | 31 | #include <geode/geometry/basic_objects/tetrahedron.hpp> |
32 | 32 | #include <geode/geometry/basic_objects/triangle.hpp> |
| 33 | +#include <geode/geometry/bounding_box.hpp> |
33 | 34 | #include <geode/geometry/distance.hpp> |
34 | 35 | #include <geode/geometry/internal/position_from_sides.hpp> |
35 | 36 | #include <geode/geometry/internal/predicates.hpp> |
@@ -67,6 +68,25 @@ namespace geode |
67 | 68 | internal::side( dot0 ), internal::opposite_side( dot1 ) ); |
68 | 69 | } |
69 | 70 |
|
| 71 | + POSITION point_segment_position_exact( |
| 72 | + const Point1D& point, const Segment1D& segment ) |
| 73 | + { |
| 74 | + const auto& vertices = segment.vertices(); |
| 75 | + if( point == vertices[0] ) |
| 76 | + { |
| 77 | + return POSITION::vertex0; |
| 78 | + } |
| 79 | + if( point == vertices[1] ) |
| 80 | + { |
| 81 | + return POSITION::vertex1; |
| 82 | + } |
| 83 | + if( segment.bounding_box().contains( point ) ) |
| 84 | + { |
| 85 | + return POSITION::inside; |
| 86 | + } |
| 87 | + return POSITION::outside; |
| 88 | + } |
| 89 | + |
70 | 90 | template < index_t dimension > |
71 | 91 | POSITION point_triangle_position_all_zero( |
72 | 92 | const Point< dimension >& point, const Triangle< dimension >& triangle ) |
@@ -305,9 +325,10 @@ namespace geode |
305 | 325 | return GEO::PCK::aligned_3d( point0, point1, point2 ); |
306 | 326 | } |
307 | 327 |
|
| 328 | + template POSITION opengeode_geometry_api point_segment_position( |
| 329 | + const Point1D&, const Segment1D& ); |
308 | 330 | template POSITION opengeode_geometry_api point_segment_position( |
309 | 331 | const Point2D&, const Segment2D& ); |
310 | | - |
311 | 332 | template POSITION opengeode_geometry_api point_segment_position( |
312 | 333 | const Point3D&, const Segment3D& ); |
313 | 334 | } // namespace geode |
0 commit comments