37#include <gtest/gtest.h>
78 LineEq line(2.0, 4.0, 3.0);
90 LineEq line(0.0, 0.0, 2.0, 6.0);
103 LineEq line(0.0, 4.0, 2.0, 0.0);
112 LineEq line(0.0, 5.0, 10.0, 5.0);
199 LineEq horizontal(5.0, 0.0);
273 LineEq diagonal(0.0, 2.0);
274 LineEq horizontal(4.0, 0.0);
329 LineEq horizontal(5.0, 0.0);
366 double expected = 1.0 / std::sqrt(2.0);
420 LineEq l2(3.0 + 1e-12, 2.0 + 1e-12);
454 EXPECT_TRUE(str.find(
"y = ") != std::string::npos);
462 std::ostringstream
ss;
512 LineEq line(5.0, 10.0, 0.0, 0.0);
527 static_assert(line.
y0 == 0.0,
"Default y0 should be 0");
528 static_assert(line.
m == 1.0,
"Default m should be 1");
533 constexpr LineEq line(5.0, 2.0);
534 static_assert(line.
y0 == 5.0,
"y0 should be 5");
535 static_assert(line.
m == 2.0,
"m should be 2");
540 constexpr LineEq line(1.0, 2.0);
541 constexpr double y = line(3.0);
542 static_assert(
y == 7.0,
"y at x=3 should be 7");
588 LineEq l1(0.0, 0.0, 4.0, 8.0);
591 LineEq l2(0.0, 4.0, 4.0, 0.0);
624 ::testing::InitGoogleTest(&
argc,
argv);
__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.
DynList< T > maps(const C &c, Op op)
Classic map operation.
2D infinite line in slope-intercept form.
constexpr bool is_horizontal(double epsilon=LINE_EPSILON) const noexcept
Check if the line is horizontal (slope = 0).
double x_at(double y) const
Compute x-coordinate for a given y-coordinate.
double distance_to(double px, double py) const noexcept
Compute distance from a point to this line.
double y0
Y-intercept (where line crosses y-axis)
constexpr bool is_parallel_to(const LineEq &l, double epsilon=LINE_EPSILON) const noexcept
Check if this line is parallel to another.
LineEq perpendicular_through(double px, double py) const
Compute perpendicular line through a point.
constexpr double y_intercept() const noexcept
Get the y-intercept of the line.
std::string to_string() const
Convert line to string representation.
std::pair< double, double > intersection(const LineEq &l, double epsilon=LINE_EPSILON) const
Compute intersection point with another line.
bool contains_point(double px, double py, double epsilon=LINE_EPSILON) const noexcept
Check if a point lies on this line.
constexpr bool is_perpendicular_to(const LineEq &l, double epsilon=LINE_EPSILON) const noexcept
Check if this line is perpendicular to another.
constexpr double slope() const noexcept
Get the slope of the line.