TORCS  1.3.10
The Open Racing Car Simulator
Loading...
Searching...
No Matches
Polygon.cpp
Go to the documentation of this file.
1/*
2 SOLID - Software Library for Interference Detection
3 Copyright (C) 1997-1998 Gino van den Bergen
4
5 This library is free software; you can redistribute it and/or
6 modify it under the terms of the GNU Library General Public
7 License as published by the Free Software Foundation; either
8 version 2 of the License, or (at your option) any later version.
9
10 This library is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 Library General Public License for more details.
14
15 You should have received a copy of the GNU Library General Public
16 License along with this library; if not, write to the Free
17 Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
18
19 Please send remarks, questions and bug reports to gino@win.tue.nl,
20 or write to:
21 Gino van den Bergen
22 Department of Mathematics and Computing Science
23 Eindhoven University of Technology
24 P.O. Box 513, 5600 MB Eindhoven, The Netherlands
25*/
26
27#ifdef _MSC_VER
28#pragma warning(disable:4786) // identifier was truncated to '255'
29#endif // _MSC_VER
30
31#include "Polygon.h"
32
33Point Polygon::support(const Vector& v) const {
34 Scalar h = dot((*this)[ci], v), d;
35 int ni = ci < numVerts()-1 ? ci+1 : 0;
36 if ((d = dot((*this)[ni], v)) > h) {
37 do {
38 h = d; ci = ni;
39 if (++ni == numVerts()) ni = 0;
40 }
41 while ((d = dot((*this)[ni], v)) > h);
42 }
43 else {
44 ni = ci ? ci-1 : numVerts()-1;
45 while ((d = dot((*this)[ni], v)) > h) {
46 h = d; ci = ni;
47 if (ni) --ni; else ni = numVerts()-1;
48 }
49 }
50 return (*this)[ci];
51}
52
53
54
55
56
#define Scalar
Definition Basic.h:34
Scalar dot(const Quaternion &q1, const Quaternion &q2)
Definition Quaternion.h:163
Definition Point.h:34
Point support(const Vector &) const
Definition Polygon.cpp:33
int ci
Definition Polygon.h:44
int numVerts() const
Definition Polytope.h:46