b2Distance.h
Go to the documentation of this file.
1 
2 /*
3 * Copyright (c) 2006-2009 Erin Catto http://www.box2d.org
4 *
5 * This software is provided 'as-is', without any express or implied
6 * warranty. In no event will the authors be held liable for any damages
7 * arising from the use of this software.
8 * Permission is granted to anyone to use this software for any purpose,
9 * including commercial applications, and to alter it and redistribute it
10 * freely, subject to the following restrictions:
11 * 1. The origin of this software must not be misrepresented; you must not
12 * claim that you wrote the original software. If you use this software
13 * in a product, an acknowledgment in the product documentation would be
14 * appreciated but is not required.
15 * 2. Altered source versions must be plainly marked as such, and must not be
16 * misrepresented as being the original software.
17 * 3. This notice may not be removed or altered from any source distribution.
18 */
19 
20 #ifndef B2_DISTANCE_H
21 #define B2_DISTANCE_H
22 
23 #include <Box2D/Common/b2Math.h>
24 
25 class b2Shape;
26 
30 {
32 
35  void Set(const b2Shape* shape, int32 index);
36 
38  int32 GetSupport(const b2Vec2& d) const;
39 
41  const b2Vec2& GetSupportVertex(const b2Vec2& d) const;
42 
44  int32 GetVertexCount() const;
45 
47  const b2Vec2& GetVertex(int32 index) const;
48 
53 };
54 
58 {
61  uint8 indexA[3];
62  uint8 indexB[3];
63 };
64 
69 {
74  bool useRadii;
75 };
76 
79 {
84 };
85 
89 void b2Distance(b2DistanceOutput* output,
90  b2SimplexCache* cache,
91  const b2DistanceInput* input);
92 
93 
95 
97 {
98  return m_count;
99 }
100 
102 {
103  b2Assert(0 <= index && index < m_count);
104  return m_vertices[index];
105 }
106 
108 {
109  int32 bestIndex = 0;
110  float32 bestValue = b2Dot(m_vertices[0], d);
111  for (int32 i = 1; i < m_count; ++i)
112  {
113  float32 value = b2Dot(m_vertices[i], d);
114  if (value > bestValue)
115  {
116  bestIndex = i;
117  bestValue = value;
118  }
119  }
120 
121  return bestIndex;
122 }
123 
124 inline const b2Vec2& b2DistanceProxy::GetSupportVertex(const b2Vec2& d) const
125 {
126  int32 bestIndex = 0;
127  float32 bestValue = b2Dot(m_vertices[0], d);
128  for (int32 i = 1; i < m_count; ++i)
129  {
130  float32 value = b2Dot(m_vertices[i], d);
131  if (value > bestValue)
132  {
133  bestIndex = i;
134  bestValue = value;
135  }
136  }
137 
138  return m_vertices[bestIndex];
139 }
140 
141 #endif
d
float32 b2Dot(const b2Vec2 &a, const b2Vec2 &b)
Perform the dot product on two vectors.
Definition: b2Math.h:405
void Set(const b2Shape *shape, int32 index)
Definition: b2Distance.cpp:28
unsigned short uint16
Definition: b2Settings.h:33
GLenum GLenum GLenum input
b2DistanceProxy proxyA
Definition: b2Distance.h:70
int32 iterations
number of GJK iterations used
Definition: b2Distance.h:83
A 2D column vector.
Definition: b2Math.h:52
b2Vec2 pointB
closest point on shapeB
Definition: b2Distance.h:81
GLsizei const GLfloat * value
const b2Vec2 & GetVertex(int32 index) const
Get a vertex by index. Used by b2Distance.
Definition: b2Distance.h:101
b2Vec2 pointA
closest point on shapeA
Definition: b2Distance.h:80
signed int int32
Definition: b2Settings.h:31
uint16 count
Definition: b2Distance.h:60
const b2Vec2 & GetSupportVertex(const b2Vec2 &d) const
Get the supporting vertex in the given direction.
Definition: b2Distance.h:124
b2Vec2 m_buffer[2]
Definition: b2Distance.h:49
b2Transform transformA
Definition: b2Distance.h:72
b2Transform transformB
Definition: b2Distance.h:73
int32 GetSupport(const b2Vec2 &d) const
Get the supporting vertex index in the given direction.
Definition: b2Distance.h:107
const b2Vec2 * m_vertices
Definition: b2Distance.h:50
unsigned char uint8
Definition: b2Settings.h:32
float32 metric
length or area
Definition: b2Distance.h:59
GLuint index
Output for b2Distance.
Definition: b2Distance.h:78
#define b2Assert(A)
Definition: b2Settings.h:27
int32 GetVertexCount() const
Get the vertex count.
Definition: b2Distance.h:96
float32 distance
Definition: b2Distance.h:82
float32 m_radius
Definition: b2Distance.h:52
void b2Distance(b2DistanceOutput *output, b2SimplexCache *cache, const b2DistanceInput *input)
Definition: b2Distance.cpp:444
b2DistanceProxy proxyB
Definition: b2Distance.h:71
float float32
Definition: b2Settings.h:35
GLdouble GLdouble GLdouble GLdouble GLdouble GLdouble f


mvsim
Author(s):
autogenerated on Fri May 7 2021 03:05:51