Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
T
typed-geometry
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container registry
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Philip Trettner
typed-geometry
Commits
baf38aeb
Commit
baf38aeb
authored
4 years ago
by
Aaron Grabowy
Browse files
Options
Downloads
Patches
Plain Diff
Added vertices_of aabb4 and box4
parent
502b9b36
No related branches found
No related tags found
1 merge request
!104
intersects aabb
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
src/typed-geometry/functions/objects/vertices.hh
+68
-23
68 additions, 23 deletions
src/typed-geometry/functions/objects/vertices.hh
with
68 additions
and
23 deletions
src/typed-geometry/functions/objects/vertices.hh
+
68
−
23
View file @
baf38aeb
...
...
@@ -37,8 +37,8 @@ template <class ScalarT, class TraitsT>
template
<
class
ScalarT
,
class
TraitsT
>
[[
nodiscard
]]
constexpr
array
<
pos
<
2
,
ScalarT
>
,
4
>
vertices_of
(
aabb
<
2
,
ScalarT
,
TraitsT
>
const
&
bb
)
{
auto
p10
=
pos
<
2
,
ScalarT
>
(
bb
.
max
.
x
,
bb
.
min
.
y
);
auto
p01
=
pos
<
2
,
ScalarT
>
(
bb
.
min
.
x
,
bb
.
max
.
y
);
auto
const
p10
=
pos
<
2
,
ScalarT
>
(
bb
.
max
.
x
,
bb
.
min
.
y
);
auto
const
p01
=
pos
<
2
,
ScalarT
>
(
bb
.
min
.
x
,
bb
.
max
.
y
);
return
{{
bb
.
min
,
p10
,
bb
.
max
,
p01
}};
// in ccw order
}
...
...
@@ -46,31 +46,52 @@ template <class ScalarT, class TraitsT>
template
<
class
ScalarT
,
class
TraitsT
>
[[
nodiscard
]]
constexpr
array
<
pos
<
3
,
ScalarT
>
,
8
>
vertices_of
(
aabb
<
3
,
ScalarT
,
TraitsT
>
const
&
bb
)
{
auto
p001
=
pos
<
3
,
ScalarT
>
(
bb
.
min
.
x
,
bb
.
min
.
y
,
bb
.
max
.
z
);
auto
p010
=
pos
<
3
,
ScalarT
>
(
bb
.
min
.
x
,
bb
.
max
.
y
,
bb
.
min
.
z
);
auto
p011
=
pos
<
3
,
ScalarT
>
(
bb
.
min
.
x
,
bb
.
max
.
y
,
bb
.
max
.
z
);
auto
p100
=
pos
<
3
,
ScalarT
>
(
bb
.
max
.
x
,
bb
.
min
.
y
,
bb
.
min
.
z
);
auto
p101
=
pos
<
3
,
ScalarT
>
(
bb
.
max
.
x
,
bb
.
min
.
y
,
bb
.
max
.
z
);
auto
p110
=
pos
<
3
,
ScalarT
>
(
bb
.
max
.
x
,
bb
.
max
.
y
,
bb
.
min
.
z
);
auto
const
p001
=
pos
<
3
,
ScalarT
>
(
bb
.
min
.
x
,
bb
.
min
.
y
,
bb
.
max
.
z
);
auto
const
p010
=
pos
<
3
,
ScalarT
>
(
bb
.
min
.
x
,
bb
.
max
.
y
,
bb
.
min
.
z
);
auto
const
p011
=
pos
<
3
,
ScalarT
>
(
bb
.
min
.
x
,
bb
.
max
.
y
,
bb
.
max
.
z
);
auto
const
p100
=
pos
<
3
,
ScalarT
>
(
bb
.
max
.
x
,
bb
.
min
.
y
,
bb
.
min
.
z
);
auto
const
p101
=
pos
<
3
,
ScalarT
>
(
bb
.
max
.
x
,
bb
.
min
.
y
,
bb
.
max
.
z
);
auto
const
p110
=
pos
<
3
,
ScalarT
>
(
bb
.
max
.
x
,
bb
.
max
.
y
,
bb
.
min
.
z
);
return
{{
bb
.
min
,
p001
,
p010
,
p011
,
p100
,
p101
,
p110
,
bb
.
max
}};
}
template
<
class
ScalarT
,
class
TraitsT
>
[[
nodiscard
]]
constexpr
array
<
pos
<
4
,
ScalarT
>
,
16
>
vertices_of
(
aabb
<
4
,
ScalarT
,
TraitsT
>
const
&
bb
)
{
auto
const
p0001
=
pos
<
4
,
ScalarT
>
(
bb
.
min
.
x
,
bb
.
min
.
y
,
bb
.
min
.
z
,
bb
.
max
.
w
);
auto
const
p0010
=
pos
<
4
,
ScalarT
>
(
bb
.
min
.
x
,
bb
.
min
.
y
,
bb
.
max
.
z
,
bb
.
min
.
w
);
auto
const
p0011
=
pos
<
4
,
ScalarT
>
(
bb
.
min
.
x
,
bb
.
min
.
y
,
bb
.
max
.
z
,
bb
.
max
.
w
);
auto
const
p0100
=
pos
<
4
,
ScalarT
>
(
bb
.
min
.
x
,
bb
.
max
.
y
,
bb
.
min
.
z
,
bb
.
min
.
w
);
auto
const
p0101
=
pos
<
4
,
ScalarT
>
(
bb
.
min
.
x
,
bb
.
max
.
y
,
bb
.
min
.
z
,
bb
.
max
.
w
);
auto
const
p0110
=
pos
<
4
,
ScalarT
>
(
bb
.
min
.
x
,
bb
.
max
.
y
,
bb
.
max
.
z
,
bb
.
min
.
w
);
auto
const
p0111
=
pos
<
4
,
ScalarT
>
(
bb
.
min
.
x
,
bb
.
max
.
y
,
bb
.
max
.
z
,
bb
.
max
.
w
);
auto
const
p1000
=
pos
<
4
,
ScalarT
>
(
bb
.
max
.
x
,
bb
.
min
.
y
,
bb
.
min
.
z
,
bb
.
min
.
w
);
auto
const
p1001
=
pos
<
4
,
ScalarT
>
(
bb
.
max
.
x
,
bb
.
min
.
y
,
bb
.
min
.
z
,
bb
.
max
.
w
);
auto
const
p1010
=
pos
<
4
,
ScalarT
>
(
bb
.
max
.
x
,
bb
.
min
.
y
,
bb
.
max
.
z
,
bb
.
min
.
w
);
auto
const
p1011
=
pos
<
4
,
ScalarT
>
(
bb
.
max
.
x
,
bb
.
min
.
y
,
bb
.
max
.
z
,
bb
.
max
.
w
);
auto
const
p1100
=
pos
<
4
,
ScalarT
>
(
bb
.
max
.
x
,
bb
.
max
.
y
,
bb
.
min
.
z
,
bb
.
min
.
w
);
auto
const
p1101
=
pos
<
4
,
ScalarT
>
(
bb
.
max
.
x
,
bb
.
max
.
y
,
bb
.
min
.
z
,
bb
.
max
.
w
);
auto
const
p1110
=
pos
<
4
,
ScalarT
>
(
bb
.
max
.
x
,
bb
.
max
.
y
,
bb
.
max
.
z
,
bb
.
min
.
w
);
return
{{
bb
.
min
,
p0001
,
p0010
,
p0011
,
p0100
,
p0101
,
p0110
,
p0111
,
p1001
,
p1010
,
p1011
,
p1100
,
p1101
,
p1110
,
bb
.
max
}};
}
template
<
class
ScalarT
,
int
DomainD
,
class
TraitsT
>
[[
nodiscard
]]
constexpr
array
<
pos
<
DomainD
,
ScalarT
>
,
2
>
vertices_of
(
box
<
1
,
ScalarT
,
DomainD
,
TraitsT
>
const
&
b
)
{
const
auto
p0
=
b
[
comp
<
1
,
ScalarT
>
(
-
1
)];
const
auto
p1
=
b
[
comp
<
1
,
ScalarT
>
(
1
)];
auto
const
p0
=
b
[
comp
<
1
,
ScalarT
>
(
-
1
)];
auto
const
p1
=
b
[
comp
<
1
,
ScalarT
>
(
1
)];
return
{{
p0
,
p1
}};
}
template
<
class
ScalarT
,
int
DomainD
,
class
TraitsT
>
[[
nodiscard
]]
constexpr
array
<
pos
<
DomainD
,
ScalarT
>
,
4
>
vertices_of
(
box
<
2
,
ScalarT
,
DomainD
,
TraitsT
>
const
&
b
)
{
const
auto
p00
=
b
[
comp
<
2
,
ScalarT
>
(
-
1
,
-
1
)];
const
auto
p10
=
b
[
comp
<
2
,
ScalarT
>
(
1
,
-
1
)];
const
auto
p11
=
b
[
comp
<
2
,
ScalarT
>
(
1
,
1
)];
const
auto
p01
=
b
[
comp
<
2
,
ScalarT
>
(
-
1
,
1
)];
auto
const
p00
=
b
[
comp
<
2
,
ScalarT
>
(
-
1
,
-
1
)];
auto
const
p10
=
b
[
comp
<
2
,
ScalarT
>
(
1
,
-
1
)];
auto
const
p11
=
b
[
comp
<
2
,
ScalarT
>
(
1
,
1
)];
auto
const
p01
=
b
[
comp
<
2
,
ScalarT
>
(
-
1
,
1
)];
return
{{
p00
,
p10
,
p11
,
p01
}};
// in ccw order
}
...
...
@@ -78,25 +99,49 @@ template <class ScalarT, int DomainD, class TraitsT>
template
<
class
ScalarT
,
int
DomainD
,
class
TraitsT
>
[[
nodiscard
]]
constexpr
array
<
pos
<
DomainD
,
ScalarT
>
,
8
>
vertices_of
(
box
<
3
,
ScalarT
,
DomainD
,
TraitsT
>
const
&
b
)
{
const
auto
p000
=
b
[
comp
<
3
,
ScalarT
>
(
-
1
,
-
1
,
-
1
)];
const
auto
p100
=
b
[
comp
<
3
,
ScalarT
>
(
1
,
-
1
,
-
1
)];
const
auto
p110
=
b
[
comp
<
3
,
ScalarT
>
(
1
,
1
,
-
1
)];
const
auto
p010
=
b
[
comp
<
3
,
ScalarT
>
(
-
1
,
1
,
-
1
)];
const
auto
p001
=
b
[
comp
<
3
,
ScalarT
>
(
-
1
,
-
1
,
1
)];
const
auto
p101
=
b
[
comp
<
3
,
ScalarT
>
(
1
,
-
1
,
1
)];
const
auto
p111
=
b
[
comp
<
3
,
ScalarT
>
(
1
,
1
,
1
)];
const
auto
p011
=
b
[
comp
<
3
,
ScalarT
>
(
-
1
,
1
,
1
)];
auto
const
p000
=
b
[
comp
<
3
,
ScalarT
>
(
-
1
,
-
1
,
-
1
)];
auto
const
p100
=
b
[
comp
<
3
,
ScalarT
>
(
1
,
-
1
,
-
1
)];
auto
const
p110
=
b
[
comp
<
3
,
ScalarT
>
(
1
,
1
,
-
1
)];
auto
const
p010
=
b
[
comp
<
3
,
ScalarT
>
(
-
1
,
1
,
-
1
)];
auto
const
p001
=
b
[
comp
<
3
,
ScalarT
>
(
-
1
,
-
1
,
1
)];
auto
const
p101
=
b
[
comp
<
3
,
ScalarT
>
(
1
,
-
1
,
1
)];
auto
const
p111
=
b
[
comp
<
3
,
ScalarT
>
(
1
,
1
,
1
)];
auto
const
p011
=
b
[
comp
<
3
,
ScalarT
>
(
-
1
,
1
,
1
)];
return
{{
p000
,
p100
,
p110
,
p010
,
p001
,
p101
,
p111
,
p011
}};
}
template
<
class
ScalarT
,
int
DomainD
,
class
TraitsT
>
[[
nodiscard
]]
constexpr
array
<
pos
<
DomainD
,
ScalarT
>
,
16
>
vertices_of
(
box
<
4
,
ScalarT
,
DomainD
,
TraitsT
>
const
&
b
)
{
auto
const
p0000
=
b
[
comp
<
4
,
ScalarT
>
(
-
1
,
-
1
,
-
1
,
-
1
)];
auto
const
p1000
=
b
[
comp
<
4
,
ScalarT
>
(
1
,
-
1
,
-
1
,
-
1
)];
auto
const
p1100
=
b
[
comp
<
4
,
ScalarT
>
(
1
,
1
,
-
1
,
-
1
)];
auto
const
p0100
=
b
[
comp
<
4
,
ScalarT
>
(
-
1
,
1
,
-
1
,
-
1
)];
auto
const
p0010
=
b
[
comp
<
4
,
ScalarT
>
(
-
1
,
-
1
,
1
,
-
1
)];
auto
const
p1010
=
b
[
comp
<
4
,
ScalarT
>
(
1
,
-
1
,
1
,
-
1
)];
auto
const
p1110
=
b
[
comp
<
4
,
ScalarT
>
(
1
,
1
,
1
,
-
1
)];
auto
const
p0110
=
b
[
comp
<
4
,
ScalarT
>
(
-
1
,
1
,
1
,
-
1
)];
auto
const
p0001
=
b
[
comp
<
4
,
ScalarT
>
(
-
1
,
-
1
,
-
1
,
1
)];
auto
const
p1001
=
b
[
comp
<
4
,
ScalarT
>
(
1
,
-
1
,
-
1
,
1
)];
auto
const
p1101
=
b
[
comp
<
4
,
ScalarT
>
(
1
,
1
,
-
1
,
1
)];
auto
const
p0101
=
b
[
comp
<
4
,
ScalarT
>
(
-
1
,
1
,
-
1
,
1
)];
auto
const
p0011
=
b
[
comp
<
4
,
ScalarT
>
(
-
1
,
-
1
,
1
,
1
)];
auto
const
p1011
=
b
[
comp
<
4
,
ScalarT
>
(
1
,
-
1
,
1
,
1
)];
auto
const
p1111
=
b
[
comp
<
4
,
ScalarT
>
(
1
,
1
,
1
,
1
)];
auto
const
p0111
=
b
[
comp
<
4
,
ScalarT
>
(
-
1
,
1
,
1
,
1
)];
return
{{
p0000
,
p1000
,
p1100
,
p0100
,
p0010
,
p1010
,
p1110
,
p0110
,
p0001
,
p1001
,
p1101
,
p0101
,
p0011
,
p1011
,
p1111
,
p0111
}};
}
template
<
class
BaseT
,
class
TraitsT
>
[[
nodiscard
]]
constexpr
auto
vertices_of
(
pyramid
<
BaseT
,
TraitsT
>
const
&
py
)
{
using
ScalarT
=
typename
BaseT
::
scalar_t
;
static_assert
(
!
std
::
is_same_v
<
BaseT
,
sphere
<
2
,
ScalarT
,
3
>>
,
"not possible for cones"
);
const
auto
vertsBase
=
vertices_of
(
py
.
base
);
auto
const
vertsBase
=
vertices_of
(
py
.
base
);
auto
res
=
array
<
pos
<
3
,
ScalarT
>
,
vertsBase
.
size
()
+
1
>
();
for
(
size_t
i
=
0
;
i
<
vertsBase
.
size
();
++
i
)
res
[
i
]
=
vertsBase
[
i
];
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment