generative modeling for Rhino
Hey
I'm trying to perform matrix operations in a VB component, and I'm stuck...
I've pieced together this code on matrix multiplication from forum searches:
Dim MatrixA(,) As Double = { _
{1, 3, 3}, _
{2, 4, 3}, _
{1, 3, 4}}
Dim MatrixB(,) As Double = { _
{1, 0, 0}, _
{0, 1, 0}, _
{0, 0, 1}}
Dim MatrixC(,) As Double = { _
{0, 0, 0}, _
{0, 0, 0}, _
{0, 0, 0}}
Public Shared Operator + ( _
a As MatrixA, _
b As MatrixB_
) As MatrixC
A = MatrixC
But I guess the "Public Shared..." part is a RH 5 function (?) and I'm running RH4!
Any ideas?
Also, not sure if I need to define MatrixC before the multiplication (?) but it's an attempt to troubleshoot...
Thanks, Peter
Tags: VB, matrices, matrix, multiplication, operations
Permalink Reply by Giulio Piacentino on April 17, 2012 at 6:51am Hi Peter,
you normally would not need to costruct the operations manually through 2-dimensional arrays, but in RhinoCommon you can use the Matrix class:
Dim m as new Matrix(3, 3)
m.Zero
m(0,1) = 3
m.Transpose
A = m(1,0)'A is 3
I attach a more detailed matrix multiplication example,
Thanks,
- Giulio
________________
giulio@mcneel.com
Permalink Reply by Peter Stavnshøj on April 18, 2012 at 2:17am Hey Giulio
THX for the reply!
I've tried both the .gh file you attached and the code you posted but non of them worked for me... Maybe it's a RH4 vs. RH5 issue?
From your .gh file I get the following error-message (in danish):
Which translates to: 'ON_Matrix_New' can not be found i the DLL 'rhcommon_c'. (line:0)
I've tried to rewrite my own file based on the coding in yours, but every time a get an error-message on the line that contains the multiplication of the matrices... So I'm inclined to think that it's not possible to perform the multiplication in RH4, unless I create the code myself??
It's not essential to perform the matrix multiplication, but it would make my work alot easier!
Thanks, Peter
Permalink Reply by Giulio Piacentino on April 18, 2012 at 3:28am It is working here: are you using Grasshopper 0.8.0066?
Thanks,
- Giulio
________________
giulio@mcneel.com
Permalink Reply by Peter Stavnshøj on April 20, 2012 at 2:22am yes, RH4 and GH8.0066...
I've just got the beta for RH5 and I'll install it later and see if that makes a difference!
Thanks, Peter
Permalink Reply by Giulio Piacentino on April 20, 2012 at 3:09am Nice! Please let me know if you have any doubts.
Thanks,
- Giulio
________________
giulio@mcneel.com
Permalink Reply by Peter Stavnshøj on April 20, 2012 at 9:00am Hi Giulio
I've just installed RH5 beta, and guess what... The file you sent me works :D
Just to double check - I unloaded GH in RH5 and ran it again in RH4, and here your file still didn't work... So it must be something with the newer RH.
Anyways, it works now - so I'm happy :D
Thanks, Peter
Permalink Reply by Giulio Piacentino on April 20, 2012 at 9:53am Yes, in Rhino 4 it will work with the next release of Grasshopper I think.
In Rhino 5, updates are given weekly or almost weekly.
- Giulio
________________
giulio@mcneel.com
Added by David Stasiuk 6 Comments 14 Likes
Added by stefano 4 Comments 6 Likes
© 2013 Created by Scott Davidson.
Powered by