Grasshopper

algorithmic modeling for Rhino

Hey,

I'm attempting to use grasshopper to output fractal geometries. The problem I have is that using grasshopper components is not fast enough to output any meaningful amount of data.

The
equations are actually quite simple, so I thought that a small script could prove much faster. I have no real experience at scripting but I attempted to make a VB script component that solves this problem:

for any vector v,
v = s*ballFold(r, f*boxFold(v)) + c
where boxFold(v) means for each axis a:
if v[a]>1 v[a] = 2-v[a]
else if v[a]<-1 v[a] =-2-v[a]
and ballFold(r, v) means for v's magnitude m:
if m<r m = m/r^2
else if m<1 m = 1/m

I ended up with this code:

If v.x > 1 Then
v.x = 2 - v.x
ElseIf v.X < -1 Then
v.x = -2 - v.x
End If
If v.y > 1 Then
v.y = 2 - v.y
ElseIf v.Y < -1 Then
v.y = -2 - v.y
End If
If v.z > 1 Then
v.z = 2 - v.z
ElseIf v.z < -1 Then
v.z = -2 - v.z
End If

If v.length < 0.5 Then
v = (1 / r ^ 2) * v
ElseIf v.length < 1 Then
v = 1 / v
End If

v = scale * v + c

A = v

But this doesn't work - the operation 1 / v doesn't work for vectors. Plus I don't know if i'm going about this the right way to make the fastest code possible. It would be great if anyone with some real scripting knowledge could help
me out! Thanks

 

Views: 328

Replies to This Discussion

Hi Andrew,

 

what's the error that v= 1/v returns?

RSS

About

Translate

Search

Photos

  • Add Photos
  • View All

Videos

  • Add Videos
  • View All

© 2024   Created by Scott Davidson.   Powered by

Badges  |  Report an Issue  |  Terms of Service