42inline static float sign(
double number)
46 }
else if (number < 0.0) {
79 return sign(outgoing_tangent[d] + incoming_tangent[d]);
90 auto const ZERO_TIME =
PathTime(0, 0);
98 .glance_direction_at_min = 0.0,
99 .glance_direction_at_max = 0.0,
100 .min_time = ZERO_TIME,
101 .max_time = ZERO_TIME
107 auto min_time = ZERO_TIME, max_time = ZERO_TIME;
108 unsigned curve_counter = 0;
111 auto const update_minmax = [&](
Point const &new_point,
Coord t) {
112 if (new_point[d] < min_point[d]) {
113 min_point = new_point;
114 min_time =
PathTime(curve_counter, t);
115 }
else if (new_point[d] > max_point[d]) {
116 max_point = new_point;
117 max_time =
PathTime(curve_counter, t);
124 update_minmax(
curve.initialPoint(), 0.0);
137 .max_point = max_point,
140 .min_time = min_time,
Path - a sequence of contiguous curves.
Cartesian point / 2D vector and related operations.
std::vector< Coord > roots() const
virtual Point unitTangentAt(Coord t, unsigned n=3) const
Compute a vector tangent to the curve.
Sequence of contiguous curves, aka spline.
bool closed() const
Check whether the path is closed.
PathExtrema extrema(Dim2 d) const
Find the extrema of the specified coordinate.
std::shared_ptr< PathData > _data
bool empty() const
Check whether path is empty.
Point finalUnitTangent() const
Get the unit tangent vector at the end of the path, or the zero vector if undefined.
Point initialPoint() const
Get the first point in the path.
Point initialUnitTangent() const
Get the unit tangent vector at the start of the path, or the zero vector if undefined.
size_type size() const
Natural size of the path.
Curve const & curveAt(Coord t, Coord *rest=NULL) const
Get the curve at the specified time value.
Two-dimensional point that doubles as a vector.
Dim2
2D axis enumeration (X or Y).
constexpr Dim2 other_dimension(Dim2 d)
Get the other (perpendicular) dimension.
double Coord
Floating point type used to store coordinates.
Various utility functions.
static float sign(double number)
Returns +1 for positive numbers, -1 for negative numbers, and 0 otherwise.
static float find_direction_of_travel(Path const &path, PathTime const &time, Dim2 d)
Determine whether the d-coordinate increases or decreases at the given path time.
Bezier derivative(Bezier const &a)
Stores information about the extremum points on a path, with respect to one of the coordinate axes.
Point min_point
Points with the minimum and maximum value of a coordinate.
Generalized time value in the path.
size_type curve_index
Index of the curve in the path.
Coord t
Time value in the curve.