mageo 0.0.0 → 0.0.1
Sign up to get free protection for your applications and to get access to all the features.
- data/CHANGES +9 -0
- data/Gemfile +5 -4
- data/VERSION +1 -1
- data/lib/mageo/axes.rb +77 -78
- data/lib/mageo/cylinder.rb +10 -11
- data/lib/mageo/octahedron.rb +48 -49
- data/lib/mageo/polar2d.rb +78 -79
- data/lib/mageo/polar3d.rb +33 -34
- data/lib/mageo/polyhedron.rb +60 -61
- data/lib/mageo/segment.rb +73 -74
- data/lib/mageo/sphere.rb +6 -7
- data/lib/mageo/tetrahedron.rb +26 -27
- data/lib/mageo/triangle.rb +208 -209
- data/lib/mageo/vector.rb +13 -14
- data/lib/mageo/vector3d.rb +212 -213
- data/lib/mageo/vector3dinternal.rb +107 -108
- data/mageo.gemspec +19 -15
- data/test/test_axes.rb +198 -199
- data/test/test_cylinder.rb +8 -9
- data/test/test_octahedron.rb +140 -142
- data/test/test_polar2d.rb +136 -137
- data/test/test_polar3d.rb +61 -63
- data/test/test_polyhedron.rb +3 -3
- data/test/test_segment.rb +71 -72
- data/test/test_sphere.rb +7 -8
- data/test/test_tetrahedron.rb +115 -117
- data/test/test_triangle.rb +244 -245
- data/test/test_vector.rb +53 -54
- data/test/test_vector3d.rb +409 -411
- data/test/test_vector3dinternal.rb +133 -134
- metadata +34 -52
data/test/test_polar3d.rb
CHANGED
@@ -7,89 +7,87 @@ require "mageo/polar3d.rb"
|
|
7
7
|
require "mageo/vector3d.rb"
|
8
8
|
|
9
9
|
class TC_Polar3D < Test::Unit::TestCase
|
10
|
-
|
10
|
+
$tolerance = 10**(-10)
|
11
11
|
|
12
|
-
|
12
|
+
include Math
|
13
13
|
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
14
|
+
def setup
|
15
|
+
@p3d00 = Polar3D.new( 0.0, 0.00*PI, 0.00*PI)
|
16
|
+
@p3d01 = Polar3D.new( 2.0, 0.00*PI, 0.25*PI)
|
17
|
+
@p3d02 = Polar3D.new( 2.0, 0.25*PI, 0.00*PI)
|
18
|
+
@p3d03 = Polar3D.new( 2.0, 0.25*PI, 0.25*PI)
|
19
|
+
end
|
20
20
|
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
21
|
+
def test_to_v3d
|
22
|
+
assert_equal( Vector3D, @p3d00.to_v3d.class )
|
23
|
+
assert_in_delta( 0.0, @p3d00.to_v3d[0], $tolerance )
|
24
|
+
assert_in_delta( 0.0, @p3d00.to_v3d[1], $tolerance )
|
25
|
+
assert_in_delta( 0.0, @p3d00.to_v3d[2], $tolerance )
|
26
26
|
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
27
|
+
assert_equal( Vector3D, @p3d01.to_v3d.class )
|
28
|
+
assert_in_delta( 0.0, @p3d01.to_v3d[0], $tolerance )
|
29
|
+
assert_in_delta( 0.0, @p3d01.to_v3d[1], $tolerance )
|
30
|
+
assert_in_delta( 2.0, @p3d01.to_v3d[2], $tolerance )
|
31
31
|
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
32
|
+
assert_equal( Vector3D, @p3d02.to_v3d.class )
|
33
|
+
assert_in_delta( Math::sqrt(2.0), @p3d02.to_v3d[0], $tolerance )
|
34
|
+
assert_in_delta( 0.0 , @p3d02.to_v3d[1], $tolerance )
|
35
|
+
assert_in_delta( Math::sqrt(2.0), @p3d02.to_v3d[2], $tolerance )
|
36
36
|
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
37
|
+
assert_equal( Vector3D, @p3d03.to_v3d.class )
|
38
|
+
#√2 * cos(0.25PI)
|
39
|
+
assert_in_delta( 1.0 , @p3d03.to_v3d[0], $tolerance)
|
40
|
+
assert_in_delta( 1.0 , @p3d03.to_v3d[1], $tolerance)
|
41
|
+
assert_in_delta( Math::sqrt(2.0), @p3d03.to_v3d[2], $tolerance )
|
42
42
|
|
43
|
-
|
43
|
+
end
|
44
44
|
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
45
|
+
def test_minimize_phi!
|
46
|
+
p2pA = Polar3D.new( 2.0, 0.5*PI, -2.5*PI )
|
47
|
+
p2pA.minimize_phi!
|
48
|
+
assert_in_delta( 1.5*PI, p2pA.phi, $tolerance )
|
49
49
|
|
50
|
-
|
51
|
-
|
52
|
-
|
50
|
+
p2pB = Polar3D.new( 2.0, 0.5*PI, -0.5*PI )
|
51
|
+
p2pB.minimize_phi!
|
52
|
+
assert_in_delta( 1.5*PI, p2pB.phi, $tolerance )
|
53
53
|
|
54
|
-
|
55
|
-
|
56
|
-
|
54
|
+
p2pC = Polar3D.new( 2.0, 0.5*PI, 1.5*PI )
|
55
|
+
p2pC.minimize_phi!
|
56
|
+
assert_in_delta( 1.5*PI, p2pC.phi, $tolerance )
|
57
57
|
|
58
|
-
|
59
|
-
|
60
|
-
|
58
|
+
p2pD = Polar3D.new( 2.0, 0.5*PI, 3.5*PI )
|
59
|
+
p2pD.minimize_phi!
|
60
|
+
assert_in_delta( 1.5*PI, p2pD.phi, $tolerance )
|
61
61
|
|
62
|
-
|
63
|
-
|
64
|
-
|
62
|
+
p2pE = Polar3D.new( 2.0, 0.5*PI, 5.5*PI )
|
63
|
+
p2pE.minimize_phi!
|
64
|
+
assert_in_delta( 1.5*PI, p2pE.phi, $tolerance )
|
65
65
|
|
66
|
-
|
67
|
-
|
68
|
-
|
66
|
+
p2pF = Polar3D.new( 2.0, 0.5*PI, 4.5*PI )
|
67
|
+
p2pF.minimize_phi!
|
68
|
+
assert_in_delta( 0.5*PI, p2pF.phi, $tolerance )
|
69
69
|
|
70
|
-
|
70
|
+
end
|
71
71
|
|
72
|
-
|
73
|
-
|
74
|
-
|
72
|
+
def test_minimize_phi
|
73
|
+
p2pA = Polar3D.new( 2.0, 0.5*PI, -2.5*PI ).minimize_phi
|
74
|
+
assert_in_delta( 1.5*PI, p2pA.phi, $tolerance )
|
75
75
|
|
76
|
-
|
77
|
-
|
76
|
+
p2pB = Polar3D.new( 2.0, 0.5*PI, -0.5*PI ).minimize_phi
|
77
|
+
assert_in_delta( 1.5*PI, p2pB.phi, $tolerance )
|
78
78
|
|
79
|
-
|
80
|
-
|
79
|
+
p2pC = Polar3D.new( 2.0, 0.5*PI, 1.5*PI ).minimize_phi
|
80
|
+
assert_in_delta( 1.5*PI, p2pC.phi, $tolerance )
|
81
81
|
|
82
|
-
|
83
|
-
|
82
|
+
p2pD = Polar3D.new( 2.0, 0.5*PI, 3.5*PI ).minimize_phi
|
83
|
+
assert_in_delta( 1.5*PI, p2pD.phi, $tolerance )
|
84
84
|
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
p2pF = Polar3D.new( 2.0, 0.5*PI, 4.5*PI ).minimize_phi
|
89
|
-
assert_in_delta( 0.5*PI, p2pF.phi, $tolerance )
|
90
|
-
|
91
|
-
end
|
85
|
+
p2pE = Polar3D.new( 2.0, 0.5*PI, 5.5*PI ).minimize_phi
|
86
|
+
assert_in_delta( 1.5*PI, p2pE.phi, $tolerance )
|
92
87
|
|
88
|
+
p2pF = Polar3D.new( 2.0, 0.5*PI, 4.5*PI ).minimize_phi
|
89
|
+
assert_in_delta( 0.5*PI, p2pF.phi, $tolerance )
|
93
90
|
|
91
|
+
end
|
94
92
|
end
|
95
93
|
|
data/test/test_polyhedron.rb
CHANGED
@@ -8,7 +8,7 @@ require "mageo/polyhedron.rb"
|
|
8
8
|
# initialize でインスタンスを生成できないことのみテストする。
|
9
9
|
# その他の機能はサブクラスでテスト。
|
10
10
|
class TC_Polyhedron < Test::Unit::TestCase
|
11
|
-
|
12
|
-
|
13
|
-
|
11
|
+
def test_initialize
|
12
|
+
assert_raise( NotImplementedError ) { Polyhedron.new }
|
13
|
+
end
|
14
14
|
end
|
data/test/test_segment.rb
CHANGED
@@ -6,77 +6,76 @@ require "helper"
|
|
6
6
|
require "mageo/segment.rb"
|
7
7
|
|
8
8
|
class TC_Segment < Test::Unit::TestCase
|
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
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
|
9
|
+
$tolerance = 1.0 * 10.0 ** (-10)
|
10
|
+
|
11
|
+
VEC_00 = Vector3D[1.0, 2.0, 3.0]
|
12
|
+
VEC_01 = Vector3D[4.0, 6.0, 8.0]
|
13
|
+
|
14
|
+
VEC_10 = Vector3D[0.0, 0.0, 1.0]
|
15
|
+
VEC_11 = Vector3D[0.0, 0.0, 3.0]
|
16
|
+
|
17
|
+
VEC_20 = Vector3D[1.0, 1.0, 1.0]
|
18
|
+
VEC_21 = Vector3D[0.0, 0.0, 0.0]
|
19
|
+
def setup
|
20
|
+
@s00 = Segment.new(VEC_00, VEC_01)
|
21
|
+
@s01 = Segment.new(VEC_10, VEC_11)
|
22
|
+
@s02 = Segment.new(VEC_20, VEC_21)
|
23
|
+
end
|
24
|
+
|
25
|
+
def test_initialize
|
26
|
+
vec00 = [1.0, 2.0, 3.0]
|
27
|
+
vec01 = [4.0, 6.0, 8.0]
|
28
|
+
assert_raise(Segment::InitializeError){
|
29
|
+
Segment.new(vec00, vec01)
|
30
|
+
}
|
31
|
+
assert_raise(Segment::InitializeError){
|
32
|
+
Segment.new(VEC_00, VEC_00)
|
33
|
+
}
|
34
|
+
end
|
35
|
+
|
36
|
+
def test_endpoints
|
37
|
+
assert_equal(VEC_00, @s00.endpoints[0])
|
38
|
+
assert_equal(VEC_01, @s00.endpoints[1])
|
39
|
+
end
|
40
|
+
|
41
|
+
def test_include?
|
42
|
+
assert_raise(Segment::TypeError){
|
43
|
+
@s02.include?([0.0, 0.0, 0.0], $tolerance)
|
44
|
+
}
|
45
|
+
|
46
|
+
#直線上
|
47
|
+
assert_equal(false, @s02.include?(Vector3D[-1.0,-1.0,-1.0], $tolerance))
|
48
|
+
assert_equal(true , @s02.include?(Vector3D[ 0.0, 0.0, 0.0], $tolerance))
|
49
|
+
assert_equal(true , @s02.include?(Vector3D[ 0.3, 0.3, 0.3], $tolerance))
|
50
|
+
assert_equal(true , @s02.include?(Vector3D[ 1.0, 1.0, 1.0], $tolerance))
|
51
|
+
assert_equal(false, @s02.include?(Vector3D[ 2.0, 2.0, 2.0], $tolerance))
|
52
|
+
|
53
|
+
#横に出てる
|
54
|
+
assert_equal(false, @s02.include?(Vector3D[0.1, 0.1, 0.2], $tolerance))
|
55
|
+
assert_equal(true , @s02.include?(Vector3D[0.1, 0.1, 0.2], 1.0))
|
56
|
+
end
|
57
|
+
|
58
|
+
def test_to_v3d
|
59
|
+
assert_equal(Vector3D[ 3.0, 4.0, 5.0], @s00.to_v3d)
|
60
|
+
assert_equal(Vector3D[ 0.0, 0.0, 2.0], @s01.to_v3d)
|
61
|
+
assert_equal(Vector3D[-1.0,-1.0,-1.0], @s02.to_v3d)
|
62
|
+
end
|
63
|
+
|
64
|
+
def test_eql?
|
65
|
+
assert_raise(Segment::TypeError){ @s00.eql?([[0,0,0],[1,1,1]])}
|
66
|
+
|
67
|
+
assert_equal(true , @s00.eql?(Segment.new(VEC_01, VEC_00)))
|
68
|
+
assert_equal(false, @s00.eql?(@s01))
|
69
|
+
end
|
70
|
+
|
71
|
+
def test_equal2
|
72
|
+
assert_raise(Segment::TypeError){ @s00.eql?([[0,0,0],[1,1,1]])}
|
73
|
+
|
74
|
+
assert_equal(true , @s00 == Segment.new(VEC_00, VEC_01))
|
75
|
+
assert_equal(false, @s00 == Segment.new(VEC_01, VEC_00))
|
76
|
+
assert_equal(false, @s00 == @s01)
|
77
|
+
end
|
78
|
+
|
79
|
+
#undef test_include?
|
81
80
|
end
|
82
81
|
|
data/test/test_sphere.rb
CHANGED
@@ -7,14 +7,13 @@ require "mageo/sphere.rb"
|
|
7
7
|
require "mageo/vector3d.rb"
|
8
8
|
|
9
9
|
class TC_Sphere < Test::Unit::TestCase
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
def test_initialize
|
15
|
-
assert_equal(Vector3D[0.0, 1.0, 2.0], @s00.position)
|
16
|
-
assert_equal(3.0, @s00.radius)
|
17
|
-
end
|
10
|
+
def setup
|
11
|
+
@s00 = Sphere.new([0.0, 1.0, 2.0], 3.0)
|
12
|
+
end
|
18
13
|
|
14
|
+
def test_initialize
|
15
|
+
assert_equal(Vector3D[0.0, 1.0, 2.0], @s00.position)
|
16
|
+
assert_equal(3.0, @s00.radius)
|
17
|
+
end
|
19
18
|
end
|
20
19
|
|
data/test/test_tetrahedron.rb
CHANGED
@@ -8,125 +8,123 @@ require "array_include_eql.rb"
|
|
8
8
|
require "mageo/tetrahedron.rb"
|
9
9
|
|
10
10
|
class Tetrahedron
|
11
|
-
|
11
|
+
public :center
|
12
12
|
end
|
13
13
|
|
14
14
|
class TC_Tetrahedron < Test::Unit::TestCase
|
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
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
|
92
|
-
|
93
|
-
|
94
|
-
|
95
|
-
|
96
|
-
|
97
|
-
|
98
|
-
|
99
|
-
|
100
|
-
|
101
|
-
|
102
|
-
|
103
|
-
|
104
|
-
|
105
|
-
|
106
|
-
|
107
|
-
|
108
|
-
|
109
|
-
|
110
|
-
|
111
|
-
|
112
|
-
|
113
|
-
|
114
|
-
|
115
|
-
|
116
|
-
|
117
|
-
|
118
|
-
|
119
|
-
|
120
|
-
|
121
|
-
|
122
|
-
|
123
|
-
|
124
|
-
|
125
|
-
|
126
|
-
|
127
|
-
|
128
|
-
|
129
|
-
|
130
|
-
|
15
|
+
$tolerance = 10**(-10)
|
16
|
+
|
17
|
+
V_00 = Vector3D[ 0.0, 0.0, 0.0]
|
18
|
+
V_01 = Vector3D[10.0, 0.0, 0.0]
|
19
|
+
V_02 = Vector3D[ 0.0,10.0, 0.0]
|
20
|
+
V_03 = Vector3D[ 0.0, 0.0,10.0]
|
21
|
+
|
22
|
+
V_10 = Vector3D[10.0,20.0,30.0]
|
23
|
+
V_11 = Vector3D[ 0.0,20.0,30.0]
|
24
|
+
V_12 = Vector3D[10.0, 0.0,30.0]
|
25
|
+
V_13 = Vector3D[10.0,20.0, 0.0]
|
26
|
+
|
27
|
+
def setup
|
28
|
+
@t00 = Tetrahedron.new( [ V_00, V_01, V_02, V_03 ])
|
29
|
+
@t01 = Tetrahedron.new( [ V_10, V_11, V_12, V_13 ])
|
30
|
+
end
|
31
|
+
|
32
|
+
def test_initialize
|
33
|
+
assert_raise( ArgumentError ){ Tetrahedron.new }
|
34
|
+
assert_raise( ArgumentError ){ Tetrahedron.new() }
|
35
|
+
assert_raise( Tetrahedron::InitializeError ){ Tetrahedron.new( nil ) }
|
36
|
+
assert_raise( Tetrahedron::InitializeError ){ Tetrahedron.new( [] ) }
|
37
|
+
assert_raise( Tetrahedron::InitializeError ){ Tetrahedron.new( [ 0, 1, 2, 3 ] ) }
|
38
|
+
assert_raise( Tetrahedron::InitializeError ){ Tetrahedron.new( [ [], [], [], [] ] ) }
|
39
|
+
assert_raise( Tetrahedron::InitializeError ){
|
40
|
+
Tetrahedron.new( [ V_00, V_01, V_02, [ 0.0, 0.0 ] ])
|
41
|
+
}
|
42
|
+
assert_raise( Tetrahedron::InitializeError ){
|
43
|
+
Tetrahedron.new( [ V_00, V_01, V_02, [ 0.0, 0.0, 1.0, 0.0 ] ])
|
44
|
+
}
|
45
|
+
|
46
|
+
# 5点ある
|
47
|
+
assert_raise( Tetrahedron::InitializeError ){
|
48
|
+
Tetrahedron.new( [ V_00, V_01, V_02, V_03, [ 1.0, 1.0, 1.0] ])
|
49
|
+
}
|
50
|
+
|
51
|
+
# 体積が 0.0 になるのはエラー
|
52
|
+
assert_raise( Tetrahedron::InitializeError ){
|
53
|
+
Tetrahedron.new( [ V_00, V_01, V_02, [ 2.0, 2.0, 0.0] ])
|
54
|
+
}
|
55
|
+
|
56
|
+
# Vector3DInternal なら 例外
|
57
|
+
assert_raise( Tetrahedron::InitializeError ){
|
58
|
+
Tetrahedron.new(
|
59
|
+
[ Vector3DInternal[ 0.0, 0.0, 0.0],
|
60
|
+
Vector3DInternal[ 1.0, 0.0, 0.0],
|
61
|
+
Vector3DInternal[ 0.0, 1.0, 0.0],
|
62
|
+
Vector3DInternal[ 0.0, 0.0, 1.0]
|
63
|
+
]
|
64
|
+
)
|
65
|
+
}
|
66
|
+
|
67
|
+
# Vector3D なら OK
|
68
|
+
assert_nothing_raised{
|
69
|
+
Tetrahedron.new( [ V_00, V_01, V_02, V_03 ])
|
70
|
+
}
|
71
|
+
end
|
72
|
+
|
73
|
+
def test_inside?
|
74
|
+
assert_equal( true , @t00.inside?( [ 1.0, 1.0, 1.0] ) )
|
75
|
+
assert_equal( false, @t00.inside?( [ 5.0, 5.0, 5.0] ) )
|
76
|
+
assert_equal( false, @t00.inside?( [-5.0,-5.0,-5.0] ) )
|
77
|
+
assert_equal( false, @t00.inside?( [ 0.0, 0.0, 0.0] ) ) #頂点上
|
78
|
+
|
79
|
+
assert_raise(Polyhedron::TypeError){@t00.inside?(Vector3DInternal[1.0, 1.0, 1.0])}
|
80
|
+
assert_raise(Tetrahedron::TypeError){@t00.inside?(Vector3DInternal[1.0, 1.0, 1.0])}
|
81
|
+
#pp Polyhedron::TypeError.ancestors
|
82
|
+
#pp Tetrahedron::TypeError.ancestors
|
83
|
+
end
|
84
|
+
|
85
|
+
def test_include?
|
86
|
+
assert_equal( true , @t00.include?([ 1.0, 1.0, 1.0], $tolerance))
|
87
|
+
assert_equal( false, @t00.include?([ 5.0, 5.0, 5.0], $tolerance))
|
88
|
+
assert_equal( false, @t00.include?([-5.0,-5.0,-5.0], $tolerance))
|
89
|
+
assert_equal( true , @t00.include?([ 0.0, 0.0, 0.0], $tolerance)) #頂点上
|
90
|
+
|
91
|
+
assert_equal( false, @t01.include?(Vector3D[ 3.0, 6.0, 30.0], $tolerance))
|
92
|
+
|
93
|
+
assert_raise(Polyhedron::TypeError){@t00.include?(Vector3DInternal[1.0, 1.0, 1.0], $tolerance)}
|
94
|
+
end
|
95
|
+
|
96
|
+
def test_volume
|
97
|
+
assert_in_delta( 1000.0/6.0 , @t00.volume, $tolerance )
|
98
|
+
end
|
99
|
+
|
100
|
+
def test_center
|
101
|
+
assert_in_delta( 10.0/4.0, @t00.center[0], $tolerance)
|
102
|
+
assert_in_delta( 10.0/4.0, @t00.center[1], $tolerance)
|
103
|
+
assert_in_delta( 10.0/4.0, @t00.center[2], $tolerance)
|
104
|
+
end
|
105
|
+
|
106
|
+
def test_vertices
|
107
|
+
assert_equal( [ V_00, V_01, V_02, V_03 ], @t00.vertices)
|
108
|
+
end
|
109
|
+
|
110
|
+
def test_triangles
|
111
|
+
t = @t00.triangles
|
112
|
+
assert_equal(4, t.size)
|
113
|
+
assert_equal(Triangle.new([V_00, V_01, V_02]) ,t[0])
|
114
|
+
assert_equal(Triangle.new([V_01, V_02, V_03]) ,t[1])
|
115
|
+
assert_equal(Triangle.new([V_02, V_03, V_00]) ,t[2])
|
116
|
+
assert_equal(Triangle.new([V_03, V_00, V_01]) ,t[3])
|
117
|
+
end
|
118
|
+
|
119
|
+
def test_edges
|
120
|
+
t = @t00.edges
|
121
|
+
assert_equal(6, t.size)
|
122
|
+
assert_equal(true, (t.include_eql?(Segment.new(V_00, V_01))))
|
123
|
+
assert_equal(true, (t.include_eql?(Segment.new(V_00, V_02))))
|
124
|
+
assert_equal(true, (t.include_eql?(Segment.new(V_00, V_03))))
|
125
|
+
assert_equal(true, (t.include_eql?(Segment.new(V_01, V_02))))
|
126
|
+
assert_equal(true, (t.include_eql?(Segment.new(V_01, V_03))))
|
127
|
+
assert_equal(true, (t.include_eql?(Segment.new(V_02, V_03))))
|
128
|
+
end
|
131
129
|
end
|
132
130
|
|