snow-math 1.3.1 → 1.4.2

Sign up to get free protection for your applications and to get access to all the features.
@@ -36,6 +36,22 @@ class Snow::Vec3
36
36
  alias_method :clone, :copy
37
37
 
38
38
 
39
+ def to_vec2
40
+ Vec2.new(self)
41
+ end
42
+
43
+ def to_vec3
44
+ Vec3.new(self)
45
+ end
46
+
47
+ def to_vec4
48
+ Vec4.new(self)
49
+ end
50
+
51
+ def to_quat
52
+ Quat.new(self)
53
+ end
54
+
39
55
  # Returns the X component of the vector.
40
56
  #
41
57
  # call-seq: x -> float
@@ -120,7 +136,7 @@ class Snow::Vec3
120
136
  # multiply(scalar, output) -> output or new vec3
121
137
  def multiply(rhs, output = nil)
122
138
  case rhs
123
- when ::Snow::Vec3 then multiply_vec3(rhs, output)
139
+ when ::Snow::Vec3, ::Snow::Vec4, ::Snow::Quat then multiply_vec3(rhs, output)
124
140
  when Numeric then scale(rhs, output)
125
141
  else raise TypeError, "Invalid type for RHS"
126
142
  end
@@ -35,6 +35,22 @@ class Snow::Vec4
35
35
  alias_method :clone, :copy
36
36
 
37
37
 
38
+ def to_vec2
39
+ Vec2.new(self)
40
+ end
41
+
42
+ def to_vec3
43
+ Vec3.new(self)
44
+ end
45
+
46
+ def to_vec4
47
+ Vec4.new(self)
48
+ end
49
+
50
+ def to_quat
51
+ Quat.new(self)
52
+ end
53
+
38
54
  # Returns the X component of the vector.
39
55
  #
40
56
  # call-seq: x -> float
@@ -126,7 +142,7 @@ class Snow::Vec4
126
142
  # multiply(scalar, output = nil) -> output or new vec4
127
143
  def multiply(rhs, output = nil)
128
144
  case rhs
129
- when ::Snow::Vec4 then multiply_vec4(rhs, output)
145
+ when ::Snow::Vec4, ::Snow::Quat then multiply_vec4(rhs, output)
130
146
  when Numeric then scale(rhs, output)
131
147
  else raise TypeError, "Invalid type for RHS"
132
148
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: snow-math
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.3.1
4
+ version: 1.4.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Noel Raymond Cower
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2013-07-08 00:00:00.000000000 Z
11
+ date: 2013-07-10 00:00:00.000000000 Z
12
12
  dependencies: []
13
13
  description: Math types built on the SnowPalm math code
14
14
  email: ncower@gmail.com
@@ -28,6 +28,7 @@ files:
28
28
  - lib/snow-math/quat.rb
29
29
  - lib/snow-math/swizzle.rb
30
30
  - lib/snow-math/to_a.rb
31
+ - lib/snow-math/vec2.rb
31
32
  - lib/snow-math/vec3.rb
32
33
  - lib/snow-math/vec4.rb
33
34
  - lib/snow-math.rb
@@ -36,6 +37,7 @@ files:
36
37
  - ext/snow-math/maths.c
37
38
  - ext/snow-math/quat.c
38
39
  - ext/snow-math/snow-math.c
40
+ - ext/snow-math/vec2.c
39
41
  - ext/snow-math/vec3.c
40
42
  - ext/snow-math/vec4.c
41
43
  - ext/snow-math/maths_local.h