Fix geom::intersection
This commit is contained in:
parent
98d26f76cf
commit
ebe3570b96
1 changed files with 5 additions and 5 deletions
|
|
@ -16,8 +16,8 @@
|
||||||
namespace psemek::geom
|
namespace psemek::geom
|
||||||
{
|
{
|
||||||
|
|
||||||
template <typename Point, typename = std::enable_if_t<Point::dimension == 2>>
|
template <typename T>
|
||||||
bool intersect(segment<Point> const & s0, segment<Point> const & s1)
|
bool intersect(segment<point<T, 2>> const & s0, segment<point<T, 2>> const & s1)
|
||||||
{
|
{
|
||||||
auto const o00 = orientation(s0[0], s0[1], s1[0]);
|
auto const o00 = orientation(s0[0], s0[1], s1[0]);
|
||||||
auto const o01 = orientation(s0[0], s0[1], s1[1]);
|
auto const o01 = orientation(s0[0], s0[1], s1[1]);
|
||||||
|
|
@ -28,8 +28,8 @@ namespace psemek::geom
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO: robust implementation
|
// TODO: robust implementation
|
||||||
template <typename Point, typename = std::enable_if_t<Point::dimension == 2>>
|
template <typename T>
|
||||||
std::variant<util::empty, Point, segment<Point>> intersection(segment<Point> s0, segment<Point> s1)
|
std::variant<util::empty, point<T, 2>, segment<point<T, 2>>> intersection(segment<point<T, 2>> const & s0, segment<point<T, 2>> const & s1)
|
||||||
{
|
{
|
||||||
auto const a0 = -det(s1[0] - s0[0], s1[1] - s1[0]);
|
auto const a0 = -det(s1[0] - s0[0], s1[1] - s1[0]);
|
||||||
auto const a1 = det(s0[1] - s0[0], s1[0] - s0[0]);
|
auto const a1 = det(s0[1] - s0[0], s1[0] - s0[0]);
|
||||||
|
|
@ -77,7 +77,7 @@ namespace psemek::geom
|
||||||
|
|
||||||
if (r0 == r1)
|
if (r0 == r1)
|
||||||
{
|
{
|
||||||
Point p;
|
point<T, 2> p;
|
||||||
p[k] = r0;
|
p[k] = r0;
|
||||||
p[1 - k] = s0_is_first ? s0[1][1 - k] : s1[1][1 - k];
|
p[1 - k] = s0_is_first ? s0[1][1 - k] : s1[1][1 - k];
|
||||||
return p;
|
return p;
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue