coords 0.0.6 → 0.0.7

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: ead9696c33e5de4100aa80223a3b9760456dff6c
4
- data.tar.gz: f85926df8801c3f961fa05368cd08cafadc238d3
3
+ metadata.gz: 0ef9b5e2c1c4abd073f48762963efacecefaf883
4
+ data.tar.gz: 93f89db2a8d99ffedfaf63490a3a496f5f35501d
5
5
  SHA512:
6
- metadata.gz: bce87b3931da04e5cfa9318c5d9e78c66f17f187bc26493597a41c89a2606e53cd93d40d7a546d2c38f2d568f7bcb7f46876ed54f31362eda24639c049dba159
7
- data.tar.gz: 179c206b03680ad6082b5ab4808958d57a4b90de3273a94b4bac6dd86090335821c2c18c5b75a49ff67cc08b2e85ce7718b318e44c0ce7a575bca2c8f67970c7
6
+ metadata.gz: 0584d5390b17ca055081f9b1ef8dbe340971aa2e067be870b6f55b01ffa17e20ef6d2714bfe91d780683c3381bb65723503d90d189d48aec2d446a0b01e45d8b
7
+ data.tar.gz: b0791aab99ca15f1ba2c88935ef4844cce8ab5e9d4b1050f400e7a085fb0888072284a2df4587085e9ec028f5675a34ea43b8be8ef84ada67f0a873096e19ad2
@@ -1,3 +1,3 @@
1
1
  module Coords
2
- VERSION = "0.0.6"
2
+ VERSION = "0.0.7"
3
3
  end
data/lib/coords.rb CHANGED
@@ -14,4 +14,12 @@ module Coords
14
14
  radians / (Math::PI / 180)
15
15
  end
16
16
 
17
+ def self.rotate_matrix(matrix, times = 1, clockwise = true)
18
+ new_matrix = matrix
19
+ times.times.each do |i|
20
+ new_matrix = clockwise ? new_matrix.reverse.transpose : new_matrix.transpose.reverse
21
+ end
22
+ new_matrix
23
+ end
24
+
17
25
  end
@@ -0,0 +1,37 @@
1
+ require 'spec_helper'
2
+
3
+ describe Coords do
4
+
5
+ describe '#radians' do
6
+ it 'converts degrees to radians' do
7
+ expect(Coords.radians(180)).to eq(Math::PI)
8
+ end
9
+ end
10
+
11
+ describe '#degrees' do
12
+ it 'converts radians to degrees' do
13
+ expect(Coords.degrees(Math::PI)).to eq(180)
14
+ end
15
+ end
16
+
17
+ describe '#rotate_matrix' do
18
+ it 'rotates matrix 90 degrees clockwise' do
19
+ matrix1 = [[1, 2], [3, 4]]
20
+ matrix2 = [[3, 1], [4, 2]]
21
+ expect(Coords.rotate_matrix(matrix1)).to eq(matrix2)
22
+ end
23
+
24
+ it 'rotates matrix 90 degrees counter-clockwise' do
25
+ matrix1 = [[1, 2], [3, 4]]
26
+ matrix2 = [[2, 4], [1, 3]]
27
+ expect(Coords.rotate_matrix(matrix1, 1, false)).to eq(matrix2)
28
+ end
29
+
30
+ it 'rotates matrix 180 degrees clockwise' do
31
+ matrix1 = [[1, 2], [3, 4]]
32
+ matrix2 = [[4, 3], [2, 1]]
33
+ expect(Coords.rotate_matrix(matrix1, 2)).to eq(matrix2)
34
+ end
35
+ end
36
+
37
+ end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: coords
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.6
4
+ version: 0.0.7
5
5
  platform: ruby
6
6
  authors:
7
7
  - Craig Allan
@@ -117,6 +117,7 @@ files:
117
117
  - spec/lib/coords/cartesian3d_spec.rb
118
118
  - spec/lib/coords/polar_spec.rb
119
119
  - spec/lib/coords/spherical_spec.rb
120
+ - spec/lib/coords_spec.rb
120
121
  - spec/spec_helper.rb
121
122
  homepage: https://github.com/ceud/coords
122
123
  licenses:
@@ -147,5 +148,6 @@ test_files:
147
148
  - spec/lib/coords/cartesian3d_spec.rb
148
149
  - spec/lib/coords/polar_spec.rb
149
150
  - spec/lib/coords/spherical_spec.rb
151
+ - spec/lib/coords_spec.rb
150
152
  - spec/spec_helper.rb
151
153
  has_rdoc: