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 +4 -4
- data/lib/quaternion.rb +11 -5
- data/lib/quaternion/version.rb +1 -1
- metadata +3 -4
- data/lib/quaternion/numeric.rb +0 -24
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 307afea4a1dd5948a1f645add421a0fc42454668
|
4
|
+
data.tar.gz: 50911cfc471eed1f504a47ab87030eb7fc1b41b0
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: c0fc7880583e1a6115faf86adc36ca4bdb609f199bc5bab416bd4540b9617a67c692803de5b0e995c4b3fb0a488018b8964a856a84197f56047c1071bb6d4ef0
|
7
|
+
data.tar.gz: 1de04f678ee91a4d9fd851cfe9966dd65453de2562bbeca4b728f88baa1a812ad4fbb1abca425e1d5383895976186583c8fe06c3ff3e186b6157c9f6007a276d
|
data/lib/quaternion.rb
CHANGED
@@ -1,13 +1,11 @@
|
|
1
|
-
root_dir = "#{__dir__}/.."
|
2
|
-
|
3
1
|
require 'matrix'
|
4
|
-
require "
|
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
|
-
|
data/lib/quaternion/version.rb
CHANGED
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.
|
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-
|
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.
|
93
|
+
rubygems_version: 2.4.8
|
95
94
|
signing_key:
|
96
95
|
specification_version: 4
|
97
96
|
summary: Quaternion class
|
data/lib/quaternion/numeric.rb
DELETED
@@ -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
|