Skip to content

Commit 0ab8149

Browse files
committed
line constant 2D
1 parent e55e2a8 commit 0ab8149

File tree

2 files changed

+17
-4
lines changed

2 files changed

+17
-4
lines changed

include/geode/geometry/basic_objects/infinite_line.hpp

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,9 @@ namespace geode
5454

5555
[[nodiscard]] const Point< dimension >& origin() const;
5656
[[nodiscard]] const Vector< dimension >& direction() const;
57-
[[nodiscard]] double line_constant() const;
57+
template < index_t T = dimension >
58+
[[nodiscard]] typename std::enable_if< T == 2, double >::type
59+
line_constant() const;
5860

5961
private:
6062
Vector< dimension > direction_;

src/geode/geometry/basic_objects/infinite_line.cpp

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,8 @@
2424
#include <geode/geometry/basic_objects/infinite_line.hpp>
2525

2626
#include <geode/geometry/basic_objects/segment.hpp>
27+
#include <geode/geometry/perpendicular.hpp>
28+
#include <geode/geometry/vector.hpp>
2729

2830
namespace geode
2931
{
@@ -68,12 +70,16 @@ namespace geode
6870
return direction_;
6971
}
7072
template < typename PointType, index_t dimension >
71-
double GenericLine< PointType, dimension >::line_constant() const
73+
template < index_t T >
74+
typename std::enable_if< T == 2, double >::type
75+
GenericLine< PointType, dimension >::line_constant() const
7276
{
7377
double line_constant{ 0.0 };
74-
for( const auto i : LRange{ 2 } )
78+
const auto perpendicular_direction = perpendicular( direction() );
79+
for( const auto i : LRange{ dimension } )
7580
{
76-
line_constant -= origin().value( i ) * direction().value( i );
81+
line_constant -=
82+
origin().value( i ) * perpendicular_direction.value( i );
7783
}
7884
return line_constant;
7985
}
@@ -206,4 +212,9 @@ namespace geode
206212
template class opengeode_geometry_api Ray< 1 >;
207213
template class opengeode_geometry_api Ray< 2 >;
208214
template class opengeode_geometry_api Ray< 3 >;
215+
216+
template opengeode_geometry_api double
217+
GenericLine< Point< 2 >, 2 >::line_constant< 2 >() const;
218+
template opengeode_geometry_api double
219+
GenericLine< RefPoint< 2 >, 2 >::line_constant< 2 >() const;
209220
} // namespace geode

0 commit comments

Comments
 (0)