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
tg-samples
Commits
52b969c4
Commit
52b969c4
authored
Mar 12, 2020
by
Julian Schakib
Browse files
triangle plane intersection tests
parent
7b572186
Pipeline
#13773
passed with stage
in 6 minutes and 17 seconds
Changes
2
Pipelines
1
Show whitespace changes
Inline
Side-by-side
typed-geometry
@
f98a78e6
Subproject commit f
0136489a98723376f10be4ab1ff8e9bae146b6a
Subproject commit f
98a78e690b49be701eb4dd6f6415e8c697130fd
tests/feature/intersections/plane-intersect.cc
View file @
52b969c4
...
...
@@ -197,4 +197,67 @@ TG_FUZZ_TEST(Plane, Intersect)
CHECK
(
intersects
(
c
,
p
));
}
}
// plane3 - triangle3
{
auto
const
box
=
tg
::
aabb3
(
tg
::
pos3
(
-
10.0
f
),
tg
::
pos3
(
10.0
f
));
auto
const
center
=
uniform
(
rng
,
box
);
auto
const
n
=
tg
::
uniform
<
tg
::
dir3
>
(
rng
);
auto
plane
=
tg
::
plane3
(
n
,
center
);
auto
const
t
=
any_normal
(
n
);
auto
const
bi
=
normalize
(
cross
(
n
,
t
));
// coplanar triangle
auto
triangle
=
tg
::
triangle3
(
center
,
center
+
t
,
center
+
bi
);
CHECK
(
intersects
(
triangle
,
plane
));
// one point of triangle in plane
tg
::
array
<
tg
::
pos3
,
3
>
c
=
{
center
,
center
+
n
,
center
+
n
+
t
};
// check all possible orders
for
(
auto
i
=
0
;
i
<
3
;
i
++
)
{
triangle
=
tg
::
triangle
(
c
[(
i
+
0
)
%
3
],
c
[(
i
+
1
)
%
3
],
c
[(
i
+
2
)
%
3
]);
CHECK
(
intersects
(
plane
,
triangle
));
triangle
=
tg
::
triangle
(
c
[(
i
+
1
)
%
3
],
c
[(
i
+
0
)
%
3
],
c
[(
i
+
2
)
%
3
]);
CHECK
(
intersects
(
plane
,
triangle
));
}
// all above triangle in plane
c
=
{
center
+
n
+
bi
,
center
+
n
,
center
+
n
+
t
};
// check all possible orders
for
(
auto
i
=
0
;
i
<
3
;
i
++
)
{
triangle
=
tg
::
triangle
(
c
[(
i
+
0
)
%
3
],
c
[(
i
+
1
)
%
3
],
c
[(
i
+
2
)
%
3
]);
CHECK
(
!
intersects
(
plane
,
triangle
));
triangle
=
tg
::
triangle
(
c
[(
i
+
1
)
%
3
],
c
[(
i
+
0
)
%
3
],
c
[(
i
+
2
)
%
3
]);
CHECK
(
!
intersects
(
plane
,
triangle
));
}
// all below triangle in plane
c
=
{
center
-
n
+
bi
,
center
-
n
,
center
-
n
+
t
};
// check all possible orders
for
(
auto
i
=
0
;
i
<
3
;
i
++
)
{
triangle
=
tg
::
triangle
(
c
[(
i
+
0
)
%
3
],
c
[(
i
+
1
)
%
3
],
c
[(
i
+
2
)
%
3
]);
CHECK
(
!
intersects
(
plane
,
triangle
));
triangle
=
tg
::
triangle
(
c
[(
i
+
1
)
%
3
],
c
[(
i
+
0
)
%
3
],
c
[(
i
+
2
)
%
3
]);
CHECK
(
!
intersects
(
plane
,
triangle
));
}
// 2 on 1 side
c
=
{
center
-
n
+
bi
,
center
+
n
,
center
-
n
+
t
};
// check all possible orders
for
(
auto
i
=
0
;
i
<
3
;
i
++
)
{
triangle
=
tg
::
triangle
(
c
[(
i
+
0
)
%
3
],
c
[(
i
+
1
)
%
3
],
c
[(
i
+
2
)
%
3
]);
CHECK
(
intersects
(
plane
,
triangle
));
triangle
=
tg
::
triangle
(
c
[(
i
+
1
)
%
3
],
c
[(
i
+
0
)
%
3
],
c
[(
i
+
2
)
%
3
]);
CHECK
(
intersects
(
plane
,
triangle
));
}
}
}
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