Grasshopper

algorithmic modeling for Rhino

Hello All, 

I am working on a project where I need to trace vectors from the 3d point grid and check for intersection with surrounding meshes. I tried using the Mesh | Ray intersection component, but it doesn't work the way I expected. Basically not all rays and collision points are being detected. Any help would be appreciated. GH file attached. 

Apoorv 

Views: 3292

Attachments:

Replies to This Discussion

you are correct, using the mesh curve intersection component i get 2seconds calculation instead of 6.3 with brep curve.(old laptop)

Yes, you are right, the solution with meshes is by far the fastest one.

Attachments:

still 2 times is an improvement.

yes, i remeber in a post David explaining why it is difficult, if not impossible, for some components, but many are going to be MT. lets wait and see

Djordje, 

I have a question related to the definition you wrote. These are primarily for me to understand python. 

def intersect(_meshVecTupleL):
_m, _pt, _v = _meshVecTupleL
ray = Rhino.Geometry.Ray3d(_pt,_v)
length = Rhino.Geometry.Intersect.Intersection.MeshRay(_m,ray)
print length
if length < 0.0:
lines=Rhino.Geometry.Line(_pt,_pt+(100*_v))
return lines


if Run == True:
if parallel:
meshVecTupleL = []
for pt in points:
for v in vectors:
meshVecTupleL.append((mesh, pt, v))
withNulls = ghpythonlib.parallel.run(intersect, meshVecTupleL, True)
a = [item for item in withNulls if item != None]

1. How come we never defined length as an empty list and still it stored all the numbers? 

2. If length < 0.0 , lines are being created. How does python/rhino knows which pt to make the line at since we are processing the entire list "length" ? 

3. If I add another statement before return lines that would return the startpoint of the line instead of the line itself, it doesn't work. Why is that? 

Thanks for your help. 

Hi Apoorv,

1. length is not a list. It's a variable, and it stores a value which Intersection.MeshRay returns. Intersection.MeshRay always returns a single value not a list

2. if length is > 0.0 the ray intersects the mesh at length point along that particular ray. Similar to evaluating a point on a line/curve at particular parameter.
if length is equal to 0.0 the point from which the ray starts, sits on the mesh.
if length is < 0.0, then there's no intersection between the ray and the mesh, which is exactly what you wanted - so in that case for the sake of visualization we are creating lines from those rays.

3. It works here. Check the attached 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