Grasshopper

algorithmic modeling for Rhino

Dear all,

I'm getting more and more familiar with the C# scripting, but I've run into a problem for which I can't find the solution.

In my model I want to work with geodesic lines on a surface between it's borders. Grasshopper has a Geodesic-component which can do that, but now I want to use it in a loop-script in C#. For this, I found the ShortPath function which you earlier talked about in another discussion: 

http://www.grasshopper3d.com/forum/topics/is-there-a-way-to-measure...

The question: How do I use and control the 3D-Points in my model, when it asks for a 2d-Point for the ShortPath? Or is there an other/easier solution which I haven't found yet?

I've attached a gh-model with a simplified version of my model with the use of the Geodesic-component as an example and the part of the C#-script to the point where I want to make the geodesic line.

Thank you.

Joey

Views: 763

Attachments:

Replies to This Discussion

ShortPath requires UV coordinates, not XYZ coordinates because (a) an xyz point might not be on the surface at all, and (b) an xyz coordinate might be at a place where the surface self-intersects or at a surface seam, in which case it's unclear exactly where the geodesic should start.

//Points to connect
Point3d p = new Point3d();
p = AB.PointAt(parAB);

Point3d q = new Point3d();
q = CD.PointAt(parCD);

double pu, pv;
surface.ClosestPoint(p, out pu, out pv);
Point2d puv = new Point2d(pu, pv);

double qu, qv;
surface.ClosestPoint(q, out qu, out qv);
Point2d quv = new Point2d(qu, qv);

//Geodesic connection
Curve geo = surface.ShortPath(puv, quv, 0.1);

//Output
P = p;
Q = q;
Geodesic = geo;

Thanks a lot David, it works!

That's exactly what I was looking for. I tried something similar, but probably messed up somewhere.

RSS

About

Translate

Search

Photos

  • Add Photos
  • View All

Videos

  • Add Videos
  • View All

© 2025   Created by Scott Davidson.   Powered by

Badges  |  Report an Issue  |  Terms of Service