class Snow::Mat3
Public Instance Methods
identity?()
click to toggle source
Returns true if this Mat3
is an identity matrix.
# 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)
click to toggle source
Monkey-patch fix for Mat3
* Vec3
# 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
Also aliased as: *
multiply!(rhs)
click to toggle source
Monkey-patch fix for multiply!
type-switching
# File lib/gosling/patches.rb, line 27 def multiply!(rhs) multiply rhs, case rhs when ::Snow::Mat3, Numeric then self when ::Snow::Vec3 then rhs else raise TypeError, "Invalid type for RHS" end end