bivector 0.0.1 → 0.0.2
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/lib/bivector.rb +13 -1
- metadata +2 -2
data/lib/bivector.rb
CHANGED
@@ -47,6 +47,18 @@ class Bivector
|
|
47
47
|
|
48
48
|
def unit_vector
|
49
49
|
return nil if self.zero?
|
50
|
-
Bivector.new(x /
|
50
|
+
Bivector.new(x / norm, y / norm)
|
51
|
+
end
|
52
|
+
|
53
|
+
def angles_to(another, style = 'rad')
|
54
|
+
if another.is_a? Bivector
|
55
|
+
angle = Math.acos(dot_product(another) / ( norm * another.norm))
|
56
|
+
case style
|
57
|
+
when 'rad'
|
58
|
+
return angle
|
59
|
+
when 'ang'
|
60
|
+
return angle * 360 / Math::PI
|
61
|
+
end
|
62
|
+
end
|
51
63
|
end
|
52
64
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: bivector
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.2
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2013-
|
12
|
+
date: 2013-02-17 00:00:00.000000000 Z
|
13
13
|
dependencies: []
|
14
14
|
description: A 2D Vector
|
15
15
|
email: zwt315@163.com
|