Grasshopper

algorithmic modeling for Rhino

Hi all, 

       I am a python user(beginner) trying to understand meshes and meshing algorithms like Marching cubes, Ball Pivot and Marching tetrahedra. I saw basic example provided with rhinoscriptsyntax, It was hard to imagine how hard it was to make mesh faces assigned from points. One way i could think of not Reinventing the wheel was to call mesh from points commands in python . I needs some direction to head towards creating meshes in rhino

      I was suggested Libraries but i not smart enough to figure out how to or where to use them exactly. 

Views: 8167

Replies to This Discussion

So this AddFace command/function is so obscurely documented, that how you really use it, what damn buttons to push on your keyboard as a hopeful primate, is *hidden* in the old 32 bit version of the command in the help file Rhinocommon.chk, there being no examples in real language let alone the English language in the modern entries of the "help" document, no indication for a normal student of Rhino to find out that you need to use mesh.Faces before AddFace which is NOT described anywhere in any manual that exists:

I also realize that my periodic study of Javascript has confused me in relation to the specific object oriented command "dot structure sequences" of Python in Grasshopper in Rhino in Windows in Intel.

LESSON LEARNED: "slow down to speed up" by actively scanning *every* entry in the help file Rhinocommon.chk for an old seemingly obsolete entry that really contains code examples that indicate how you actually use the godforsaken command.

Oh God no, I thought the faces were created as independent, separate "meshes" but here you are implying that you are somehow keeping a list of vertices too, and in removing duplicates, somehow you retain the topological (vertex number) face definitions?

I thought you were just making floating faces as proudly independent "meshes" and then joining them.

Remember we are dealing with a marching tetrahedra script that spits out many redundant vertices.

I get it: this is a formality. Just a way to "weld" the faces into one real mesh. This is a footnote.

There is a way to teach this stuff. I don't know it yet. But I have an inkling. It involves shouting out strong distinctions. One distinction is to stick to real programming, since Grasshopper is a bait and switch bitch.

Didn't mean to confuse you...yes, you build the faces independently and then let the OutputMesh.Vertices.CombineIdentical() function sort out all of the redundant vertices.

There are no redundant vertices.

It's just mesh join or something. Really it's just 1011110 becoming 1011101, right, as the whole human universe is made of gray atoms?

I'm a street fighter, trying to steel your thunder, to bullshit my way into a $120K job.

Why are you doing Grasshopper?

I'm asking a personal question and I want a story, as does almost everyone who reads this forum.

What do you want?

it's probably just easier...http://www.bespokegeometry.com/about/

You won't tell yet, still being a Ph.D. student. Got mine in chemistry in the late '90s.

This is utterly beautiful, so double thank you today:

Thanks! Nice! Looking forward to keeping the conversation going...

Thanks to David Stasiuk's street smart guidance, I have now finally achieved a simple mesh output of marching tetrahedra in Python in Grasshopper in Rhino in Windows in Intel:

Computation time for the Python script is two seconds. I'm still not sure how to ramp up the resolution of the tetrahedra, or what sort of smoothing is best in Grasshopper. Nor yet how to join the individual mesh faces into one mesh within Python to avoid the MJoin Grasshopper component.

Now, gloriously, I only import Rhino, leaving out rhinoscriptsyntax.

I'm still not sure what marching cubes/tetrahedra is though. Does the internal trigonometric function define an actual volume or just a surface? Marching cubes was supposed to make a surface around voxels when the early computer kids started grabbing 3D scanner data from frozen biological sample slices and then nuclear magnetic resonance data, volumetric pixels, but here is just a surface function?! What do I input to this beast now, instead? Can I make art out of this?

Attachments:
To understand what marching cubes/tets is doing, I recommend reading Paul Bourke's article: http://paulbourke.net/geometry/polygonise/

It is essentially a method of *contouring* - easier to see in the 2d case as taking a horizontal slice through a 3d height field (which can come from an equation, or image, or distance from some geometry etc.) Marching squares is the equivalent algorithm in 2d.

In 3d you are slicing a 'height' field in 4d space, by checking which corners of each tet or cube are 'under' this hypersurface and adding the appropriate facet.
How do I make metaballs that simply politely merge like smoothly melted clay instead of act like light bulbs that get too bright and thus too ridiculously fat where I include several of them together to try to build a plane or strip or a line out of points/balls? The simple math that makes a field around each point screws up intuitive modeling since each point fields adds to instead of politely merges with its neighbor.

Also, a trigonometric function only describes a surface, so this example is just silly, right? How does math describe 3D fields instead of just exact yes/no points on a 3D surface?
You can play with the distance function like in the bottom comment here:
http://www.grasshopper3d.com/photo/line-distance-field
For example - only include the influence of the closest point/line instead of summing all of them.

I didn't see the particular equation your example is using, but I imagine it is something defined implicitly (https://en.m.wikipedia.org/wiki/Implicit_surface)
This page also directly addresses this issue of bulging and blending functions:
http://paulbourke.net/geometry/implicitsurf/

Surface Formula:

# return a 3d list of values  
def readdata(f=lambda x,y,z:x*x+y*y+z*z,size=5.0,steps=11):  
 m=int(steps/2)  
 ki = []  
 for i in range(steps):  
  kj = []  
  for j in range(steps):  
   kd=[]  
   for k in range(steps):  
    kd.append(f(size*(i-m)/m,size*(j-m)/m,size*(k-m)/m))  
   kj.append(kd)  
  ki.append(kj)  
 return ki  
 
from math import cos,exp,atan2  
 
def lobes(x,y,z):  
 try:  
  theta = atan2(x,y)         # sin t = o   
 except:  
  theta = 0  
 try:  
  phi = atan2(z,y)  
 except:  
  phi = 0  
 r = x*x+y*y+z*z  
 ct=cos(PARAMETER_A * theta)  
 cp=cos(PARAMETER_B * phi)  
 return ct*ct*cp*cp*exp(-r/10)  
   
def main():  
 
 data = readdata(lobes,10,40)

...

RSS

About

Translate

Search

Videos

  • Add Videos
  • View All

© 2024   Created by Scott Davidson.   Powered by

Badges  |  Report an Issue  |  Terms of Service