Class: Snow::Vec3
- Inherits:
-
Object
- Object
- Snow::Vec3
- Defined in:
- lib/snow-math/vec3.rb,
lib/snow-math/swizzle.rb
Constant Summary collapse
- @@SWIZZLE_CHARS =
/^[xyz]{3,4}$/- @@SWIZZLE_MAPPING =
{ 3 => self, 4 => ::Snow::Vec4, 'x' => 0, 'y' => 1, 'z' => 2 }
Instance Method Summary collapse
- #add!(rhs) ⇒ Object
- #cross_product!(rhs) ⇒ Object
- #divide!(rhs) ⇒ Object
- #dup ⇒ Object
- #inverse! ⇒ Object
- #multiply(rhs, output = nil) ⇒ Object (also: #*)
- #multiply!(rhs) ⇒ Object
- #multiply_vec3!(rhs) ⇒ Object
- #negate! ⇒ Object
- #normalize! ⇒ Object
- #scale!(rhs) ⇒ Object
- #subtract!(rhs) ⇒ Object
- #x ⇒ Object
- #x=(value) ⇒ Object
- #y ⇒ Object
- #y=(value) ⇒ Object
- #z ⇒ Object
- #z=(value) ⇒ Object
Instance Method Details
#add!(rhs) ⇒ Object
86 87 88 |
# File 'lib/snow-math/vec3.rb', line 86 def add!(rhs) add rhs, self end |
#cross_product!(rhs) ⇒ Object
66 67 68 |
# File 'lib/snow-math/vec3.rb', line 66 def cross_product!(rhs) cross_product rhs, self end |
#divide!(rhs) ⇒ Object
98 99 100 |
# File 'lib/snow-math/vec3.rb', line 98 def divide!(rhs) divide rhs, self end |
#dup ⇒ Object
50 51 52 |
# File 'lib/snow-math/vec3.rb', line 50 def dup self.class.new(self) end |
#inverse! ⇒ Object
58 59 60 |
# File 'lib/snow-math/vec3.rb', line 58 def inverse! inverse self end |
#multiply(rhs, output = nil) ⇒ Object Also known as: *
74 75 76 77 78 79 80 |
# File 'lib/snow-math/vec3.rb', line 74 def multiply(rhs, output = nil) case rhs when Vec3 then multiply_vec3(rhs, output) when Numeric then scale(rhs, output) else raise TypeError, "Invalid type for RHS" end end |
#multiply!(rhs) ⇒ Object
82 83 84 |
# File 'lib/snow-math/vec3.rb', line 82 def multiply!(rhs) multiply rhs, self end |
#multiply_vec3!(rhs) ⇒ Object
70 71 72 |
# File 'lib/snow-math/vec3.rb', line 70 def multiply_vec3!(rhs) multiply_vec3 rhs, self end |
#negate! ⇒ Object
62 63 64 |
# File 'lib/snow-math/vec3.rb', line 62 def negate! negate self end |
#normalize! ⇒ Object
54 55 56 |
# File 'lib/snow-math/vec3.rb', line 54 def normalize! normalize self end |
#scale!(rhs) ⇒ Object
94 95 96 |
# File 'lib/snow-math/vec3.rb', line 94 def scale!(rhs) scale rhs, self end |
#subtract!(rhs) ⇒ Object
90 91 92 |
# File 'lib/snow-math/vec3.rb', line 90 def subtract!(rhs) subtract rhs, self end |
#x ⇒ Object
26 27 28 |
# File 'lib/snow-math/vec3.rb', line 26 def x self[0] end |
#x=(value) ⇒ Object
30 31 32 |
# File 'lib/snow-math/vec3.rb', line 30 def x=(value) self[0] = value end |
#y ⇒ Object
34 35 36 |
# File 'lib/snow-math/vec3.rb', line 34 def y self[1] end |
#y=(value) ⇒ Object
38 39 40 |
# File 'lib/snow-math/vec3.rb', line 38 def y=(value) self[1] = value end |
#z ⇒ Object
42 43 44 |
# File 'lib/snow-math/vec3.rb', line 42 def z self[2] end |
#z=(value) ⇒ Object
46 47 48 |
# File 'lib/snow-math/vec3.rb', line 46 def z=(value) self[2] = value end |