Class: Snow::Mat3
Instance Method Summary collapse
-
#identity? ⇒ Boolean
Returns true if this Mat3 is an identity matrix.
-
#multiply(rhs, out = nil) ⇒ Object
(also: #*)
Monkey-patch fix for Mat3 * Vec3.
-
#multiply!(rhs) ⇒ Object
Monkey-patch fix for #multiply! type-switching.
Instance Method Details
#identity? ⇒ Boolean
Returns true if this Mat3 is an identity matrix.
38 39 40 |
# File 'lib/gosling/patches.rb', line 38 def identity? [1, 2, 3, 5, 6, 7].all? { |i| self[i] == 0 } && [0, 4, 8].all? { |i| self[i] == 1 } end |
#multiply(rhs, out = nil) ⇒ Object Also known as: *
Monkey-patch fix for Mat3 * Vec3
8 9 10 11 12 13 14 15 16 17 18 19 20 21 |
# File 'lib/gosling/patches.rb', line 8 def multiply(rhs, out = nil) case rhs when ::Snow::Mat3 multiply_mat3(rhs, out) when ::Snow::Vec3 values = (0..2).map { |i| get_row3(i) ** rhs } out ||= Snow::Vec3.new out.set(values) when Numeric scale(rhs, rhs, rhs, out) else raise TypeError, "Invalid type for RHS" end end |