mageo 0.0.1 → 0.0.2

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,19 +1,20 @@
1
1
  #! /usr/bin/env ruby
2
2
  # coding: utf-8
3
3
 
4
- require "test/unit"
5
4
  require "helper"
6
- require "mageo/cylinder.rb"
7
- require "mageo/vector3d.rb"
5
+ #require "test/unit"
6
+ #require 'mageo.rb'
7
+ #require "mageo/cylinder.rb"
8
+ #require "mageo/vector3d.rb"
8
9
 
9
10
  class TC_Cylinder < Test::Unit::TestCase
10
11
  def setup
11
- @c00 = Cylinder.new([[0.0, 1.0, 2.0], [1.0, 2.0, 3.0]], 3.0)
12
+ @c00 = Mageo::Cylinder.new([[0.0, 1.0, 2.0], [1.0, 2.0, 3.0]], 3.0)
12
13
  end
13
14
 
14
15
  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])
16
+ assert_equal(Mageo::Vector3D[0.0, 1.0, 2.0], @c00.positions[0])
17
+ assert_equal(Mageo::Vector3D[1.0, 2.0, 3.0], @c00.positions[1])
17
18
  assert_equal(3.0, @c00.radius)
18
19
  end
19
20
  end
@@ -1,34 +1,32 @@
1
1
  #! /usr/bin/env ruby
2
2
  # coding: utf-8
3
3
 
4
- require "test/unit"
5
4
  require "helper"
6
- require "mageo/octahedron.rb"
7
- gem "builtinextension"
8
- require "array_include_eql.rb"
5
+ #gem "builtinextension"
6
+ #require "array/includeeql.rb"
9
7
 
10
- class Octahedron
8
+ class Mageo::Octahedron
11
9
  public :center
12
10
  end
13
11
 
14
12
  class TC_Octahedron < Test::Unit::TestCase
15
13
  $tolerance = 10**(-10)
16
14
 
17
- V_X_PLUS = Vector3D[ 1, 0, 0 ]
18
- V_Y_PLUS = Vector3D[ 0, 1, 0 ]
19
- V_Z_PLUS = Vector3D[ 0, 0, 1 ]
15
+ V_X_PLUS = Mageo::Vector3D[ 1, 0, 0 ]
16
+ V_Y_PLUS = Mageo::Vector3D[ 0, 1, 0 ]
17
+ V_Z_PLUS = Mageo::Vector3D[ 0, 0, 1 ]
20
18
 
21
- V_X_MINUS = Vector3D[ -1, 0, 0 ]
22
- V_Y_MINUS = Vector3D[ 0, -1, 0 ]
23
- V_Z_MINUS = Vector3D[ 0, 0, -1 ]
19
+ V_X_MINUS = Mageo::Vector3D[ -1, 0, 0 ]
20
+ V_Y_MINUS = Mageo::Vector3D[ 0, -1, 0 ]
21
+ V_Z_MINUS = Mageo::Vector3D[ 0, 0, -1 ]
24
22
 
25
23
  def setup
26
- @o00 = Octahedron.new(
24
+ @o00 = Mageo::Octahedron.new(
27
25
  [ [V_X_MINUS, V_X_PLUS ],
28
26
  [V_Y_MINUS, V_Y_PLUS ],
29
27
  [V_Z_MINUS, V_Z_PLUS ] ]
30
28
  )
31
- @o01 = Octahedron.new(
29
+ @o01 = Mageo::Octahedron.new(
32
30
  [ [ [ -0.5, 0.5, 0.5 ], [ 1.5, 0.5, 0.5 ] ],
33
31
  [ [ 0.5, -0.5, 0.5 ], [ 0.5, 1.5, 0.5 ] ],
34
32
  [ [ 0.5, 0.5, -0.5 ], [ 0.5, 0.5, 1.5 ] ] ]
@@ -36,30 +34,30 @@ class TC_Octahedron < Test::Unit::TestCase
36
34
  end
37
35
 
38
36
  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(
37
+ assert_raise( ArgumentError ){ Mageo::Octahedron.new }
38
+ assert_raise( ArgumentError ){ Mageo::Octahedron.new() }
39
+ assert_raise( Mageo::Octahedron::InitializeError ){ Mageo::Octahedron.new( nil ) }
40
+ assert_raise( Mageo::Octahedron::InitializeError ){ Mageo::Octahedron.new( [] ) }
41
+ assert_raise( Mageo::Octahedron::InitializeError ){ Mageo::Octahedron.new( [ 0, 1, 2 ] ) }
42
+ assert_raise( Mageo::Octahedron::InitializeError ){ Mageo::Octahedron.new( [ [], [], [] ] ) }
43
+ assert_raise( Mageo::Octahedron::InitializeError ){
44
+ Mageo::Octahedron.new(
47
45
  [ [ V_X_MINUS, V_X_PLUS ],
48
46
  [ V_Y_MINUS, V_Y_PLUS ],
49
47
  [ V_Z_MINUS, [ 0, 0 ] ]
50
48
  ]
51
49
  )
52
50
  }
53
- assert_raise( Octahedron::InitializeError ){
54
- Octahedron.new(
51
+ assert_raise( Mageo::Octahedron::InitializeError ){
52
+ Mageo::Octahedron.new(
55
53
  [ [ V_X_MINUS, V_X_PLUS],
56
54
  [ V_Y_MINUS, [ 0, 1, 0, 2 ] ],
57
55
  [ V_Z_MINUS, V_Z_PLUS ]
58
56
  ]
59
57
  )
60
58
  }
61
- assert_raise( Octahedron::InitializeError ){
62
- Octahedron.new(
59
+ assert_raise( Mageo::Octahedron::InitializeError ){
60
+ Mageo::Octahedron.new(
63
61
  [ [ V_X_MINUS, V_X_PLUS ],
64
62
  [ V_Y_MINUS, V_Y_PLUS ],
65
63
  [ V_Z_MINUS, V_Z_PLUS ],
@@ -68,19 +66,19 @@ class TC_Octahedron < Test::Unit::TestCase
68
66
  )
69
67
  }
70
68
 
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 ] ] ]
69
+ assert_raise( Mageo::Octahedron::InitializeError ){
70
+ Mageo::Octahedron.new(
71
+ [ [ Mageo::Vector3DInternal[ -0.5, 0.5, 0.5 ], Mageo::Vector3DInternal[ 1.5, 0.5, 0.5 ] ],
72
+ [ Mageo::Vector3DInternal[ 0.5, -0.5, 0.5 ], Mageo::Vector3DInternal[ 0.5, 1.5, 0.5 ] ],
73
+ [ Mageo::Vector3DInternal[ 0.5, 0.5, -0.5 ], Mageo::Vector3DInternal[ 0.5, 0.5, 1.5 ] ] ]
76
74
  )
77
75
  }
78
76
 
79
77
  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 ] ] ]
78
+ Mageo::Octahedron.new(
79
+ [ [ Mageo::Vector3D[ -0.5, 0.5, 0.5 ], Mageo::Vector3D[ 1.5, 0.5, 0.5 ] ],
80
+ [ Mageo::Vector3D[ 0.5, -0.5, 0.5 ], Mageo::Vector3D[ 0.5, 1.5, 0.5 ] ],
81
+ [ Mageo::Vector3D[ 0.5, 0.5, -0.5 ], Mageo::Vector3D[ 0.5, 0.5, 1.5 ] ] ]
84
82
  )
85
83
  }
86
84
  end
@@ -94,6 +92,7 @@ class TC_Octahedron < Test::Unit::TestCase
94
92
  def test_include?
95
93
  assert_equal( true , @o00.include?( [0.0, 0.2, 0.4], $tolerance ) )
96
94
  assert_equal( true , @o00.include?( [1.0, 0.0, 0.0], $tolerance ) ) #境界上
95
+ assert_equal( true , @o00.include?( [1.0, 0.0, 0.0] ) ) #境界上, no tolerance
97
96
  assert_equal( false, @o00.include?( [2.0, 0.2, 0.4], $tolerance ) )
98
97
  end
99
98
 
@@ -114,42 +113,42 @@ class TC_Octahedron < Test::Unit::TestCase
114
113
  def test_vertices
115
114
  t = @o00.vertices
116
115
  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 ))
116
+ assert_equal(V_X_MINUS, t[0])
117
+ assert_equal(V_X_PLUS , t[1])
118
+ assert_equal(V_Y_MINUS, t[2])
119
+ assert_equal(V_Y_PLUS , t[3])
120
+ assert_equal(V_Z_MINUS, t[4])
121
+ assert_equal(V_Z_PLUS , t[5])
123
122
  end
124
123
 
125
124
  def test_triangles
126
125
  t = @o00.triangles
127
126
  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])))
127
+ assert_equal(true, t.include_eql?(Mageo::Triangle.new([V_X_PLUS, V_Y_PLUS, V_Z_PLUS])))
128
+ assert_equal(true, t.include_eql?(Mageo::Triangle.new([V_X_PLUS, V_Y_PLUS, V_Z_MINUS])))
129
+ assert_equal(true, t.include_eql?(Mageo::Triangle.new([V_X_PLUS, V_Y_MINUS, V_Z_PLUS])))
130
+ assert_equal(true, t.include_eql?(Mageo::Triangle.new([V_X_PLUS, V_Y_MINUS, V_Z_MINUS])))
131
+ assert_equal(true, t.include_eql?(Mageo::Triangle.new([V_X_MINUS, V_Y_PLUS, V_Z_PLUS])))
132
+ assert_equal(true, t.include_eql?(Mageo::Triangle.new([V_X_MINUS, V_Y_PLUS, V_Z_MINUS])))
133
+ assert_equal(true, t.include_eql?(Mageo::Triangle.new([V_X_MINUS, V_Y_MINUS, V_Z_PLUS])))
134
+ assert_equal(true, t.include_eql?(Mageo::Triangle.new([V_X_MINUS, V_Y_MINUS, V_Z_MINUS])))
136
135
  end
137
136
 
138
137
  def test_edges
139
138
  t = @o00.edges
140
139
  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))))
140
+ assert_equal(true, (t.include_eql?(Mageo::Segment.new(V_X_PLUS , V_Y_PLUS))))
141
+ assert_equal(true, (t.include_eql?(Mageo::Segment.new(V_X_PLUS , V_Y_MINUS))))
142
+ assert_equal(true, (t.include_eql?(Mageo::Segment.new(V_X_PLUS , V_Z_PLUS))))
143
+ assert_equal(true, (t.include_eql?(Mageo::Segment.new(V_X_PLUS , V_Z_MINUS))))
144
+ assert_equal(true, (t.include_eql?(Mageo::Segment.new(V_X_MINUS, V_Y_PLUS))))
145
+ assert_equal(true, (t.include_eql?(Mageo::Segment.new(V_X_MINUS, V_Y_MINUS))))
146
+ assert_equal(true, (t.include_eql?(Mageo::Segment.new(V_X_MINUS, V_Z_PLUS))))
147
+ assert_equal(true, (t.include_eql?(Mageo::Segment.new(V_X_MINUS, V_Z_MINUS))))
148
+ assert_equal(true, (t.include_eql?(Mageo::Segment.new(V_Y_PLUS , V_Z_PLUS))))
149
+ assert_equal(true, (t.include_eql?(Mageo::Segment.new(V_Y_PLUS , V_Z_MINUS))))
150
+ assert_equal(true, (t.include_eql?(Mageo::Segment.new(V_Y_MINUS, V_Z_PLUS))))
151
+ assert_equal(true, (t.include_eql?(Mageo::Segment.new(V_Y_MINUS, V_Z_MINUS))))
153
152
  end
154
153
  end
155
154
 
data/test/test_polar2d.rb CHANGED
@@ -1,10 +1,12 @@
1
1
  #! /usr/bin/env ruby
2
2
  # coding: utf-8
3
3
 
4
- require "test/unit"
5
4
  require "helper"
6
- require "mageo/vector.rb"
7
- require "mageo/polar2d.rb"
5
+ #require "test/unit"
6
+ #require "helper"
7
+ #require 'mageo.rb'
8
+ #require "mageo/vector.rb"
9
+ #require "mageo/polar2d.rb"
8
10
 
9
11
 
10
12
  class TC_Vector < Test::Unit::TestCase
@@ -21,7 +23,7 @@ class TC_Vector < Test::Unit::TestCase
21
23
  def test_to_p2d
22
24
  assert_raise( Vector::SizeError ){ @v0.to_p2d }
23
25
  assert_raise( Vector::SizeError ){ @v2.to_p2d }
24
- assert_equal( Polar2D , @v1.to_p2d.class )
26
+ assert_equal( Mageo::Polar2D , @v1.to_p2d.class )
25
27
  assert_equal( Math::sqrt(2.0), @v1.to_p2d.r )
26
28
  assert_equal( 0.25*PI , @v1.to_p2d.theta )
27
29
 
@@ -44,10 +46,10 @@ class TC_Polar2D < Test::Unit::TestCase
44
46
  include Math
45
47
 
46
48
  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)
49
+ @p2d00 = Mageo::Polar2D.new( 0.0, 0.0*PI)
50
+ @p2d01 = Mageo::Polar2D.new( 0.0, 2.0*PI)
51
+ @p2d02 = Mageo::Polar2D.new( 2.0, 0.0*PI)
52
+ @p2d03 = Mageo::Polar2D.new( 2.0, 0.1*PI)
51
53
  end
52
54
 
53
55
  def test_to_v
@@ -58,7 +60,7 @@ class TC_Polar2D < Test::Unit::TestCase
58
60
  end
59
61
 
60
62
  def test_rotate
61
- assert_equal( Polar2D, @p2d00.rotate( 0.2 * PI ).class )
63
+ assert_equal( Mageo::Polar2D, @p2d00.rotate( 0.2 * PI ).class )
62
64
 
63
65
  assert_in_delta( 0.0 , @p2d00.rotate( 0.2 * PI ).r , $tolerance )
64
66
  assert_in_delta( 0.2*PI, @p2d00.rotate( 0.2 * PI ).theta, $tolerance )
@@ -93,60 +95,60 @@ class TC_Polar2D < Test::Unit::TestCase
93
95
  end
94
96
 
95
97
  def test_minimize_theta!
96
- p2pA = Polar2D.new( 2.0, -2.5*PI )
98
+ p2pA = Mageo::Polar2D.new( 2.0, -2.5*PI )
97
99
  p2pA.minimize_theta!
98
100
  assert_in_delta( 1.5*PI, p2pA.theta, $tolerance )
99
101
 
100
- p2pB = Polar2D.new( 2.0, -0.5*PI )
102
+ p2pB = Mageo::Polar2D.new( 2.0, -0.5*PI )
101
103
  p2pB.minimize_theta!
102
104
  assert_in_delta( 1.5*PI, p2pB.theta, $tolerance )
103
105
 
104
- p2pC = Polar2D.new( 2.0, 1.5*PI )
106
+ p2pC = Mageo::Polar2D.new( 2.0, 1.5*PI )
105
107
  p2pC.minimize_theta!
106
108
  assert_in_delta( 1.5*PI, p2pC.theta, $tolerance )
107
109
 
108
- p2pD = Polar2D.new( 2.0, 3.5*PI )
110
+ p2pD = Mageo::Polar2D.new( 2.0, 3.5*PI )
109
111
  p2pD.minimize_theta!
110
112
  assert_in_delta( 1.5*PI, p2pD.theta, $tolerance )
111
113
 
112
- p2pE = Polar2D.new( 2.0, 5.5*PI )
114
+ p2pE = Mageo::Polar2D.new( 2.0, 5.5*PI )
113
115
  p2pE.minimize_theta!
114
116
  assert_in_delta( 1.5*PI, p2pE.theta, $tolerance )
115
117
 
116
- p2pF = Polar2D.new( 2.0, 4.5*PI )
118
+ p2pF = Mageo::Polar2D.new( 2.0, 4.5*PI )
117
119
  p2pF.minimize_theta!
118
120
  assert_in_delta( 0.5*PI, p2pF.theta, $tolerance )
119
121
 
120
122
  end
121
123
 
122
124
  def test_minimize_theta
123
- p2pA = Polar2D.new( 2.0, -2.5*PI ).minimize_theta
125
+ p2pA = Mageo::Polar2D.new( 2.0, -2.5*PI ).minimize_theta
124
126
  assert_in_delta( 1.5*PI, p2pA.theta, $tolerance )
125
127
 
126
- p2pB = Polar2D.new( 2.0, -0.5*PI ).minimize_theta
128
+ p2pB = Mageo::Polar2D.new( 2.0, -0.5*PI ).minimize_theta
127
129
  assert_in_delta( 1.5*PI, p2pB.theta, $tolerance )
128
130
 
129
- p2pC = Polar2D.new( 2.0, 1.5*PI ).minimize_theta
131
+ p2pC = Mageo::Polar2D.new( 2.0, 1.5*PI ).minimize_theta
130
132
  assert_in_delta( 1.5*PI, p2pC.theta, $tolerance )
131
133
 
132
- p2pD = Polar2D.new( 2.0, 3.5*PI ).minimize_theta
134
+ p2pD = Mageo::Polar2D.new( 2.0, 3.5*PI ).minimize_theta
133
135
  assert_in_delta( 1.5*PI, p2pD.theta, $tolerance )
134
136
 
135
- p2pE = Polar2D.new( 2.0, 5.5*PI ).minimize_theta
137
+ p2pE = Mageo::Polar2D.new( 2.0, 5.5*PI ).minimize_theta
136
138
  assert_in_delta( 1.5*PI, p2pE.theta, $tolerance )
137
139
 
138
- p2pF = Polar2D.new( 2.0, 4.5*PI ).minimize_theta
140
+ p2pF = Mageo::Polar2D.new( 2.0, 4.5*PI ).minimize_theta
139
141
  assert_in_delta( 0.5*PI, p2pF.theta, $tolerance )
140
142
 
141
143
  end
142
144
 
143
145
  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 )
146
+ assert_in_delta( 1.5*PI, Mageo::Polar2D.minimum_radian( -2.5*PI ), $tolerance )
147
+ assert_in_delta( 1.5*PI, Mageo::Polar2D.minimum_radian( -0.5*PI ), $tolerance )
148
+ assert_in_delta( 1.5*PI, Mageo::Polar2D.minimum_radian( 1.5*PI ), $tolerance )
149
+ assert_in_delta( 1.5*PI, Mageo::Polar2D.minimum_radian( 3.5*PI ), $tolerance )
150
+ assert_in_delta( 0.5*PI, Mageo::Polar2D.minimum_radian( 4.5*PI ), $tolerance )
151
+ assert_in_delta( 1.5*PI, Mageo::Polar2D.minimum_radian( 5.5*PI ), $tolerance )
150
152
  end
151
153
  end
152
154
 
data/test/test_polar3d.rb CHANGED
@@ -1,10 +1,11 @@
1
1
  #! /usr/bin/env ruby
2
2
  # coding: utf-8
3
3
 
4
- require "test/unit"
4
+ #require "test/unit"
5
5
  require "helper"
6
- require "mageo/polar3d.rb"
7
- require "mageo/vector3d.rb"
6
+ #require 'mageo.rb'
7
+ #require "mageo/polar3d.rb"
8
+ #require "mageo/vector3d.rb"
8
9
 
9
10
  class TC_Polar3D < Test::Unit::TestCase
10
11
  $tolerance = 10**(-10)
@@ -12,29 +13,29 @@ class TC_Polar3D < Test::Unit::TestCase
12
13
  include Math
13
14
 
14
15
  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)
16
+ @p3d00 = Mageo::Polar3D.new( 0.0, 0.00*PI, 0.00*PI)
17
+ @p3d01 = Mageo::Polar3D.new( 2.0, 0.00*PI, 0.25*PI)
18
+ @p3d02 = Mageo::Polar3D.new( 2.0, 0.25*PI, 0.00*PI)
19
+ @p3d03 = Mageo::Polar3D.new( 2.0, 0.25*PI, 0.25*PI)
19
20
  end
20
21
 
21
22
  def test_to_v3d
22
- assert_equal( Vector3D, @p3d00.to_v3d.class )
23
+ assert_equal( Mageo::Vector3D, @p3d00.to_v3d.class )
23
24
  assert_in_delta( 0.0, @p3d00.to_v3d[0], $tolerance )
24
25
  assert_in_delta( 0.0, @p3d00.to_v3d[1], $tolerance )
25
26
  assert_in_delta( 0.0, @p3d00.to_v3d[2], $tolerance )
26
27
 
27
- assert_equal( Vector3D, @p3d01.to_v3d.class )
28
+ assert_equal( Mageo::Vector3D, @p3d01.to_v3d.class )
28
29
  assert_in_delta( 0.0, @p3d01.to_v3d[0], $tolerance )
29
30
  assert_in_delta( 0.0, @p3d01.to_v3d[1], $tolerance )
30
31
  assert_in_delta( 2.0, @p3d01.to_v3d[2], $tolerance )
31
32
 
32
- assert_equal( Vector3D, @p3d02.to_v3d.class )
33
+ assert_equal( Mageo::Vector3D, @p3d02.to_v3d.class )
33
34
  assert_in_delta( Math::sqrt(2.0), @p3d02.to_v3d[0], $tolerance )
34
35
  assert_in_delta( 0.0 , @p3d02.to_v3d[1], $tolerance )
35
36
  assert_in_delta( Math::sqrt(2.0), @p3d02.to_v3d[2], $tolerance )
36
37
 
37
- assert_equal( Vector3D, @p3d03.to_v3d.class )
38
+ assert_equal( Mageo::Vector3D, @p3d03.to_v3d.class )
38
39
  #√2 * cos(0.25PI)
39
40
  assert_in_delta( 1.0 , @p3d03.to_v3d[0], $tolerance)
40
41
  assert_in_delta( 1.0 , @p3d03.to_v3d[1], $tolerance)
@@ -43,49 +44,49 @@ class TC_Polar3D < Test::Unit::TestCase
43
44
  end
44
45
 
45
46
  def test_minimize_phi!
46
- p2pA = Polar3D.new( 2.0, 0.5*PI, -2.5*PI )
47
+ p2pA = Mageo::Polar3D.new( 2.0, 0.5*PI, -2.5*PI )
47
48
  p2pA.minimize_phi!
48
49
  assert_in_delta( 1.5*PI, p2pA.phi, $tolerance )
49
50
 
50
- p2pB = Polar3D.new( 2.0, 0.5*PI, -0.5*PI )
51
+ p2pB = Mageo::Polar3D.new( 2.0, 0.5*PI, -0.5*PI )
51
52
  p2pB.minimize_phi!
52
53
  assert_in_delta( 1.5*PI, p2pB.phi, $tolerance )
53
54
 
54
- p2pC = Polar3D.new( 2.0, 0.5*PI, 1.5*PI )
55
+ p2pC = Mageo::Polar3D.new( 2.0, 0.5*PI, 1.5*PI )
55
56
  p2pC.minimize_phi!
56
57
  assert_in_delta( 1.5*PI, p2pC.phi, $tolerance )
57
58
 
58
- p2pD = Polar3D.new( 2.0, 0.5*PI, 3.5*PI )
59
+ p2pD = Mageo::Polar3D.new( 2.0, 0.5*PI, 3.5*PI )
59
60
  p2pD.minimize_phi!
60
61
  assert_in_delta( 1.5*PI, p2pD.phi, $tolerance )
61
62
 
62
- p2pE = Polar3D.new( 2.0, 0.5*PI, 5.5*PI )
63
+ p2pE = Mageo::Polar3D.new( 2.0, 0.5*PI, 5.5*PI )
63
64
  p2pE.minimize_phi!
64
65
  assert_in_delta( 1.5*PI, p2pE.phi, $tolerance )
65
66
 
66
- p2pF = Polar3D.new( 2.0, 0.5*PI, 4.5*PI )
67
+ p2pF = Mageo::Polar3D.new( 2.0, 0.5*PI, 4.5*PI )
67
68
  p2pF.minimize_phi!
68
69
  assert_in_delta( 0.5*PI, p2pF.phi, $tolerance )
69
70
 
70
71
  end
71
72
 
72
73
  def test_minimize_phi
73
- p2pA = Polar3D.new( 2.0, 0.5*PI, -2.5*PI ).minimize_phi
74
+ p2pA = Mageo::Polar3D.new( 2.0, 0.5*PI, -2.5*PI ).minimize_phi
74
75
  assert_in_delta( 1.5*PI, p2pA.phi, $tolerance )
75
76
 
76
- p2pB = Polar3D.new( 2.0, 0.5*PI, -0.5*PI ).minimize_phi
77
+ p2pB = Mageo::Polar3D.new( 2.0, 0.5*PI, -0.5*PI ).minimize_phi
77
78
  assert_in_delta( 1.5*PI, p2pB.phi, $tolerance )
78
79
 
79
- p2pC = Polar3D.new( 2.0, 0.5*PI, 1.5*PI ).minimize_phi
80
+ p2pC = Mageo::Polar3D.new( 2.0, 0.5*PI, 1.5*PI ).minimize_phi
80
81
  assert_in_delta( 1.5*PI, p2pC.phi, $tolerance )
81
82
 
82
- p2pD = Polar3D.new( 2.0, 0.5*PI, 3.5*PI ).minimize_phi
83
+ p2pD = Mageo::Polar3D.new( 2.0, 0.5*PI, 3.5*PI ).minimize_phi
83
84
  assert_in_delta( 1.5*PI, p2pD.phi, $tolerance )
84
85
 
85
- p2pE = Polar3D.new( 2.0, 0.5*PI, 5.5*PI ).minimize_phi
86
+ p2pE = Mageo::Polar3D.new( 2.0, 0.5*PI, 5.5*PI ).minimize_phi
86
87
  assert_in_delta( 1.5*PI, p2pE.phi, $tolerance )
87
88
 
88
- p2pF = Polar3D.new( 2.0, 0.5*PI, 4.5*PI ).minimize_phi
89
+ p2pF = Mageo::Polar3D.new( 2.0, 0.5*PI, 4.5*PI ).minimize_phi
89
90
  assert_in_delta( 0.5*PI, p2pF.phi, $tolerance )
90
91
 
91
92
  end