42#include <gtest/gtest.h>
65 double epsilon = 1e-9)
70 static bool near_equal(
double a,
double b,
double epsilon = 1e-9)
72 return std::abs(a - b) < epsilon;
165 Segment horizontal(origin, p1);
198 Segment horizontal(origin, p1);
301 double angle =
s1.counterclockwise_angle_with(
s2);
372 Point a(1000000, 1000000);
373 Point b(1000010, 1000010);
381 ::testing::InitGoogleTest(&
argc,
argv);
Represents a point with rectangular coordinates in a 2D plane.
const Geom_Number & get_x() const noexcept
Gets the x-coordinate value.
const Geom_Number & get_y() const noexcept
Gets the y-coordinate value.
Represents a line segment between two points.
Point mid_point() const
Returns the midpoint of this segment.
double slope() const
Returns the slope of the segment.
double counterclockwise_angle() const
Computes the counter-clockwise angle of this segment with respect to the x-axis.
bool is_left_of(const Point &p) const
Checks if this segment is to the left of a given point.
Point project(const Point &p) const
Orthogonal projection of a point onto this segment's infinite line, clamped to the segment's endpoint...
Segment reversed() const
Returns a new segment with the endpoints swapped.
bool is_right_of(const Point &p) const
Checks if this segment is to the right of a given point.
Geom_Number distance_to(const Point &p) const
Calculates the Euclidean distance from a point to this segment.
bool is_colinear_with(const Point &p) const
Checks if a point is collinear with this segment.
const Point & get_tgt_point() const noexcept
Gets the target point of the segment.
const Point & get_src_point() const noexcept
Gets the source point of the segment.
Geom_Number length() const
Returns the Euclidean length of the segment.
static bool near_equal(double a, double b, double epsilon=1e-9)
static bool near_equal(const Geom_Number &a, const Geom_Number &b, double epsilon=1e-9)
bool vertical
If true, use vertical layout (default).
Main namespace for Aleph-w library functions.
Divide_Conquer_DP_Result< Cost > divide_and_conquer_partition_dp(const size_t groups, const size_t n, Transition_Cost_Fn transition_cost, const Cost inf=dp_optimization_detail::default_inf< Cost >())
Optimize partition DP using divide-and-conquer optimization.
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 point and geometric utilities.
TEST_F(SegmentTest, DefaultConstructor)