Complex numbers and other libraries
-
Can anyone tell me how to use other ruby libraries like the complex number functions in the Ruby in Sketchup? Khalid at http://www.betterexplained.com has rocked my world and has got me scrambling to apply euler's formula to simple animation as a teaching tool. All of you wizards out there can take this as a general question about other libraries as well. Thanks heaps.
-
Thanks for that link!
(Sorry I'm not sure about your question though. Is it a module part of the standard Ruby?)
-
I think so. Complex(10,2) should yield 10 + 2i. In ruby 1.9.2 it is a Class with a parent being numeric. If it sounds like I don't know what I'm talking about its cause I don't know what I'm talking about....However Complex numbers are a part of the TI83 Calculator Basic but not a standard function in Google Docs Spreadsheets.
Thanks for your great work..
-
It's a class under Ruby 1.9. But I don't see it for 1.8.6 (which is what SU uses). http://www.ruby-doc.org/core-1.8.6/index.html
-
It's in the Standard (ie Extended,) Libraries for 1.8.6 (not in the Core.)
In Files
lib/complex.rb
lib/mathn.rbYou need a full ruby installation.
You need to add paths to the $LOAD_PATH array.
I have a topic on this and a utility script called !loadpaths.rb
Addenda: -See these posts:
-
for the !loadpaths.rb script:
[code] Ruby LOAD PATHs script for (Win32) -
and for info: same topic near the bottom..
-
for the complete Ruby libraries (with precompiled .so files,) direct from ftp.ruby-lang.org:
-
to match SU 8.0M0 & M1: ruby 1.8.6-p287* for Ruby 1.8.6-p369 (latest as of this posting.)
-
requires you replace DLL in Sketchup program folder if on Windows.* See instructions: Ruby Interpreter DLLs (Win32)
Also see: Ruby Newbie's Guide to Getting Started
-
Advertisement