In my calculations I have to do a matrix multiplication. Instead of doing this calculation of every element I want to use the base ruby class Matrix which is made for such operations. I found out that it's not just adding require 'matrix' to your code.
I did copy the matrix.rb and e2mmap.rb (which is required by matrix.rb) from the ruby2.2.2 folder to the plugin folder from SketchUp where also my main script is located. Next thing I did is add this line require File.join(File.dirname(FILE), 'matrix.rb') to my main script and this line require File.join(File.dirname(FILE), 'e2mmap.rb') in matrix.rb. I believe this is the right way to require 'matrix'.
The thing is, when I load my main script in SketchUp I get a bunch of error messages and my script still won't do any matrix calculations. Here's the list of errors:
Error Loading File matrix.rb
C;/Program Files (x86)/Google/Google SketchUp 8/Plugins/matrix.rb;573; odd number list for Hash
SELECTORS = {all; true, diagonal; true, off_dia...
^
C;/Program Files (x86)/Google/Google SketchUp 8/Plugins/matrix.rb;573; syntax error, unexpected ';', expecting '}'
SELECTORS = {all; true, diagonal; true, off_dia...
^
C;/Program Files (x86)/Google/Google SketchUp 8/Plugins/matrix.rb;573; Can't assign to true
SELECTORS = {all; true, diagonal; true, off_diagonal;...
^
C;/Program Files (x86)/Google/Google SketchUp 8/Plugins/matrix.rb;573; syntax error, unexpected ';', expecting '='
...ECTORS = {all; true, diagonal; true, off_diagonal; true, low...
^
C;/Program Files (x86)/Google/Google SketchUp 8/Plugins/matrix.rb;573; Can't assign to true
... = {all; true, diagonal; true, off_diagonal; true, lower; tr...
^
C;/Program Files (x86)/Google/Google SketchUp 8/Plugins/matrix.rb;573; syntax error, unexpected ';', expecting '='
... diagonal; true, off_diagonal; true, lower; true, strict_low...
^
C;/Program Files (x86)/Google/Google SketchUp 8/Plugins/matrix.rb;573; Can't assign to true
...nal; true, off_diagonal; true, lower; true, strict_lower; tr...
^
C;/Program Files (x86)/Google/Google SketchUp 8/Plugins/matrix.rb;573; syntax error, unexpected ';', expecting '='
...ue, off_diagonal; true, lower; true, strict_lower; true, str...
^
C;/Program Files (x86)/Google/Google SketchUp 8/Plugins/matrix.rb;573; Can't assign to true
...f_diagonal; true, lower; true, strict_lower; true, strict_up...
^
C;/Program Files (x86)/Google/Google SketchUp 8/Plugins/matrix.rb;573; syntax error, unexpected ';', expecting '='
...ue, lower; true, strict_lower; true, strict_upper; true, upp...
^
C;/Program Files (x86)/Google/Google SketchUp 8/Plugins/matrix.rb;573; Can't assign to true
...wer; true, strict_lower; true, strict_upper; true, upper; tr...
^
C;/Program Files (x86)/Google/Google SketchUp 8/Plugins/matrix.rb;573; syntax error, unexpected ';', expecting '='
...ict_lower; true, strict_upper; true, upper; true}.freeze
^
C;/Program Files (x86)/Google/Google SketchUp 8/Plugins/matrix.rb;573; Can't assign to true
...wer; true, strict_upper; true, upper; true}.freeze
^
C;/Program Files (x86)/Google/Google SketchUp 8/Plugins/matrix.rb;573; syntax error, unexpected ';', expecting '='
...ue, strict_upper; true, upper; true}.freeze
^
C;/Program Files (x86)/Google/Google SketchUp 8/Plugins/matrix.rb;717; syntax error, unexpected ';', expecting ')'
def laplace_expansion(row; nil, column; nil)
^
C;/Program Files (x86)/Google/Google SketchUp 8/Plugins/matrix.rb;717; Can't assign to nil
def laplace_expansion(row; nil, column; nil)
^
C;/Program Files (x86)/Google/Google SketchUp 8/Plugins/matrix.rb;717; syntax error, unexpected ';', expecting '='
def laplace_expansion(row; nil, column; nil)
^
C;/Program Files (x86)/Google/Google SketchUp 8/Plugins/matrix.rb;1535; module definition in method body
C;/Program Files (x86)/Google/Google SketchUp 8/Plugins/matrix.rb;1561; module definition in method body
C;/Program Files (x86)/Google/Google SketchUp 8/Plugins/matrix.rb;1603; class definition in method body
C;/Program Files (x86)/Google/Google SketchUp 8/Plugins/matrix.rb;1673; syntax error, unexpected kEND, expecting $end
I think I already have a solution for my problem. I'm only going to use the multiplication class method. So I can maybe delete all the rest from matrix.rb, so the lines where the errors occur are gone. I can also code the calculation of a 3x3 matrix * 3x1 matrix by myself. But I just want to know why I can use the Matrix class in powershell and not in SketchUp. I'm think it has someting to do with my older version of SketchUp (8)?