mageo 0.0.0 → 0.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- 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_cylinder.rb
CHANGED
@@ -7,15 +7,14 @@ require "mageo/cylinder.rb"
|
|
7
7
|
require "mageo/vector3d.rb"
|
8
8
|
|
9
9
|
class TC_Cylinder < Test::Unit::TestCase
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
def test_initialize
|
15
|
-
assert_equal(Vector3D[0.0, 1.0, 2.0], @c00.positions[0])
|
16
|
-
assert_equal(Vector3D[1.0, 2.0, 3.0], @c00.positions[1])
|
17
|
-
assert_equal(3.0, @c00.radius)
|
18
|
-
end
|
10
|
+
def setup
|
11
|
+
@c00 = Cylinder.new([[0.0, 1.0, 2.0], [1.0, 2.0, 3.0]], 3.0)
|
12
|
+
end
|
19
13
|
|
14
|
+
def test_initialize
|
15
|
+
assert_equal(Vector3D[0.0, 1.0, 2.0], @c00.positions[0])
|
16
|
+
assert_equal(Vector3D[1.0, 2.0, 3.0], @c00.positions[1])
|
17
|
+
assert_equal(3.0, @c00.radius)
|
18
|
+
end
|
20
19
|
end
|
21
20
|
|
data/test/test_octahedron.rb
CHANGED
@@ -8,150 +8,148 @@ gem "builtinextension"
|
|
8
8
|
require "array_include_eql.rb"
|
9
9
|
|
10
10
|
class Octahedron
|
11
|
-
|
11
|
+
public :center
|
12
12
|
end
|
13
13
|
|
14
14
|
class TC_Octahedron < 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
|
-
|
131
|
-
|
132
|
-
|
133
|
-
|
134
|
-
|
135
|
-
|
136
|
-
|
137
|
-
|
138
|
-
|
139
|
-
|
140
|
-
|
141
|
-
|
142
|
-
|
143
|
-
|
144
|
-
|
145
|
-
|
146
|
-
|
147
|
-
|
148
|
-
|
149
|
-
|
150
|
-
|
151
|
-
|
152
|
-
|
153
|
-
|
154
|
-
|
155
|
-
|
15
|
+
$tolerance = 10**(-10)
|
16
|
+
|
17
|
+
V_X_PLUS = Vector3D[ 1, 0, 0 ]
|
18
|
+
V_Y_PLUS = Vector3D[ 0, 1, 0 ]
|
19
|
+
V_Z_PLUS = Vector3D[ 0, 0, 1 ]
|
20
|
+
|
21
|
+
V_X_MINUS = Vector3D[ -1, 0, 0 ]
|
22
|
+
V_Y_MINUS = Vector3D[ 0, -1, 0 ]
|
23
|
+
V_Z_MINUS = Vector3D[ 0, 0, -1 ]
|
24
|
+
|
25
|
+
def setup
|
26
|
+
@o00 = Octahedron.new(
|
27
|
+
[ [V_X_MINUS, V_X_PLUS ],
|
28
|
+
[V_Y_MINUS, V_Y_PLUS ],
|
29
|
+
[V_Z_MINUS, V_Z_PLUS ] ]
|
30
|
+
)
|
31
|
+
@o01 = Octahedron.new(
|
32
|
+
[ [ [ -0.5, 0.5, 0.5 ], [ 1.5, 0.5, 0.5 ] ],
|
33
|
+
[ [ 0.5, -0.5, 0.5 ], [ 0.5, 1.5, 0.5 ] ],
|
34
|
+
[ [ 0.5, 0.5, -0.5 ], [ 0.5, 0.5, 1.5 ] ] ]
|
35
|
+
)
|
36
|
+
end
|
37
|
+
|
38
|
+
def test_initialize
|
39
|
+
assert_raise( ArgumentError ){ Octahedron.new }
|
40
|
+
assert_raise( ArgumentError ){ Octahedron.new() }
|
41
|
+
assert_raise( Octahedron::InitializeError ){ Octahedron.new( nil ) }
|
42
|
+
assert_raise( Octahedron::InitializeError ){ Octahedron.new( [] ) }
|
43
|
+
assert_raise( Octahedron::InitializeError ){ Octahedron.new( [ 0, 1, 2 ] ) }
|
44
|
+
assert_raise( Octahedron::InitializeError ){ Octahedron.new( [ [], [], [] ] ) }
|
45
|
+
assert_raise( Octahedron::InitializeError ){
|
46
|
+
Octahedron.new(
|
47
|
+
[ [ V_X_MINUS, V_X_PLUS ],
|
48
|
+
[ V_Y_MINUS, V_Y_PLUS ],
|
49
|
+
[ V_Z_MINUS, [ 0, 0 ] ]
|
50
|
+
]
|
51
|
+
)
|
52
|
+
}
|
53
|
+
assert_raise( Octahedron::InitializeError ){
|
54
|
+
Octahedron.new(
|
55
|
+
[ [ V_X_MINUS, V_X_PLUS],
|
56
|
+
[ V_Y_MINUS, [ 0, 1, 0, 2 ] ],
|
57
|
+
[ V_Z_MINUS, V_Z_PLUS ]
|
58
|
+
]
|
59
|
+
)
|
60
|
+
}
|
61
|
+
assert_raise( Octahedron::InitializeError ){
|
62
|
+
Octahedron.new(
|
63
|
+
[ [ V_X_MINUS, V_X_PLUS ],
|
64
|
+
[ V_Y_MINUS, V_Y_PLUS ],
|
65
|
+
[ V_Z_MINUS, V_Z_PLUS ],
|
66
|
+
[ [ -5, -5, -5 ], [ 5, 5, 5 ] ]
|
67
|
+
]
|
68
|
+
)
|
69
|
+
}
|
70
|
+
|
71
|
+
assert_raise( Octahedron::InitializeError ){
|
72
|
+
Octahedron.new(
|
73
|
+
[ [ Vector3DInternal[ -0.5, 0.5, 0.5 ], Vector3DInternal[ 1.5, 0.5, 0.5 ] ],
|
74
|
+
[ Vector3DInternal[ 0.5, -0.5, 0.5 ], Vector3DInternal[ 0.5, 1.5, 0.5 ] ],
|
75
|
+
[ Vector3DInternal[ 0.5, 0.5, -0.5 ], Vector3DInternal[ 0.5, 0.5, 1.5 ] ] ]
|
76
|
+
)
|
77
|
+
}
|
78
|
+
|
79
|
+
assert_nothing_raised{
|
80
|
+
Octahedron.new(
|
81
|
+
[ [ Vector3D[ -0.5, 0.5, 0.5 ], Vector3D[ 1.5, 0.5, 0.5 ] ],
|
82
|
+
[ Vector3D[ 0.5, -0.5, 0.5 ], Vector3D[ 0.5, 1.5, 0.5 ] ],
|
83
|
+
[ Vector3D[ 0.5, 0.5, -0.5 ], Vector3D[ 0.5, 0.5, 1.5 ] ] ]
|
84
|
+
)
|
85
|
+
}
|
86
|
+
end
|
87
|
+
|
88
|
+
def test_inside?
|
89
|
+
assert_equal( true , @o00.inside?( [0.0, 0.2, 0.4] ) )
|
90
|
+
assert_equal( false, @o00.inside?( [1.0, 0.0, 0.0] ) ) #境界上
|
91
|
+
assert_equal( false, @o00.inside?( [2.0, 0.2, 0.4] ) )
|
92
|
+
end
|
93
|
+
|
94
|
+
def test_include?
|
95
|
+
assert_equal( true , @o00.include?( [0.0, 0.2, 0.4], $tolerance ) )
|
96
|
+
assert_equal( true , @o00.include?( [1.0, 0.0, 0.0], $tolerance ) ) #境界上
|
97
|
+
assert_equal( false, @o00.include?( [2.0, 0.2, 0.4], $tolerance ) )
|
98
|
+
end
|
99
|
+
|
100
|
+
def test_volume
|
101
|
+
assert_in_delta( 8.0/6.0 , @o00.volume, $tolerance )
|
102
|
+
end
|
103
|
+
|
104
|
+
def test_center
|
105
|
+
assert_in_delta( 0.0, @o00.center[0], $tolerance)
|
106
|
+
assert_in_delta( 0.0, @o00.center[1], $tolerance)
|
107
|
+
assert_in_delta( 0.0, @o00.center[2], $tolerance)
|
108
|
+
|
109
|
+
assert_in_delta( 0.5, @o01.center[0], $tolerance)
|
110
|
+
assert_in_delta( 0.5, @o01.center[1], $tolerance)
|
111
|
+
assert_in_delta( 0.5, @o01.center[2], $tolerance)
|
112
|
+
end
|
113
|
+
|
114
|
+
def test_vertices
|
115
|
+
t = @o00.vertices
|
116
|
+
assert_equal(6, t.size)
|
117
|
+
assert_equal(true , t.include_eql?(V_X_MINUS))
|
118
|
+
assert_equal(true , t.include_eql?(V_X_PLUS ))
|
119
|
+
assert_equal(true , t.include_eql?(V_Y_MINUS))
|
120
|
+
assert_equal(true , t.include_eql?(V_Y_PLUS ))
|
121
|
+
assert_equal(true , t.include_eql?(V_Z_MINUS))
|
122
|
+
assert_equal(true , t.include_eql?(V_Z_PLUS ))
|
123
|
+
end
|
124
|
+
|
125
|
+
def test_triangles
|
126
|
+
t = @o00.triangles
|
127
|
+
assert_equal(8, t.size)
|
128
|
+
assert_equal(true, t.include_eql?(Triangle.new([V_X_PLUS, V_Y_PLUS, V_Z_PLUS])))
|
129
|
+
assert_equal(true, t.include_eql?(Triangle.new([V_X_PLUS, V_Y_PLUS, V_Z_MINUS])))
|
130
|
+
assert_equal(true, t.include_eql?(Triangle.new([V_X_PLUS, V_Y_MINUS, V_Z_PLUS])))
|
131
|
+
assert_equal(true, t.include_eql?(Triangle.new([V_X_PLUS, V_Y_MINUS, V_Z_MINUS])))
|
132
|
+
assert_equal(true, t.include_eql?(Triangle.new([V_X_MINUS, V_Y_PLUS, V_Z_PLUS])))
|
133
|
+
assert_equal(true, t.include_eql?(Triangle.new([V_X_MINUS, V_Y_PLUS, V_Z_MINUS])))
|
134
|
+
assert_equal(true, t.include_eql?(Triangle.new([V_X_MINUS, V_Y_MINUS, V_Z_PLUS])))
|
135
|
+
assert_equal(true, t.include_eql?(Triangle.new([V_X_MINUS, V_Y_MINUS, V_Z_MINUS])))
|
136
|
+
end
|
137
|
+
|
138
|
+
def test_edges
|
139
|
+
t = @o00.edges
|
140
|
+
assert_equal(12, t.size)
|
141
|
+
assert_equal(true, (t.include_eql?(Segment.new(V_X_PLUS , V_Y_PLUS))))
|
142
|
+
assert_equal(true, (t.include_eql?(Segment.new(V_X_PLUS , V_Y_MINUS))))
|
143
|
+
assert_equal(true, (t.include_eql?(Segment.new(V_X_PLUS , V_Z_PLUS))))
|
144
|
+
assert_equal(true, (t.include_eql?(Segment.new(V_X_PLUS , V_Z_MINUS))))
|
145
|
+
assert_equal(true, (t.include_eql?(Segment.new(V_X_MINUS, V_Y_PLUS))))
|
146
|
+
assert_equal(true, (t.include_eql?(Segment.new(V_X_MINUS, V_Y_MINUS))))
|
147
|
+
assert_equal(true, (t.include_eql?(Segment.new(V_X_MINUS, V_Z_PLUS))))
|
148
|
+
assert_equal(true, (t.include_eql?(Segment.new(V_X_MINUS, V_Z_MINUS))))
|
149
|
+
assert_equal(true, (t.include_eql?(Segment.new(V_Y_PLUS , V_Z_PLUS))))
|
150
|
+
assert_equal(true, (t.include_eql?(Segment.new(V_Y_PLUS , V_Z_MINUS))))
|
151
|
+
assert_equal(true, (t.include_eql?(Segment.new(V_Y_MINUS, V_Z_PLUS))))
|
152
|
+
assert_equal(true, (t.include_eql?(Segment.new(V_Y_MINUS, V_Z_MINUS))))
|
153
|
+
end
|
156
154
|
end
|
157
155
|
|
data/test/test_polar2d.rb
CHANGED
@@ -8,146 +8,145 @@ require "mageo/polar2d.rb"
|
|
8
8
|
|
9
9
|
|
10
10
|
class TC_Vector < Test::Unit::TestCase
|
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
|
-
|
11
|
+
include Math
|
12
|
+
|
13
|
+
$tolerance = 10.0**(-10)
|
14
|
+
|
15
|
+
def setup
|
16
|
+
@v0 = Vector[ 1.0, 2.0, 3.0 ]
|
17
|
+
@v1 = Vector[ 1.0, 1.0 ]
|
18
|
+
@v2 = Vector[ 1.0, 2.0, 3.0, 4.0 ]
|
19
|
+
end
|
20
|
+
|
21
|
+
def test_to_p2d
|
22
|
+
assert_raise( Vector::SizeError ){ @v0.to_p2d }
|
23
|
+
assert_raise( Vector::SizeError ){ @v2.to_p2d }
|
24
|
+
assert_equal( Polar2D , @v1.to_p2d.class )
|
25
|
+
assert_equal( Math::sqrt(2.0), @v1.to_p2d.r )
|
26
|
+
assert_equal( 0.25*PI , @v1.to_p2d.theta )
|
27
|
+
|
28
|
+
assert_in_delta( 0.00*PI, Vector[ 0.0, 0.0 ].to_p2d.theta, $tolerance )
|
29
|
+
assert_in_delta( 0.00*PI, Vector[ 2.0, 0.0 ].to_p2d.theta, $tolerance )
|
30
|
+
assert_in_delta( 0.25*PI, Vector[ 2.0, 2.0 ].to_p2d.theta, $tolerance )
|
31
|
+
assert_in_delta( 0.50*PI, Vector[ 0.0, 2.0 ].to_p2d.theta, $tolerance )
|
32
|
+
assert_in_delta( 0.75*PI, Vector[ -2.0, 2.0 ].to_p2d.theta, $tolerance )
|
33
|
+
assert_in_delta( 1.00*PI, Vector[ -2.0, 0.0 ].to_p2d.theta, $tolerance )
|
34
|
+
assert_in_delta( 1.25*PI, Vector[ -2.0, -2.0 ].to_p2d.theta, $tolerance )
|
35
|
+
assert_in_delta( 1.50*PI, Vector[ 0.0, -2.0 ].to_p2d.theta, $tolerance )
|
36
|
+
assert_in_delta( 1.75*PI, Vector[ 2.0, -2.0 ].to_p2d.theta, $tolerance )
|
37
|
+
end
|
38
38
|
end
|
39
39
|
|
40
40
|
|
41
41
|
class TC_Polar2D < Test::Unit::TestCase
|
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
|
-
|
131
|
-
|
132
|
-
|
133
|
-
|
134
|
-
|
135
|
-
|
136
|
-
|
137
|
-
|
138
|
-
|
139
|
-
|
140
|
-
|
141
|
-
|
142
|
-
|
143
|
-
|
144
|
-
|
145
|
-
|
146
|
-
|
147
|
-
|
148
|
-
|
149
|
-
|
150
|
-
|
151
|
-
|
42
|
+
$tolerance = 10**(-10)
|
43
|
+
|
44
|
+
include Math
|
45
|
+
|
46
|
+
def setup
|
47
|
+
@p2d00 = Polar2D.new( 0.0, 0.0*PI)
|
48
|
+
@p2d01 = Polar2D.new( 0.0, 2.0*PI)
|
49
|
+
@p2d02 = Polar2D.new( 2.0, 0.0*PI)
|
50
|
+
@p2d03 = Polar2D.new( 2.0, 0.1*PI)
|
51
|
+
end
|
52
|
+
|
53
|
+
def test_to_v
|
54
|
+
assert_equal( Vector[ 0.0, 0.0 ], @p2d00.to_v )
|
55
|
+
assert_equal( Vector[ 0.0, 0.0 ], @p2d01.to_v )
|
56
|
+
assert_equal( Vector[ 2.0, 0.0 ], @p2d02.to_v )
|
57
|
+
assert_equal( Vector[ 2.0*cos(0.1*PI), 2.0*sin(0.1*PI) ], @p2d03.to_v )
|
58
|
+
end
|
59
|
+
|
60
|
+
def test_rotate
|
61
|
+
assert_equal( Polar2D, @p2d00.rotate( 0.2 * PI ).class )
|
62
|
+
|
63
|
+
assert_in_delta( 0.0 , @p2d00.rotate( 0.2 * PI ).r , $tolerance )
|
64
|
+
assert_in_delta( 0.2*PI, @p2d00.rotate( 0.2 * PI ).theta, $tolerance )
|
65
|
+
assert_in_delta( 0.0 , @p2d01.rotate( 0.2 * PI ).r , $tolerance )
|
66
|
+
assert_in_delta( 2.2*PI, @p2d01.rotate( 0.2 * PI ).theta, $tolerance )
|
67
|
+
assert_in_delta( 2.0 , @p2d02.rotate( 0.2 * PI ).r , $tolerance )
|
68
|
+
assert_in_delta( 0.2*PI, @p2d02.rotate( 0.2 * PI ).theta, $tolerance )
|
69
|
+
assert_in_delta( 2.0 , @p2d03.rotate( 0.2 * PI ).r , $tolerance )
|
70
|
+
assert_in_delta( 0.3*PI, @p2d03.rotate( 0.2 * PI ).theta, $tolerance )
|
71
|
+
|
72
|
+
#変化していないことを確認
|
73
|
+
assert_equal( Vector[ 0.0, 0.0 ], @p2d00.to_v )
|
74
|
+
assert_equal( Vector[ 0.0, 0.0 ], @p2d01.to_v )
|
75
|
+
assert_equal( Vector[ 2.0, 0.0 ], @p2d02.to_v )
|
76
|
+
assert_equal( Vector[ 2.0*cos(0.1*PI), 2.0*sin(0.1*PI) ], @p2d03.to_v )
|
77
|
+
end
|
78
|
+
|
79
|
+
def test_rotate!
|
80
|
+
@p2d00.rotate!( 0.2 * PI )
|
81
|
+
@p2d01.rotate!( 0.2 * PI )
|
82
|
+
@p2d02.rotate!( 0.2 * PI )
|
83
|
+
@p2d03.rotate!( 0.2 * PI )
|
84
|
+
|
85
|
+
assert_in_delta( 0.0 , @p2d00.r , $tolerance )
|
86
|
+
assert_in_delta( 0.2*PI, @p2d00.theta, $tolerance )
|
87
|
+
assert_in_delta( 0.0 , @p2d01.r , $tolerance )
|
88
|
+
assert_in_delta( 2.2*PI, @p2d01.theta, $tolerance )
|
89
|
+
assert_in_delta( 2.0 , @p2d02.r , $tolerance )
|
90
|
+
assert_in_delta( 0.2*PI, @p2d02.theta, $tolerance )
|
91
|
+
assert_in_delta( 2.0 , @p2d03.r , $tolerance )
|
92
|
+
assert_in_delta( 0.3*PI, @p2d03.theta, $tolerance )
|
93
|
+
end
|
94
|
+
|
95
|
+
def test_minimize_theta!
|
96
|
+
p2pA = Polar2D.new( 2.0, -2.5*PI )
|
97
|
+
p2pA.minimize_theta!
|
98
|
+
assert_in_delta( 1.5*PI, p2pA.theta, $tolerance )
|
99
|
+
|
100
|
+
p2pB = Polar2D.new( 2.0, -0.5*PI )
|
101
|
+
p2pB.minimize_theta!
|
102
|
+
assert_in_delta( 1.5*PI, p2pB.theta, $tolerance )
|
103
|
+
|
104
|
+
p2pC = Polar2D.new( 2.0, 1.5*PI )
|
105
|
+
p2pC.minimize_theta!
|
106
|
+
assert_in_delta( 1.5*PI, p2pC.theta, $tolerance )
|
107
|
+
|
108
|
+
p2pD = Polar2D.new( 2.0, 3.5*PI )
|
109
|
+
p2pD.minimize_theta!
|
110
|
+
assert_in_delta( 1.5*PI, p2pD.theta, $tolerance )
|
111
|
+
|
112
|
+
p2pE = Polar2D.new( 2.0, 5.5*PI )
|
113
|
+
p2pE.minimize_theta!
|
114
|
+
assert_in_delta( 1.5*PI, p2pE.theta, $tolerance )
|
115
|
+
|
116
|
+
p2pF = Polar2D.new( 2.0, 4.5*PI )
|
117
|
+
p2pF.minimize_theta!
|
118
|
+
assert_in_delta( 0.5*PI, p2pF.theta, $tolerance )
|
119
|
+
|
120
|
+
end
|
121
|
+
|
122
|
+
def test_minimize_theta
|
123
|
+
p2pA = Polar2D.new( 2.0, -2.5*PI ).minimize_theta
|
124
|
+
assert_in_delta( 1.5*PI, p2pA.theta, $tolerance )
|
125
|
+
|
126
|
+
p2pB = Polar2D.new( 2.0, -0.5*PI ).minimize_theta
|
127
|
+
assert_in_delta( 1.5*PI, p2pB.theta, $tolerance )
|
128
|
+
|
129
|
+
p2pC = Polar2D.new( 2.0, 1.5*PI ).minimize_theta
|
130
|
+
assert_in_delta( 1.5*PI, p2pC.theta, $tolerance )
|
131
|
+
|
132
|
+
p2pD = Polar2D.new( 2.0, 3.5*PI ).minimize_theta
|
133
|
+
assert_in_delta( 1.5*PI, p2pD.theta, $tolerance )
|
134
|
+
|
135
|
+
p2pE = Polar2D.new( 2.0, 5.5*PI ).minimize_theta
|
136
|
+
assert_in_delta( 1.5*PI, p2pE.theta, $tolerance )
|
137
|
+
|
138
|
+
p2pF = Polar2D.new( 2.0, 4.5*PI ).minimize_theta
|
139
|
+
assert_in_delta( 0.5*PI, p2pF.theta, $tolerance )
|
140
|
+
|
141
|
+
end
|
142
|
+
|
143
|
+
def test_minimum_radian
|
144
|
+
assert_in_delta( 1.5*PI, Polar2D.minimum_radian( -2.5*PI ), $tolerance )
|
145
|
+
assert_in_delta( 1.5*PI, Polar2D.minimum_radian( -0.5*PI ), $tolerance )
|
146
|
+
assert_in_delta( 1.5*PI, Polar2D.minimum_radian( 1.5*PI ), $tolerance )
|
147
|
+
assert_in_delta( 1.5*PI, Polar2D.minimum_radian( 3.5*PI ), $tolerance )
|
148
|
+
assert_in_delta( 0.5*PI, Polar2D.minimum_radian( 4.5*PI ), $tolerance )
|
149
|
+
assert_in_delta( 1.5*PI, Polar2D.minimum_radian( 5.5*PI ), $tolerance )
|
150
|
+
end
|
152
151
|
end
|
153
152
|
|