point.h revision a4030d5ca449e7e384bc699cd249ee704faaeab0
#ifndef SEEN_Geom_POINT_H
#define SEEN_Geom_POINT_H
/**
* \file
* \brief Defines a Cartesian 2D Point class.
*/
#include <iostream>
enum Dim2 { X=0, Y=1 };
/// Cartesian 2D point.
/// The default constructor creates an Point(0,0) DO NOT RELY ON THIS, BEST NOT TO USE THIS CONSTRUCTOR
inline Point()
}
for (unsigned i = 0; i < 2; ++i)
}
for (unsigned i = 0; i < 2; ++i)
return *this;
}
}
/** Return a point like this point but rotated -90 degrees.
(If the y axis grows downwards and the x axis grows to the
right, then this is 90 degrees counter-clockwise.)
**/
}
/** Return a point like this point but rotated +90 degrees.
(If the y axis grows downwards and the x axis grows to the
right, then this is 90 degrees clockwise.)
**/
}
/**
\brief A function to lower the precision of the point
\param places The number of decimal places that should be in
the final number.
*/
return;
}
void normalize();
inline bool isFinite() const {
for ( unsigned i = 0 ; i < 2 ; ++i ) {
}
return true;
}
}
}
for ( unsigned i = 0 ; i < 2 ; ++i ) {
}
return *this;
}
for ( unsigned i = 0 ; i < 2 ; ++i ) {
}
return *this;
}
}
}
//TODO: s == 0?
}
for ( unsigned i = 0 ; i < 2 ; ++i ) _pt[i] *= s;
return *this;
}
//TODO: s == 0?
for ( unsigned i = 0 ; i < 2 ; ++i ) _pt[i] /= s;
return *this;
}
}
};
/** A function to print out the Point. It just prints out the coords
on the given output stream */
return out_file;
}
/** This is a rotation (sort of). */
a[1] * b[0] + a[0] * b[1]);
return ret;
}
//IMPL: boost::EqualityComparableConcept
return (a[X] == b[X]) && (a[Y] == b[Y]);
}
return (a[X] != b[X]) || (a[Y] != b[Y]);
}
/** This is a lexicographical ordering for points. It is remarkably useful for sweepline algorithms*/
return ( ( a[Y] < b[Y] ) ||
(( a[Y] == b[Y] ) && ( a[X] < b[X] )));
}
/** Compute the L2, or euclidean, norm of \a p. */
/** Compute the square of L2 norm of \a p. Warning: this can overflow where L2 won't.*/
bool is_unit_vector(Point const &p);
/** compute the angle turning from a to b (signed). */
//IMPL: NearConcept
}
inline
{
}
/** Returns p * Geom::rotate_degrees(90), but more efficient.
*
* Angle direction in Inkscape code: If you use the traditional mathematics convention that y
* increases upwards, then positive angles are anticlockwise as per the mathematics convention. If
* you take the common non-mathematical convention that y increases downwards, then positive angles
* are clockwise, as is common outside of mathematics.
*
* There is no rot_neg90 function: use -rot90(p) instead.
*/
/** Given two points and a parameter t \in [0, 1], return a point
* proportionally from a to b by t. Akin to 1 degree bezier.*/
/** compute the dot product (inner product) between the vectors a and b. */
/** Defined as dot(a, b.cw()). */
/** compute the square of the distance between points a and b. */
/** Constrains the angle (with respect to dir) of the line
* joining A and B to a multiple of pi/n.
*/
Point constrain_angle(Point const &A, Point const &B, unsigned int n = 4, Geom::Point const &dir = Geom::Point(1,0));
} /* namespace Geom */
#endif /* !SEEN_Geom_POINT_H */
/*
Local Variables:
mode:c++
c-file-style:"stroustrup"
c-file-offsets:((innamespace . 0)(inline-open . 0)(case-label . +))
indent-tabs-mode:nil
fill-column:99
End:
*/
// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:fileencoding=utf-8:textwidth=99 :