Class: Snow::Quat
- Inherits:
-
Object
- Object
- Snow::Quat
- Defined in:
- lib/snow-math/quat.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_quat!(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
90 91 92 |
# File 'lib/snow-math/quat.rb', line 90 def add!(rhs) add rhs, self end |
#divide!(rhs) ⇒ Object
102 103 104 |
# File 'lib/snow-math/quat.rb', line 102 def divide!(rhs) divide rhs, self end |
#dup ⇒ Object
57 58 59 |
# File 'lib/snow-math/quat.rb', line 57 def dup self.class.new(self) end |
#inverse! ⇒ Object
65 66 67 |
# File 'lib/snow-math/quat.rb', line 65 def inverse! inverse self end |
#multiply(rhs, output = nil) ⇒ Object Also known as: *
77 78 79 80 81 82 83 84 |
# File 'lib/snow-math/quat.rb', line 77 def multiply(rhs, output = nil) case rhs when Quat then multiply_quat(rhs, output) 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
86 87 88 |
# File 'lib/snow-math/quat.rb', line 86 def multiply!(rhs) multiply_quat! rhs end |
#multiply_quat!(rhs) ⇒ Object
73 74 75 |
# File 'lib/snow-math/quat.rb', line 73 def multiply_quat!(rhs) multiply_quat rhs, self end |
#negate! ⇒ Object
69 70 71 |
# File 'lib/snow-math/quat.rb', line 69 def negate! negate self end |
#normalize! ⇒ Object
61 62 63 |
# File 'lib/snow-math/quat.rb', line 61 def normalize! normalize self end |
#scale!(rhs) ⇒ Object
98 99 100 |
# File 'lib/snow-math/quat.rb', line 98 def scale!(rhs) scale rhs, self end |
#subtract!(rhs) ⇒ Object
94 95 96 |
# File 'lib/snow-math/quat.rb', line 94 def subtract!(rhs) subtract rhs, self end |
#w ⇒ Object
49 50 51 |
# File 'lib/snow-math/quat.rb', line 49 def w self[3] end |
#w=(value) ⇒ Object
53 54 55 |
# File 'lib/snow-math/quat.rb', line 53 def w=(value) self[3] = value end |
#x ⇒ Object
25 26 27 |
# File 'lib/snow-math/quat.rb', line 25 def x self[0] end |
#x=(value) ⇒ Object
29 30 31 |
# File 'lib/snow-math/quat.rb', line 29 def x=(value) self[0] = value end |
#y ⇒ Object
33 34 35 |
# File 'lib/snow-math/quat.rb', line 33 def y self[1] end |
#y=(value) ⇒ Object
37 38 39 |
# File 'lib/snow-math/quat.rb', line 37 def y=(value) self[1] = value end |
#z ⇒ Object
41 42 43 |
# File 'lib/snow-math/quat.rb', line 41 def z self[2] end |
#z=(value) ⇒ Object
45 46 47 |
# File 'lib/snow-math/quat.rb', line 45 def z=(value) self[2] = value end |