2 * This file is part of NumptyPhysics
3 * Copyright (C) 2008 Tim Edmonds
5 * This program is free software; you can redistribute it and/or
6 * modify it under the terms of the GNU General Public License as
7 * published by the Free Software Foundation; either version 3 of the
8 * License, or (at your option) any later version.
10 * This program is distributed in the hope that it will be useful, but
11 * WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 * General Public License for more details.
27 Segment( const Vec2
& p1
, const Vec2
& p2
)
28 : m_p1(p1
), m_p2(p2
) {}
29 float32
distanceTo( const Vec2
& p
);
35 class Path
: public Array
<Vec2
>
39 Path( int n
, Vec2
* p
);
40 Path( const char *ptlist
);
43 Path
& translate(const Vec2
& xlate
);
44 Path
& rotate(const b2Mat22
& rot
);
45 Path
& scale(float32 factor
);
47 inline Vec2
& origin() { return at(0); }
49 inline Path
& operator&(const Vec2
& other
)
55 inline Path
& operator&(const b2Vec2
& other
)
61 inline Path
operator+(const Vec2
& p
) const
64 return r
.translate( p
);
67 inline Path
operator-(const Vec2
& p
) const
71 return r
.translate( n
);
74 inline Path
operator*(const b2Mat22
& m
) const
80 inline Path
& operator+=(const Vec2
& p
)
82 return translate( p
);
85 inline Path
& operator-=(const Vec2
& p
)
88 return translate( n
);
91 inline int numPoints() const { return size(); }
92 inline const Vec2
& point(int i
) const { return at(i
); }
93 inline Vec2
& point(int i
) { return at(i
); }
94 inline Vec2
& first() { return at(0); }
95 inline Vec2
& last() { return at(size()-1); }
97 void simplify( float32 threshold
);
101 void simplifySub( int first
, int last
, float32 threshold
, bool* keepflags
);