Class: Snow::Vec4
- Inherits:
-
Object
- Object
- Snow::Vec4
- Defined in:
- lib/snow-math/vec4.rb,
lib/snow-math/swizzle.rb
Constant Summary collapse
- @@SWIZZLE_CHARS =
/^[xyzw]{3,4}$/- @@SWIZZLE_MAPPING =
{ 3 => ::Snow::Vec3, 4 => self, 'x' => 0, 'y' => 1, 'z' => 2, 'w' => 3 }
Instance Method Summary collapse
- #add!(rhs) ⇒ Object
- #divide!(rhs) ⇒ Object
- #dup ⇒ Object
- #inverse! ⇒ Object
- #multiply(rhs, output = nil) ⇒ Object (also: #*)
- #multiply!(rhs) ⇒ Object
- #multiply_vec4!(rhs) ⇒ Object
- #negate! ⇒ Object
- #normalize! ⇒ Object
- #scale!(rhs) ⇒ Object
- #subtract!(rhs) ⇒ Object
- #w ⇒ Object
- #w=(value) ⇒ Object
- #x ⇒ Object
- #x=(value) ⇒ Object
- #y ⇒ Object
- #y=(value) ⇒ Object
- #z ⇒ Object
- #z=(value) ⇒ Object
Instance Method Details
#add!(rhs) ⇒ Object
89 90 91 |
# File 'lib/snow-math/vec4.rb', line 89 def add!(rhs) add rhs, self end |
#divide!(rhs) ⇒ Object
101 102 103 |
# File 'lib/snow-math/vec4.rb', line 101 def divide!(rhs) divide rhs, self end |
#dup ⇒ Object
57 58 59 |
# File 'lib/snow-math/vec4.rb', line 57 def dup self.class.new(self) end |
#inverse! ⇒ Object
65 66 67 |
# File 'lib/snow-math/vec4.rb', line 65 def inverse! inverse self end |
#multiply(rhs, output = nil) ⇒ Object Also known as: *
77 78 79 80 81 82 83 |
# File 'lib/snow-math/vec4.rb', line 77 def multiply(rhs, output = nil) case rhs when Vec4 then multiply_vec4(rhs, output) when Numeric then scale(rhs, output) else raise TypeError, "Invalid type for RHS" end end |
#multiply!(rhs) ⇒ Object
85 86 87 |
# File 'lib/snow-math/vec4.rb', line 85 def multiply!(rhs) multiply rhs, self end |
#multiply_vec4!(rhs) ⇒ Object
73 74 75 |
# File 'lib/snow-math/vec4.rb', line 73 def multiply_vec4!(rhs) multiply_vec4 rhs, self end |
#negate! ⇒ Object
69 70 71 |
# File 'lib/snow-math/vec4.rb', line 69 def negate! negate self end |
#normalize! ⇒ Object
61 62 63 |
# File 'lib/snow-math/vec4.rb', line 61 def normalize! normalize self end |
#scale!(rhs) ⇒ Object
97 98 99 |
# File 'lib/snow-math/vec4.rb', line 97 def scale!(rhs) scale rhs, self end |
#subtract!(rhs) ⇒ Object
93 94 95 |
# File 'lib/snow-math/vec4.rb', line 93 def subtract!(rhs) subtract rhs, self end |
#w ⇒ Object
49 50 51 |
# File 'lib/snow-math/vec4.rb', line 49 def w self[3] end |
#w=(value) ⇒ Object
53 54 55 |
# File 'lib/snow-math/vec4.rb', line 53 def w=(value) self[3] = value end |
#x ⇒ Object
25 26 27 |
# File 'lib/snow-math/vec4.rb', line 25 def x self[0] end |
#x=(value) ⇒ Object
29 30 31 |
# File 'lib/snow-math/vec4.rb', line 29 def x=(value) self[0] = value end |
#y ⇒ Object
33 34 35 |
# File 'lib/snow-math/vec4.rb', line 33 def y self[1] end |
#y=(value) ⇒ Object
37 38 39 |
# File 'lib/snow-math/vec4.rb', line 37 def y=(value) self[1] = value end |
#z ⇒ Object
41 42 43 |
# File 'lib/snow-math/vec4.rb', line 41 def z self[2] end |
#z=(value) ⇒ Object
45 46 47 |
# File 'lib/snow-math/vec4.rb', line 45 def z=(value) self[2] = value end |