Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
Philip Trettner
typed-geometry
Commits
17b9694b
Commit
17b9694b
authored
Feb 03, 2021
by
Aaron Grabowy
Browse files
Added intersects aabb for plane and halfspace
parent
d9ffba38
Changes
1
Hide whitespace changes
Inline
Side-by-side
src/typed-geometry/functions/objects/intersection.hh
View file @
17b9694b
...
@@ -1185,6 +1185,26 @@ template <class ScalarT>
...
@@ -1185,6 +1185,26 @@ template <class ScalarT>
return
intersects
(
inf_of
(
s
),
b
);
return
intersects
(
inf_of
(
s
),
b
);
}
}
template
<
int
D
,
class
ScalarT
>
[[
nodiscard
]]
constexpr
bool
intersects
(
plane
<
D
,
ScalarT
>
const
&
p
,
aabb
<
D
,
ScalarT
>
const
&
b
)
{
auto
const
c
=
centroid_of
(
b
);
auto
const
shadow
=
dot
(
b
.
max
-
c
,
abs
(
p
.
normal
));
return
shadow
>=
distance
(
c
,
p
);
// Note: no square needed, since no sqrt involved
}
template
<
int
D
,
class
ScalarT
>
[[
nodiscard
]]
constexpr
bool
intersects
(
halfspace
<
D
,
ScalarT
>
const
&
h
,
aabb
<
D
,
ScalarT
>
const
&
b
)
{
auto
const
c
=
centroid_of
(
b
);
auto
const
dist
=
signed_distance
(
c
,
h
);
if
(
dist
<=
ScalarT
(
0
))
return
true
;
auto
const
shadow
=
dot
(
b
.
max
-
c
,
abs
(
h
.
normal
));
return
shadow
>=
dist
;
}
template
<
int
D
,
class
ScalarT
>
template
<
int
D
,
class
ScalarT
>
[[
nodiscard
]]
constexpr
bool
intersects
(
sphere
<
D
,
ScalarT
>
const
&
a
,
aabb
<
D
,
ScalarT
>
const
&
b
)
[[
nodiscard
]]
constexpr
bool
intersects
(
sphere
<
D
,
ScalarT
>
const
&
a
,
aabb
<
D
,
ScalarT
>
const
&
b
)
{
{
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment