Grasshopper

algorithmic modeling for Rhino

Hi.

 

At a point I need to add a Curve of a certain length along a direction.

I've made the following code work, but I am not sure how elegant it is, especially the conversion from Line to LineCurve to Curve. I need a Curve, because I do a CurveCurve intersection check later and this function doesn't accept a Line as a parameter. And since there is no constructor for Curve, I did it like this...

 

directionVector *=  distance; // set Vector length
Line ln = new Line(point, directionVector);
Curve crv = new LineCurve(ln).DuplicateCurve();

 

I would appreciate your input and a better solution.

Cheers

Eirik

Views: 302

Replies to This Discussion

You don't have to duplicate the LineCurve, LineCurve already implements the abstract Curve class:

Curve crv = new LineCurve(ln);

--

David Rutten

david@mcneel.com

Poprad, Slovakia

Shorter still:

Curve crv = new LineCurve(point, point + directionVector * distance);

--

David Rutten

david@mcneel.com

Poprad, Slovakia

thanks a lot David.

Worked like a charm. Interesting to know that you can use a point and vector addition as a point parameter.

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