~ubuntu-branches/ubuntu/natty/inkscape/natty

« back to all changes in this revision

Viewing changes to src/libavoid/geometry.h

  • Committer: Bazaar Package Importer
  • Author(s): Alex Valavanis
  • Date: 2010-09-12 19:44:58 UTC
  • mfrom: (1.1.12 upstream) (45.1.3 maverick)
  • Revision ID: james.westby@ubuntu.com-20100912194458-4sjwmbl7dlsrk5dc
Tags: 0.48.0-1ubuntu1
* Merge with Debian unstable (LP: #628048, LP: #401567, LP: #456248, 
  LP: #463602, LP: #591986)
* debian/control: 
  - Ubuntu maintainers
  - Promote python-lxml, python-numpy, python-uniconvertor to Recommends.
  - Demote pstoedit to Suggests (universe package).
  - Suggests ttf-dejavu instead of ttf-bitstream-vera (LP: #513319)
* debian/rules:
  - Run intltool-update on build (Ubuntu-specific).
  - Add translation domain to .desktop files (Ubuntu-specific).
* debian/dirs:
  - Add usr/share/pixmaps.  Allow inkscape.xpm installation
* drop 50-poppler-API.dpatch (now upstream)
* drop 51-paste-in-unwritable-directory.dpatch (now upstream) 

Show diffs side-by-side

added added

removed removed

Lines of Context:
2
2
 * vim: ts=4 sw=4 et tw=0 wm=0
3
3
 *
4
4
 * libavoid - Fast, Incremental, Object-avoiding Line Router
5
 
 * Copyright (C) 2004-2006  Michael Wybrow <mjwybrow@users.sourceforge.net>
 
5
 *
 
6
 * Copyright (C) 2004-2009  Monash University
6
7
 *
7
8
 * --------------------------------------------------------------------
8
9
 * Much of the code in this module is based on code published with
18
19
 * modify it under the terms of the GNU Lesser General Public
19
20
 * License as published by the Free Software Foundation; either
20
21
 * version 2.1 of the License, or (at your option) any later version.
 
22
 * See the file LICENSE.LGPL distributed with the library.
 
23
 *
 
24
 * Licensees holding a valid commercial license may use this file in
 
25
 * accordance with the commercial license agreement provided with the 
 
26
 * library.
21
27
 *
22
28
 * This library is distributed in the hope that it will be useful,
23
29
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
24
 
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
25
 
 * Lesser General Public License for more details.
 
30
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  
26
31
 *
27
 
 * You should have received a copy of the GNU Lesser General Public
28
 
 * License along with this library; if not, write to the Free Software
29
 
 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
30
 
 * 
 
32
 * Author(s):   Michael Wybrow <mjwybrow@users.sourceforge.net>
31
33
*/
32
34
 
33
35
 
35
37
#define _GEOMETRY_H
36
38
 
37
39
#include "libavoid/geomtypes.h"
 
40
#include "libavoid/assertions.h"
38
41
 
39
42
namespace Avoid {
40
43
 
41
44
 
42
 
extern double dist(const Point& a, const Point& b);
43
 
extern double totalLength(const Polygn& poly);
 
45
extern double euclideanDist(const Point& a, const Point& b);
 
46
extern double manhattanDist(const Point& a, const Point& b);
 
47
extern double totalLength(const Polygon& poly);
44
48
extern double angle(const Point& a, const Point& b, const Point& c);
45
49
extern bool segmentIntersect(const Point& a, const Point& b,
46
50
        const Point& c, const Point& d);
47
 
extern bool inPoly(const Polygn& poly, const Point& q);
48
 
extern bool inPolyGen(const Polygn& poly, const Point& q);
 
51
extern bool segmentShapeIntersect(const Point& e1, const Point& e2, 
 
52
        const Point& s1, const Point& s2, bool& seenIntersectionAtEndpoint);
 
53
extern bool inPoly(const Polygon& poly, const Point& q, bool countBorder = true);
 
54
extern bool inPolyGen(const PolygonInterface& poly, const Point& q);
49
55
extern bool inValidRegion(bool IgnoreRegions, const Point& a0,
50
56
        const Point& a1, const Point& a2, const Point& b);
51
57
extern int cornerSide(const Point &c1, const Point &c2, const Point &c3,
52
58
        const Point& p);
 
59
extern bool pointOnLine(const Point& a, const Point& b, const Point& c,
 
60
        const double tolerance = 0.0);
 
61
 
 
62
// To be used only when the points are known to be colinear.
 
63
extern bool inBetween(const Point& a, const Point& b, const Point& c);
53
64
 
54
65
 
55
66
// Direction from vector.
61
72
//
62
73
// Based on the code of 'AreaSign'.
63
74
//
64
 
static inline int vecDir(const Point& a, const Point& b, const Point& c)
 
75
// The 'maybeZero' argument can be used to adjust the tolerance of the 
 
76
// function.  It will be most accurate when 'maybeZero' == 0.0, the default.
 
77
//
 
78
static inline int vecDir(const Point& a, const Point& b, const Point& c, 
 
79
        const double maybeZero = 0.0)
65
80
{
 
81
    COLA_ASSERT(maybeZero >= 0);
 
82
 
66
83
    double area2 = ((b.x - a.x) * (c.y - a.y)) -
67
84
                   ((c.x - a.x) * (b.y - a.y));
68
85
    
69
 
    if (area2 < -0.001)
 
86
    if (area2 < (-maybeZero))
70
87
    {
71
88
        return -1;
72
89
    }
73
 
    else if (area2 > 0.001)
 
90
    else if (area2 > maybeZero)
74
91
    {
75
92
        return 1;
76
93
    }
100
117
static const int PARALLEL = 3;
101
118
extern int segmentIntersectPoint(const Point& a1, const Point& a2,
102
119
        const Point& b1, const Point& b2, double *x, double *y);
 
120
extern int rayIntersectPoint(const Point& a1, const Point& a2,
 
121
        const Point& b1, const Point& b2, double *x, double *y);
103
122
 
104
123
 
105
124
}