96void Point::normalize() {
99 if(std::isnan(
len))
return;
107 for (
unsigned i = 0 ; i < 2 ; ++i ) {
108 if (
_pt[i] == inf ) {
111 }
else if (
_pt[i] == -inf ) {
145 for (
int i = 0 ; i < 2 ; i++ ) {
155 Coord const a(fabs(p[0]));
156 Coord const b(fabs(p[1]));
157 return ( a < b || std::isnan(b)
166 return ( p[0] == 0 &&
179 return std::atan2(p[
Y], p[
X]);
187 return std::atan2(
cross(a,b),
dot(a,b));
220 }
else if (b[
Y] == 0.0) {
221 ret = b[
X] < 0.0 ? -b : b;
231 for(
int i = 0; i < 2; i++) {
232 _pt[i] =
x * m[i] +
y * m[i + 2] + m[i + 4];
252 double k = round(angle * (
double)n / (2.0*M_PI));
253 return A + dir *
Rotate(k * 2.0 * M_PI / (
double)n) *
L2(diff);
Cartesian point / 2D vector and related operations.
Various trigoniometric helper functions.
3x3 matrix representing an affine transformation.
Wrapper for angular values.
Coord radians0() const
Get the angle as positive radians.
Two-dimensional point that doubles as a vector.
bool is_zero(Point const &p)
True if the point has both coordinates zero.
Coord L1(Point const &p)
Compute the first norm (Manhattan distance) of p.
Point abs(Point const &b)
Return the "absolute value" of the point's vector.
bool are_near(Point const &a, Point const &b, double eps=EPSILON)
Test whether two points are no further apart than some threshold.
bool is_unit_vector(Point const &p, Coord eps)
True if the point has a length near 1.
Coord angle_between(Point const &a, Point const &b)
Compute the angle between a and b relative to the origin.
void normalize()
Normalize the vector representing the point.
constexpr Coord y() const noexcept
constexpr Coord x() const noexcept
Coord atan2(Point const &p)
Return the angle between the point and the +X axis.
Point unit_vector(Point const &a)
Create a normalized version of a point.
Coord LInfty(Point const &p)
Compute the infinity norm (maximum norm) of p.
Point constrain_angle(Point const &A, Point const &B, unsigned int n, Point const &dir)
Snap the angle B - A - dir to multiples of .
Rotation around the origin.
Integral and real coordinate types and some basic utilities.
double Coord
Floating point type used to store coordinates.
Various utility functions.
void sincos(double angle, double &sin_, double &cos_)
Simultaneously compute a sine and a cosine of the same angle.
std::ostream & operator<<(std::ostream &os, const Bezier &b)
SBasisN< n > sqrt(SBasisN< n > const &a, int k)
double angle_between(Line const &l1, Line const &l2)
std::string format_coord_nice(Coord x)
Piecewise< SBasis > cross(Piecewise< D2< SBasis > > const &a, Piecewise< D2< SBasis > > const &b)
SBasis L2(D2< SBasis > const &a, unsigned k)
T dot(D2< T > const &a, D2< T > const &b)
bool are_near(Affine const &a1, Affine const &a2, Coord eps=EPSILON)