Main Page
Related Pages
Namespaces
Classes
Files
File List
File Members
hrplib
hrpCollision
Opcode
OPC_SphereAABBOverlap.h
Go to the documentation of this file.
1
8
inline_
BOOL
SphereCollider::SphereAABBOverlap
(
const
Point
& center,
const
Point
& extents)
10
{
11
// Stats
12
mNbVolumeBVTests
++;
13
14
float
d = 0.0f;
15
16
//find the square of the distance
17
//from the sphere to the box
18
#ifdef OLDIES
19
for
(
udword
i
=0;
i
<3;
i
++)
20
{
21
float
tmp =
mCenter
[
i
] - center[
i
];
22
float
s = tmp + extents[
i
];
23
24
if
(s<0.0
f
) d += s*s;
25
else
26
{
27
s = tmp - extents[
i
];
28
if
(s>0.0
f
) d += s*s;
29
}
30
}
31
#endif
32
33
//#ifdef NEW_TEST
34
35
// float tmp = mCenter.x - center.x;
36
// float s = tmp + extents.x;
37
38
float
tmp,s;
39
40
tmp =
mCenter
.
x
- center.x;
41
s = tmp + extents.x;
42
43
if
(s<0.0
f
)
44
{
45
d += s*s;
46
if
(d>
mRadius2
)
return
FALSE
;
47
}
48
else
49
{
50
s = tmp - extents.x;
51
if
(s>0.0
f
)
52
{
53
d += s*s;
54
if
(d>
mRadius2
)
return
FALSE
;
55
}
56
}
57
58
tmp =
mCenter
.
y
- center.y;
59
s = tmp + extents.y;
60
61
if
(s<0.0
f
)
62
{
63
d += s*s;
64
if
(d>
mRadius2
)
return
FALSE
;
65
}
66
else
67
{
68
s = tmp - extents.y;
69
if
(s>0.0
f
)
70
{
71
d += s*s;
72
if
(d>
mRadius2
)
return
FALSE
;
73
}
74
}
75
76
tmp =
mCenter
.
z
- center.z;
77
s = tmp + extents.z;
78
79
if
(s<0.0
f
)
80
{
81
d += s*s;
82
if
(d>
mRadius2
)
return
FALSE
;
83
}
84
else
85
{
86
s = tmp - extents.z;
87
if
(s>0.0
f
)
88
{
89
d += s*s;
90
if
(d>
mRadius2
)
return
FALSE
;
91
}
92
}
93
//#endif
94
95
#ifdef OLDIES
96
// Point Min = center - extents;
97
// Point Max = center + extents;
98
99
float
d = 0.0f;
100
101
//find the square of the distance
102
//from the sphere to the box
103
for
(
udword
i
=0;
i
<3;
i
++)
104
{
105
float
Min = center[
i
] - extents[
i
];
106
107
// if(mCenter[i]<Min[i])
108
if
(
mCenter
[
i
]<Min)
109
{
110
// float s = mCenter[i] - Min[i];
111
float
s =
mCenter
[
i
] - Min;
112
d += s*s;
113
}
114
else
115
{
116
float
Max = center[
i
] + extents[
i
];
117
118
// if(mCenter[i]>Max[i])
119
if
(
mCenter
[
i
]>Max)
120
{
121
float
s =
mCenter
[
i
] - Max;
122
d += s*s;
123
}
124
}
125
}
126
#endif
127
return
d <=
mRadius2
;
128
}
FALSE
#define FALSE
Definition:
OPC_IceHook.h:9
inline_
#define inline_
Definition:
IcePreprocessor.h:103
Point::z
float z
Definition:
IcePoint.h:524
i
png_uint_32 i
Definition:
png.h:2735
Point
Definition:
IcePoint.h:25
BOOL
int BOOL
Another boolean type.
Definition:
IceTypes.h:102
Point::x
float x
Definition:
IcePoint.h:524
udword
unsigned int udword
sizeof(udword) must be 4
Definition:
IceTypes.h:65
SphereCollider::mRadius2
float mRadius2
Sphere radius squared.
Definition:
OPC_SphereCollider.h:65
Point::y
float y
Definition:
IcePoint.h:524
VolumeCollider::mNbVolumeBVTests
udword mNbVolumeBVTests
Number of Volume-BV tests.
Definition:
OPC_VolumeCollider.h:99
swingTest.f
f
Definition:
swingTest.py:6
SphereCollider::SphereAABBOverlap
inline_ BOOL SphereAABBOverlap(const Point ¢er, const Point &extents)
Definition:
OPC_SphereAABBOverlap.h:9
SphereCollider::mCenter
Point mCenter
Sphere center.
Definition:
OPC_SphereCollider.h:64
openhrp3
Author(s): AIST, General Robotix Inc., Nakamura Lab of Dept. of Mechano Informatics at University of Tokyo
autogenerated on Sat May 8 2021 02:42:39