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
33801c9d
Commit
33801c9d
authored
Feb 08, 2020
by
Aaron Grabowy
Browse files
Adapted tests to new types
parent
7ed1ccde
Pipeline
#13518
failed with stage
in 6 minutes and 19 seconds
Changes
5
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
typed-geometry
@
1f108dbf
Subproject commit
bd41a428c7141d6631a0744ab37a624863a9f22d
Subproject commit
1f108dbf619ac67b3b8eba0ffd690fef02980e7a
tests/feature/objects/area.cc
View file @
33801c9d
...
...
@@ -15,7 +15,7 @@ TG_FUZZ_TEST(TypedGeometry, Area)
auto
alpha
=
tg
::
radians
(
tg
::
abs
(
uniform
(
rng
,
box1
).
x
)
*
tg
::
pi_scalar
<
tg
::
f32
>
);
auto
rotation
=
tg
::
mat2
::
from_cols
(
tg
::
vec2
(
tg
::
cos
(
alpha
),
-
sin
(
alpha
)),
tg
::
vec2
(
sin
(
alpha
),
cos
(
alpha
)));
tg
::
f32
randomScale
=
0
;
int
max
=
10
;
auto
max
=
10
.
f
;
while
(
randomScale
==
0
)
randomScale
=
max
*
uniform
(
rng
,
box1
).
x
;
auto
scale
=
tg
::
mat2
::
from_cols
(
tg
::
vec2
(
randomScale
,
0
),
tg
::
vec2
(
0
,
randomScale
));
...
...
@@ -67,7 +67,7 @@ TG_FUZZ_TEST(TypedGeometry, Area)
auto
rotation
=
rotation_x
(
alpha
)
*
rotation_y
(
alpha
)
*
rotation_z
(
alpha
);
tg
::
f32
randomScale
=
0
;
int
max
=
10
;
auto
max
=
10
.
f
;
while
(
randomScale
==
0
)
randomScale
=
max
*
uniform
(
rng
,
box1
).
x
;
...
...
tests/feature/objects/interpolate.cc
View file @
33801c9d
...
...
@@ -15,7 +15,7 @@ TG_FUZZ_TEST(TypedGeometry, Interpolate)
auto
alpha
=
tg
::
radians
(
tg
::
abs
(
uniform
(
rng
,
box1
).
x
)
*
tg
::
pi_scalar
<
tg
::
f32
>
);
auto
rotation
=
tg
::
mat2
::
from_cols
(
tg
::
vec2
(
tg
::
cos
(
alpha
),
-
sin
(
alpha
)),
tg
::
vec2
(
sin
(
alpha
),
cos
(
alpha
)));
tg
::
f32
randomScale
=
0
;
int
max
=
10
;
auto
max
=
10
.
f
;
while
(
randomScale
==
0
)
randomScale
=
max
*
uniform
(
rng
,
box1
).
x
;
auto
scale
=
tg
::
mat2
::
from_cols
(
tg
::
vec2
(
randomScale
,
0
),
tg
::
vec2
(
0
,
randomScale
));
...
...
@@ -62,7 +62,7 @@ TG_FUZZ_TEST(TypedGeometry, Interpolate)
auto
rotation
=
rotation_x
(
alpha
)
*
rotation_y
(
alpha
)
*
rotation_z
(
alpha
);
tg
::
f32
randomScale
=
0
;
int
max
=
10
;
auto
max
=
10
.
f
;
while
(
randomScale
==
0
)
randomScale
=
max
*
uniform
(
rng
,
box1
).
x
;
...
...
tests/feature/objects/project.cc
View file @
33801c9d
...
...
@@ -27,6 +27,18 @@ TG_FUZZ_TEST_MAX_ITS(TypedGeometry, Project, 20)
CHECK
(
dist
==
approx
(
0.0
f
));
};
auto
const
test_obj_and_boundary
=
[
&
test_obj
](
auto
p
,
auto
o
)
{
test_obj
(
p
,
o
);
test_obj
(
p
,
boundary_of
(
o
));
};
auto
const
test_obj_and_boundary_no_caps
=
[
&
test_obj
](
auto
p
,
auto
o
)
{
test_obj
(
p
,
o
);
test_obj
(
p
,
boundary_of
(
o
));
test_obj
(
p
,
boundary_no_caps_of
(
o
));
};
const
auto
r
=
uniform
(
rng
,
0.0
f
,
10.0
f
);
const
auto
n2
=
tg
::
dir
(
uniform
(
rng
,
tg
::
sphere_boundary
<
2
,
float
>::
unit
));
const
auto
n3
=
tg
::
dir
(
uniform
(
rng
,
tg
::
sphere_boundary
<
3
,
float
>::
unit
));
...
...
@@ -67,6 +79,10 @@ TG_FUZZ_TEST_MAX_ITS(TypedGeometry, Project, 20)
const
auto
axis0
=
tg
::
segment3
(
pos30
,
pos31
);
const
auto
disk0
=
tg
::
sphere2in3
(
pos30
,
r
,
n3
);
auto
d1
=
tg
::
uniform
<
tg
::
dir1
>
(
rng
);
auto
m1
=
tg
::
mat1
();
m1
[
0
]
=
d1
*
uniform
(
rng
,
1.0
f
,
3.0
f
);
auto
d20
=
tg
::
uniform
<
tg
::
dir2
>
(
rng
);
auto
d21
=
perpendicular
(
d20
);
auto
m2
=
tg
::
mat2
();
...
...
@@ -81,59 +97,55 @@ TG_FUZZ_TEST_MAX_ITS(TypedGeometry, Project, 20)
m3
[
1
]
=
d31
*
uniform
(
rng
,
1.0
f
,
3.0
f
);
m3
[
2
]
=
d32
*
uniform
(
rng
,
1.0
f
,
3.0
f
);
// TODO: Adapt to new types
auto
m23
=
tg
::
mat2x3
();
m23
[
0
]
=
d30
*
uniform
(
rng
,
1.0
f
,
3.0
f
);
m23
[
1
]
=
d31
*
uniform
(
rng
,
1.0
f
,
3.0
f
);
// aabb
// TODO: And boundary
test_obj
(
p1
,
tg
::
aabb1
(
minPos1
,
maxPos1
));
test_obj
(
p2
,
tg
::
aabb2
(
minPos2
,
maxPos2
));
test_obj
(
p3
,
tg
::
aabb3
(
minPos3
,
maxPos3
));
test_obj
(
p4
,
tg
::
aabb4
(
minPos4
,
maxPos4
));
// ball
test_obj
(
p1
,
tg
::
sphere1
(
pos10
,
r
));
test_obj
(
p2
,
tg
::
sphere2
(
pos20
,
r
));
test_obj
(
p3
,
tg
::
sphere3
(
pos30
,
r
));
test_obj
(
p4
,
tg
::
sphere4
(
pos40
,
r
));
// box
// TODO: And boundary
test_obj
(
p1
,
tg
::
box1
(
pos10
,
m1
));
test_obj
(
p2
,
tg
::
box2
(
pos20
,
m2
));
test_obj
(
p3
,
tg
::
box3
(
pos30
,
m3
));
// TODO: box4
// test_obj(p3, tg::box2in3(pos30, m23)); // TODO: box2in3
// capsule
test_obj
(
p3
,
tg
::
capsule3
(
axis0
,
r
));
// circle
test_obj
(
p2
,
tg
::
sphere_boundary
<
2
,
float
,
2
>
(
pos20
,
r
));
test_obj
(
p3
,
tg
::
sphere_boundary
<
2
,
float
,
3
>
(
pos30
,
r
,
n3
));
test_obj_and_boundary
(
p3
,
tg
::
capsule3
(
axis0
,
r
));
// cone
// TODO: And boundary no caps
// test_obj(p3, tg::cone3(disk0, r)); // TODO: solid cone
test_obj
(
p3
,
tg
::
cone_boundary_no_caps
<
3
,
float
>
(
disk0
,
r
));
// cylinder
test_obj
(
p3
,
tg
::
cylinder3
(
axis0
,
r
));
// disk
test_obj
(
p2
,
tg
::
sphere2
(
pos20
,
r
));
test_obj
(
p3
,
tg
::
sphere2in3
(
pos30
,
r
,
n3
));
test_obj_and_boundary_no_caps
(
p3
,
tg
::
cylinder3
(
axis0
,
r
));
// hemisphere
//test_obj(p1, tg::hemisphere1(pos10, r, n1));
// TODO: And boundary no caps
// test_obj(p1, tg::hemisphere1(pos10, r, n1));
test_obj
(
p2
,
tg
::
hemisphere2
(
pos20
,
r
,
n2
));
test_obj
(
p3
,
tg
::
hemisphere3
(
pos30
,
r
,
n3
));
//test_obj(p4, tg::hemisphere4(pos40, r, n4));
//
test_obj(p4, tg::hemisphere4(pos40, r, n4));
// TODO: pyramid once implemented
//test_obj(p3, tg::pyramid3(rect0, r));
// TODO: rect once implemented
//test_obj(p2, tg::rect2(pos20, r, a));
//test_obj(p3, tg::rect3(pos30, r, n3, a));
// test_obj(p3, tg::pyramid3(rect0, r));
// segment
test_obj
(
p1
,
tg
::
segment1
(
pos10
,
pos11
));
test_obj
(
p2
,
tg
::
segment2
(
pos20
,
pos21
));
test_obj
(
p3
,
tg
::
segment3
(
pos30
,
pos31
));
test_obj
(
p4
,
tg
::
segment4
(
pos40
,
pos41
));
// sphere
test_obj
(
p1
,
tg
::
sphere1
(
pos10
,
r
));
test_obj
(
p2
,
tg
::
sphere2
(
pos20
,
r
));
test_obj
(
p3
,
tg
::
sphere3
(
pos30
,
r
));
test_obj
(
p4
,
tg
::
sphere4
(
pos40
,
r
));
test_obj_and_boundary
(
p1
,
tg
::
sphere1
(
pos10
,
r
));
test_obj_and_boundary
(
p2
,
tg
::
sphere2
(
pos20
,
r
));
test_obj_and_boundary
(
p3
,
tg
::
sphere3
(
pos30
,
r
));
test_obj_and_boundary
(
p4
,
tg
::
sphere4
(
pos40
,
r
));
test_obj_and_boundary
(
p3
,
tg
::
sphere2in3
(
pos30
,
r
,
n3
));
// triangle
test_obj
(
p2
,
tg
::
triangle2
(
pos20
,
pos21
,
pos22
));
test_obj
(
p3
,
tg
::
triangle3
(
pos30
,
pos31
,
pos32
));
//test_obj(p4, tg::triangle4(pos40, pos41, pos42));
// tube
test_obj
(
p3
,
tg
::
tube3
(
axis0
,
r
));
// test_obj(p4, tg::triangle4(pos40, pos41, pos42));
}
TG_FUZZ_TEST
(
TypedGeometry
,
ProjectObjects
)
...
...
tests/feature/random/uniform.cc
View file @
33801c9d
...
...
@@ -54,6 +54,17 @@ TG_FUZZ_TEST_MAX_ITS(TypedGeometry, UniformGeneralProperties, 100)
}
};
auto
const
test_obj_and_boundary
=
[
&
test_obj
](
auto
p
,
auto
o
)
{
test_obj
(
p
,
o
);
test_obj
(
p
,
boundary_of
(
o
));
};
auto
const
test_obj_and_boundary_no_caps
=
[
&
test_obj
](
auto
p
,
auto
o
)
{
test_obj
(
p
,
o
);
test_obj
(
p
,
boundary_of
(
o
));
test_obj
(
p
,
boundary_no_caps_of
(
o
));
};
auto
samples1
=
tg
::
array
<
tg
::
pos1
,
sampleSize
>
();
auto
samples2
=
tg
::
array
<
tg
::
pos2
,
sampleSize
>
();
...
...
@@ -95,55 +106,73 @@ TG_FUZZ_TEST_MAX_ITS(TypedGeometry, UniformGeneralProperties, 100)
const
auto
axis0
=
tg
::
segment3
(
pos30
,
pos31
);
const
auto
disk0
=
tg
::
sphere2in3
(
pos30
,
r
,
n3
);
auto
d1
=
tg
::
uniform
<
tg
::
dir1
>
(
rng
);
auto
m1
=
tg
::
mat1
();
m1
[
0
]
=
d1
*
uniform
(
rng
,
1.0
f
,
3.0
f
);
auto
d20
=
tg
::
uniform
<
tg
::
dir2
>
(
rng
);
auto
d21
=
perpendicular
(
d20
);
auto
m2
=
tg
::
mat2
();
m2
[
0
]
=
d20
*
uniform
(
rng
,
1.0
f
,
3.0
f
);
m2
[
1
]
=
d21
*
uniform
(
rng
,
1.0
f
,
3.0
f
);
auto
d30
=
tg
::
uniform
<
tg
::
dir3
>
(
rng
);
auto
d31
=
any_normal
(
d30
);
auto
d32
=
normalize
(
cross
(
d30
,
d31
));
auto
m3
=
tg
::
mat3
();
m3
[
0
]
=
d30
*
uniform
(
rng
,
1.0
f
,
3.0
f
);
m3
[
1
]
=
d31
*
uniform
(
rng
,
1.0
f
,
3.0
f
);
m3
[
2
]
=
d32
*
uniform
(
rng
,
1.0
f
,
3.0
f
);
auto
m23
=
tg
::
mat2x3
();
m23
[
0
]
=
d30
*
uniform
(
rng
,
1.0
f
,
3.0
f
);
m23
[
1
]
=
d31
*
uniform
(
rng
,
1.0
f
,
3.0
f
);
// aabb
// TODO: And boundary
test_obj
(
samples1
,
tg
::
aabb1
(
minPos1
,
maxPos1
));
test_obj
(
samples2
,
tg
::
aabb2
(
minPos2
,
maxPos2
));
test_obj
(
samples3
,
tg
::
aabb3
(
minPos3
,
maxPos3
));
test_obj
(
samples4
,
tg
::
aabb4
(
minPos4
,
maxPos4
));
// ball
test_obj
(
samples1
,
tg
::
sphere1
(
pos10
,
r
));
test_obj
(
samples2
,
tg
::
sphere2
(
pos20
,
r
));
test_obj
(
samples3
,
tg
::
sphere3
(
pos30
,
r
));
test_obj
(
samples4
,
tg
::
sphere4
(
pos40
,
r
));
// TODO: box once implemented
// box
// TODO: And boundary
test_obj
(
samples1
,
tg
::
box1
(
pos10
,
m1
));
test_obj
(
samples2
,
tg
::
box2
(
pos20
,
m2
));
test_obj
(
samples3
,
tg
::
box3
(
pos30
,
m3
));
// TODO: box4
// test_obj(samples3, tg::box2in3(pos30, m23)); // TODO: box2in3
// capsule
test_obj
(
samples3
,
tg
::
capsule3
(
axis0
,
r
));
// circle
test_obj
(
samples2
,
tg
::
sphere_boundary
<
2
,
float
,
2
>
(
pos20
,
r
));
test_obj
(
samples3
,
tg
::
sphere_boundary
<
2
,
float
,
3
>
(
pos30
,
r
,
n3
));
test_obj_and_boundary
(
samples3
,
tg
::
capsule3
(
axis0
,
r
));
// cone
// TODO: And boundary no caps
// test_obj(samples3, tg::cone3(disk0, r)); // TODO: solid cone
test_obj
(
samples3
,
tg
::
cone_boundary_no_caps
<
3
,
float
>
(
disk0
,
r
));
// cylinder
test_obj
(
samples3
,
tg
::
cylinder3
(
axis0
,
r
));
// disk
test_obj
(
samples2
,
tg
::
sphere
<
2
,
float
,
2
>
(
pos20
,
r
));
test_obj
(
samples3
,
tg
::
sphere2in3
(
pos30
,
r
,
n3
));
test_obj_and_boundary_no_caps
(
samples3
,
tg
::
cylinder3
(
axis0
,
r
));
// hemisphere
// TODO: And boundary no caps
//test_obj(samples1, tg::hemisphere1(pos10, r, n1));
test_obj
(
samples2
,
tg
::
hemisphere2
(
pos20
,
r
,
n2
));
test_obj
(
samples3
,
tg
::
hemisphere3
(
pos30
,
r
,
n3
));
//test_obj(samples4, tg::hemisphere4(pos40, r, n4));
// TODO: pyramid once implemented
// test_obj(samples3, tg::pyramid3(rect0, r));
// TODO: rect once implemented
// test_obj(samples2, tg::rect2(pos20, r, a));
// test_obj(samples3, tg::rect3(pos30, r, n3, a));
// segment
test_obj
(
samples1
,
tg
::
segment1
(
pos10
,
pos11
));
test_obj
(
samples2
,
tg
::
segment2
(
pos20
,
pos21
));
test_obj
(
samples3
,
tg
::
segment3
(
pos30
,
pos31
));
test_obj
(
samples4
,
tg
::
segment4
(
pos40
,
pos41
));
// sphere
// test_obj(samples1, tg::sphere1(pos10, r)); // sphere1 consists of only 2 points and therefore collisions in the samples are unavoidable
test_obj
(
samples2
,
tg
::
sphere2
(
pos20
,
r
));
test_obj
(
samples3
,
tg
::
sphere3
(
pos30
,
r
));
test_obj
(
samples4
,
tg
::
sphere4
(
pos40
,
r
));
test_obj
(
samples1
,
tg
::
sphere1
(
pos10
,
r
));
// sphere1_boundary consists of only 2 points and therefore collisions in the samples are unavoidable
test_obj_and_boundary
(
samples2
,
tg
::
sphere2
(
pos20
,
r
));
test_obj_and_boundary
(
samples3
,
tg
::
sphere3
(
pos30
,
r
));
test_obj_and_boundary
(
samples4
,
tg
::
sphere4
(
pos40
,
r
));
test_obj_and_boundary
(
samples3
,
tg
::
sphere2in3
(
pos30
,
r
,
n3
));
// triangle
test_obj
(
samples2
,
tg
::
triangle2
(
pos20
,
pos21
,
pos22
));
test_obj
(
samples3
,
tg
::
triangle3
(
pos30
,
pos31
,
pos32
));
// test_obj(samples4, tg::triangle4(pos40, pos41, pos42));
// tube
test_obj
(
samples3
,
tg
::
tube3
(
axis0
,
r
));
}
TG_FUZZ_TEST
(
TypedGeometry
,
UniformObjects
)
...
...
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