-
Notifications
You must be signed in to change notification settings - Fork 27
/
vecrep.jl
56 lines (55 loc) · 1.51 KB
/
vecrep.jl
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
function test_convexhull()
v = convexhull([1, 0, 0]) + conichull(Ray([0, 1, 0]), Line([0, 0, 1]))
@test npoints(v) == 1
@test nlines(v) == 1
@test nrays(v) == 1
ps = v.points
_ps = ps.points
rs = v.rays
_ls = rs.lines
__ls = _ls.lines
_rs = rs.rays
function _inplace()
@test v.points === ps
@test v.rays === rs
@test v.points.points === _ps
@test v.rays.lines === _ls
@test v.rays.lines.lines === __ls
@test v.rays.rays === _rs
end
convexhull!(v, [2, 0, 0])
_inplace()
@test npoints(v) == 2
@test nlines(v) == 1
@test nrays(v) == 1
convexhull!(v, Ray([0, 2, 0]))
_inplace()
@test npoints(v) == 2
@test nlines(v) == 1
@test nrays(v) == 2
convexhull!(v, Line([1, 0, 0]))
_inplace()
@test npoints(v) == 2
@test nlines(v) == 2
@test nrays(v) == 2
end
function test_intersect()
h = HalfSpace([1, 0], 1) ∩ HyperPlane([0, 1], 1)
@test nhyperplanes(h) == 1
@test nhalfspaces(h) == 1
hs = h.halfspaces
hp = h.hyperplanes
_hp = h.hyperplanes.hyperplanes
intersect!(h, HalfSpace([1, 1], 2))
@test h.halfspaces === hs
@test h.hyperplanes === hp
@test h.hyperplanes.hyperplanes === _hp
@test nhyperplanes(h) == 1
@test nhalfspaces(h) == 2
intersect!(h, HyperPlane([1, 1], 3))
@test h.halfspaces === hs
@test h.hyperplanes === hp
@test h.hyperplanes.hyperplanes === _hp
@test nhyperplanes(h) == 2
@test nhalfspaces(h) == 2
end