21 template <
typename Real,
typename ComputeType>
37 int numEdges,
int const* edges,
Vector2<Real> const* points)
const;
41 template <
typename Real,
typename ComputeType>
48 ch0(numPoints0, points0, (Real)0);
56 ch1(numPoints1, points1, (Real)0);
62 int numEdges0 =
static_cast<int>(ch0.
GetHull().size());
63 int const* edges0 = &ch0.
GetHull()[0];
64 int numEdges1 =
static_cast<int>(ch1.
GetHull().size());
65 int const* edges1 = &ch1.
GetHull()[0];
68 int j0, j1, i0, i1, side0, side1;
71 for (j1 = 0, j0 = numEdges0 - 1; j1 < numEdges0; j0 = j1++)
78 separatingLine.
origin = points0[i0];
79 separatingLine.
direction = points0[i1] - points0[i0];
82 lineConstant =
Dot(lineNormal, separatingLine.
origin);
85 side1 =
OnSameSide(lineNormal, lineConstant, numEdges1, edges1,
91 side0 =
WhichSide(lineNormal, lineConstant, numEdges0,
102 for (j1 = 0, j0 = numEdges1 - 1; j1 < numEdges1; j0 = j1++)
109 separatingLine.
origin = points1[i0];
110 separatingLine.
direction = points1[i1] - points1[i0];
113 lineConstant =
Dot(lineNormal, separatingLine.
origin);
116 side0 =
OnSameSide(lineNormal, lineConstant, numEdges0, edges0,
122 side1 =
WhichSide(lineNormal, lineConstant, numEdges1,
125 if (side0*side1 <= 0)
135 template <
typename Real,
typename ComputeType>
137 Vector2<Real> const& lineNormal, Real lineConstant,
int numEdges,
142 int posSide = 0, negSide = 0;
144 for (
int i1 = 0, i0 = numEdges - 1; i1 < numEdges; i0 = i1++)
146 c0 =
Dot(lineNormal, points[edges[i0]]);
147 if (c0 > lineConstant)
151 else if (c0 < lineConstant)
156 if (posSide && negSide)
162 c0 =
Dot(lineNormal, points[edges[i1]]);
163 if (c0 > lineConstant)
167 else if (c0 < lineConstant)
172 if (posSide && negSide)
179 return (posSide ? +1 : -1);
182 template <
typename Real,
typename ComputeType>
184 Vector2<Real> const& lineNormal, Real lineConstant,
int numEdges,
189 for (
int i1 = 0, i0 = numEdges - 1; i1 < numEdges; i0 = i1++)
191 c0 =
Dot(lineNormal, points[edges[i0]]);
192 if (c0 > lineConstant)
197 if (c0 < lineConstant)
203 c0 =
Dot(lineNormal, points[edges[i1]]);
204 if (c0 > lineConstant)
209 if (c0 < lineConstant)
std::vector< int > const & GetHull() const
int WhichSide(Vector2< Real > const &lineNormal, Real lineConstant, int numEdges, int const *edges, Vector2< Real > const *points) const
Vector< N, Real > direction
GLfixed GLfixed GLint GLint GLfixed points
int OnSameSide(Vector2< Real > const &lineNormal, Real lineConstant, int numEdges, int const *edges, Vector2< Real > const *points) const
DualQuaternion< Real > Dot(DualQuaternion< Real > const &d0, DualQuaternion< Real > const &d1)
Real Normalize(GVector< Real > &v, bool robust=false)
Vector2< Real > Perp(Vector2< Real > const &v)
bool operator()(int numPoints0, Vector2< Real > const *points0, int numPoints1, Vector2< Real > const *points1, Line2< Real > &separatingLine) const