Class: Matrix
- Inherits:
-
Object
- Object
- Matrix
- Defined in:
- lib/bvh/matrix.rb
Overview
This adds a few methods to the default Ruby Matrix implementation.
Instance Method Summary collapse
-
#[]=(i, j, x) ⇒ Object
Sets row “i”, column “j”, to the value “x”.
-
#load_identity! ⇒ Object
Turns this matrix into an identity matrix, erasing all previous values.
Instance Method Details
#[]=(i, j, x) ⇒ Object
Sets row “i”, column “j”, to the value “x”.
6 7 8 |
# File 'lib/bvh/matrix.rb', line 6 def []=(i,j,x) @rows[i][j] = x end |
#load_identity! ⇒ Object
Turns this matrix into an identity matrix, erasing all previous values.
11 12 13 14 15 16 17 18 |
# File 'lib/bvh/matrix.rb', line 11 def load_identity! row_size.times do |r| column_size.times do |c| self[r, c] = (r == c ? 1 : 0) end end self end |