Grasshopper

algorithmic 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

Views: 3709

Replies to This Discussion

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

Attachments:

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

It is working here: are you using Grasshopper 0.8.0066?

Thanks,

- Giulio
________________
giulio@mcneel.com

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

Nice! Please let me know if you have any doubts.

Thanks,

- Giulio
________________
giulio@mcneel.com

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 

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

Dear Giulio, 

thanks from me as well. 

However I would like a little help for a further step: would it be possible to input the matrix from an external panel?

Thanks, 

Dario

Hey,

I don't know if you still need it, but I just plugged it together in Grasshopper (no C# or VB)

There you go....

Attachments:

Grate work, extremely helpfull!

Works ok for square*square


Something is not ok with multiplication of square*1row and similar. Inputs should be swapped, and there is something going on with the 1row/column matrix - rows treated as columns and v.v. - Uploaded a file with explanation.

The problems can be overleaped with caution so it ok.

File:

Attachments:

RSS

About

Translate

Search

Videos

  • Add Videos
  • View All

© 2024   Created by Scott Davidson.   Powered by

Badges  |  Report an Issue  |  Terms of Service