6
/** Compute the L infinity, or maximum, norm of \a p. */
7
Geom::Coord Geom::LInfty(Point const &p) {
8
Geom::Coord const a(fabs(p[0]));
9
Geom::Coord const b(fabs(p[1]));
10
return ( a < b || isNaN(b)
15
/** Returns true iff p is a zero vector, i.e.\ Point(0, 0).
17
* (NaN is considered non-zero.)
20
Geom::is_zero(Point const &p)
27
Geom::is_unit_vector(Point const &p)
29
return fabs(1.0 - L2(p)) <= 1e-4;
30
/* The tolerance of 1e-4 is somewhat arbitrary. Geom::Point::normalize is believed to return
31
points well within this tolerance. I'm not aware of any callers that want a small
32
tolerance; most callers would be ok with a tolerance of 0.25. */
35
Geom::Coord Geom::atan2(Point const p) {
36
return std::atan2(p[Geom::Y], p[Geom::X]);
39
/** Returns a version of \a a scaled to be a unit vector (within rounding error).
41
* The current version tries to handle infinite coordinates gracefully,
42
* but it's not clear that any callers need that.
44
* \pre a != Point(0, 0).
45
* \pre Neither coordinate is NaN.
46
* \post L2(ret) very near 1.0.
48
Point Geom::unit_vector(Point const &a)
55
Geom::Point abs(Geom::Point const &b)
58
for ( int i = 0 ; i < 2 ; i++ ) {
68
c-file-style:"stroustrup"
69
c-file-offsets:((innamespace . 0)(inline-open . 0)(case-label . +))
74
// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:encoding=utf-8:textwidth=99 :