37#include <gtest/gtest.h>
214 EXPECT_TRUE(
l1.is_parallel_to(
l2));
215 EXPECT_TRUE(
l2.is_parallel_to(
l1));
216 EXPECT_FALSE(
l1.is_parallel_to(
l3));
225 EXPECT_TRUE(
l1.is_perpendicular_to(
l2));
226 EXPECT_TRUE(
l2.is_perpendicular_to(
l1));
227 EXPECT_FALSE(
l1.is_perpendicular_to(
l3));
242 auto [x,
y] =
l1.intersection(
l2);
253 auto [x,
y] =
l1.intersection(
l2);
265 auto [x,
y] =
l1.intersection(
l2);
288 EXPECT_THROW((
void)
l1.intersection(
l2), std::domain_error);
296 EXPECT_THROW((
void)
l1.intersection(
l2), std::domain_error);
313 EXPECT_TRUE(
l1.is_perpendicular_to(perp));
366 double expected = 1.0 / std::sqrt(2.0);
413 EXPECT_TRUE(
l1 ==
l2);
414 EXPECT_FALSE(
l1 !=
l2);
430 EXPECT_FALSE(
l1 ==
l2);
431 EXPECT_TRUE(
l1 !=
l2);
439 EXPECT_FALSE(
l1 ==
l2);
440 EXPECT_TRUE(
l1 !=
l2);
454 EXPECT_TRUE(str.find(
"y = ") != std::string::npos);
455 EXPECT_TRUE(str.find(
"3") != std::string::npos);
456 EXPECT_TRUE(str.find(
"2") != std::string::npos);
462 std::ostringstream ss;
465 EXPECT_TRUE(ss.str().find(
"1.5") != std::string::npos || ss.str().find(
"3/2") != std::string::npos);
466 EXPECT_TRUE(ss.str().find(
"2.5") != std::string::npos || ss.str().find(
"5/2") != std::string::npos);
549TEST(LineTypeTraits, NoDiscardAttribute)
557 EXPECT_TRUE((std::is_same<
decltype(line.
to_string()), std::string>
::value));
573 auto [x1,
y1] =
l1.intersection(
l2);
574 auto [x2, y2] =
l1.intersection(
l3);
575 auto [x3, y3] =
l2.intersection(
l3);
594 auto [x,
y] =
l1.intersection(
l2);
625 ::testing::InitGoogleTest(&argc, argv);
626 return RUN_ALL_TESTS();
size_t size_t int32_t value
Minimal std::expected-style result type for C++20.
__gmp_expr< T, __gmp_unary_expr< __gmp_expr< T, U >, __gmp_y1_function > > y1(const __gmp_expr< T, U > &expr)
2D infinite line representation using slope-intercept form.
TEST_F(LineConstructorTest, DefaultConstructor)
Main namespace for Aleph-w library functions.
double geom_number_to_double(const Geom_Number &n)
Converts a Geom_Number to its double precision representation.
mpq_class Geom_Number
Numeric type used by the geometry module.
2D infinite line in slope-intercept form.
std::pair< Geom_Number, Geom_Number > intersection(const LineEq &l, const Geom_Number &epsilon=LINE_EPSILON) const
Compute the intersection point with another line.
LineEq perpendicular_through(const Geom_Number &px, const Geom_Number &py) const
Compute perpendicular line through a point.
bool is_horizontal(const Geom_Number &epsilon=LINE_EPSILON) const noexcept
Check if the line is horizontal (slope = 0).
const Geom_Number & y_intercept() const noexcept
Get the y-intercept of the line.
Geom_Number x_at(const Geom_Number &y) const
Compute x-coordinate for a given y-coordinate.
std::string to_string() const
Convert line to a string representation.
Geom_Number distance_to(const Geom_Number &px, const Geom_Number &py) const noexcept
Compute distance from a point to this line.
const Geom_Number & slope() const noexcept
Get the slope of the line.
Geom_Number y0
Y-intercept (where line crosses y-axis)
Geom_Number m
Slope (dy/dx)
bool contains_point(const Geom_Number &px, const Geom_Number &py, const Geom_Number &epsilon=LINE_EPSILON) const noexcept
Check if a point lies on this line.