quaternion 0.1.1 → 0.1.2

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: 819da0242c1ec7196ca1cf3ac0e5e11004235696
4
- data.tar.gz: c8b70be61075d0ead7570014bcbc5f306d88e465
3
+ metadata.gz: 307afea4a1dd5948a1f645add421a0fc42454668
4
+ data.tar.gz: 50911cfc471eed1f504a47ab87030eb7fc1b41b0
5
5
  SHA512:
6
- metadata.gz: 6f67f4c07fb013157cd9230ce6fbd35c1d5d084616449b4c8337e1989dcd32577404a1fc273fda2ec99877b800c62b7948f0d23c2a2fddb9de7832a4f232fd54
7
- data.tar.gz: 4c7f6ca6b558480f4bde5be720c22c13ff2f9e2579a5364a167f77a9d8f7bf1f14726a69a35a9ea0d627cccbf6adb3f699758338676215154eeaae6e5371151d
6
+ metadata.gz: c0fc7880583e1a6115faf86adc36ca4bdb609f199bc5bab416bd4540b9617a67c692803de5b0e995c4b3fb0a488018b8964a856a84197f56047c1071bb6d4ef0
7
+ data.tar.gz: 1de04f678ee91a4d9fd851cfe9966dd65453de2562bbeca4b728f88baa1a812ad4fbb1abca425e1d5383895976186583c8fe06c3ff3e186b6157c9f6007a276d
@@ -1,13 +1,11 @@
1
- root_dir = "#{__dir__}/.."
2
-
3
1
  require 'matrix'
4
- require "#{root_dir}/lib/quaternion/version"
5
- require "#{root_dir}/lib/quaternion/numeric"
2
+ require "quaternion/version"
6
3
 
7
4
  ##
8
5
  # Class for Quaternion calculation.
9
6
  class Quaternion
10
7
  include Math
8
+ extend Math
11
9
 
12
10
  ##
13
11
  # Returns an instance of Quaternion for rotateion aroud +axis+ with angle
@@ -258,6 +256,15 @@ class Quaternion
258
256
  end
259
257
  end
260
258
 
259
+ ##
260
+ # Inverts order of multiplication, so our math methods
261
+ # will be used for types that don't know how to deal Quaternions
262
+ # q = Quaternion.new(1.0, 2.0, 3.0, 4.0)
263
+ # 2*q # => Quarternion(2.0; Vector[4.0, 6.0, 8.0])
264
+ def coerce(n)
265
+ [self, n]
266
+ end
267
+
261
268
  private
262
269
  def to_vector v
263
270
  case v
@@ -270,4 +277,3 @@ class Quaternion
270
277
  end
271
278
  end
272
279
  end
273
-
@@ -1,3 +1,3 @@
1
1
  class Quaternion
2
- VERSION = "0.1.1" # :nodoc:
2
+ VERSION = "0.1.2" # :nodoc:
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: quaternion
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.1
4
+ version: 0.1.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Hiroyuki Tanaka
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2015-04-05 00:00:00.000000000 Z
11
+ date: 2015-09-26 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -68,7 +68,6 @@ files:
68
68
  - bin/console
69
69
  - bin/setup
70
70
  - lib/quaternion.rb
71
- - lib/quaternion/numeric.rb
72
71
  - lib/quaternion/version.rb
73
72
  - quaternion.gemspec
74
73
  homepage: https://github.com/tanahiro/quaternion
@@ -91,7 +90,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
91
90
  version: '0'
92
91
  requirements: []
93
92
  rubyforge_project:
94
- rubygems_version: 2.4.6
93
+ rubygems_version: 2.4.8
95
94
  signing_key:
96
95
  specification_version: 4
97
96
  summary: Quaternion class
@@ -1,24 +0,0 @@
1
-
2
- class Float # :nodoc:
3
- alias_method :multi_org, :*
4
-
5
- def * other
6
- if other.is_a?(Quaternion)
7
- other*self
8
- else
9
- self.multi_org(other)
10
- end
11
- end
12
- end
13
-
14
- class Fixnum # :nodoc:
15
- alias_method :multi_org, :*
16
-
17
- def * other
18
- if other.is_a?(Quaternion)
19
- other*self
20
- else
21
- self.multi_org(other)
22
- end
23
- end
24
- end