Code

Fix crash when floating dialog icon is not found
[inkscape.git] / src / 2geom / coord.h
1 /**
2  *  \file
3  *  \brief Defines the Coord "real" type with sufficient precision for coordinates.
4  *
5  * Copyright 2006 Nathan Hurst <njh@mail.csse.monash.edu.au>
6  *
7  * This library is free software; you can redistribute it and/or
8  * modify it either under the terms of the GNU Lesser General Public
9  * License version 2.1 as published by the Free Software Foundation
10  * (the "LGPL") or, at your option, under the terms of the Mozilla
11  * Public License Version 1.1 (the "MPL"). If you do not alter this
12  * notice, a recipient may use your version of this file under either
13  * the MPL or the LGPL.
14  *
15  * You should have received a copy of the LGPL along with this library
16  * in the file COPYING-LGPL-2.1; if not, write to the Free Software
17  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
18  * You should have received a copy of the MPL along with this library
19  * in the file COPYING-MPL-1.1
20  *
21  * The contents of this file are subject to the Mozilla Public License
22  * Version 1.1 (the "License"); you may not use this file except in
23  * compliance with the License. You may obtain a copy of the License at
24  * http://www.mozilla.org/MPL/
25  *
26  * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY
27  * OF ANY KIND, either express or implied. See the LGPL or the MPL for
28  * the specific language governing rights and limitations.
29  *
30  */
32 #ifndef SEEN_Geom_COORD_H
33 #define SEEN_Geom_COORD_H
35 #include <cmath>
36 #include <limits>
38 namespace Geom {
40 /**
41  * A "real" type with sufficient precision for coordinates.
42  *
43  * You may safely assume that double (or even float) provides enough precision for storing
44  * on-canvas points, and hence that double provides enough precision for dot products of
45  * differences of on-canvas points.
46  */
47 typedef double Coord;
49 const Coord EPSILON = 1e-5; //1e-18;
51 inline Coord infinity() {  return std::numeric_limits<Coord>::infinity();  }
53 //IMPL: NearConcept
54 inline bool are_near(Coord a, Coord b, double eps=EPSILON) { return fabs(a-b) <= eps; }
56 } /* namespace Geom */
59 #endif /* !SEEN_Geom_COORD_H */
61 /*
62   Local Variables:
63   mode:c++
64   c-file-style:"stroustrup"
65   c-file-offsets:((innamespace . 0)(inline-open . 0)(case-label . +))
66   indent-tabs-mode:nil
67   fill-column:99
68   End:
69 */
70 // vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:fileencoding=utf-8:textwidth=99 :