Grasshopper

algorithmic modeling for Rhino

Hi, This is my problem:
I have a curve and a line on the same plane, the line has a specific direction, I'd like to find the points on that curve where the tangent has the same direction of the starting line.

Views: 2436

Replies to This Discussion

  1. Divide the curve into N samples (I used 1000, higher numbers give more accurate results).
  2. Measure the angle between the tangent at each sample and the target direction.
  3. Graph all these angles (and lower them by 0.5*pi).
  4. Find all the places where the graph hits zero using Line|Curve intersection.
  5. Map the intersection points [x] coordinate back onto curve space.
Attachments:

Hi David,

Could you explain a bit more why you lowered the whole graph by pi/2? Wouldn't 0, pi, and 2*pi angles be sufficient solutions? Or due to the interpolation we wouldn't have intersections at the two limits? I'm confused here.

Thanks for your help!

b

Thak you very much, I hoped in a much accurate and less cumbersome solution, but I guess it's an iteration problem wich is hard to calculate without a certain grade of complexity, I'm just worried about the division in 1000 (or more) wich could de a problem in a much complex algoritm, there is not a solution wich wouldn't need to divide the whole curve in equal parts to raise the tolerance?
Anyway thank you very much!!!

Hi,

you can use a divide and conquer algorithm similar to what I used here and here.

1. You can use David's method up to Step 3. for a moderate number of points (say 20-100 following the complexity of your curve) and work on each subcurve separately.

2. Each time you identify a possible candidate (at Step 4. in David's post, that would mean that at one end you have a positive angle, and at the other you have a negative angle, zero must be somewhere between these values) you can split the curve in half and look for the half where the point is the most likely to be and apply this process iteratively.

The advantage of this kind of method is that you can set arbitrarely a precision, and you explore less dead ends. With a uniform subdivision, if you need N steps to reach a certain precision, you will need here log(N), which is the best you can do.

Off course this method depends on the initial number of subcurves, and you have to give enough input points in the first place.

Best,

Romain

I have the same problem but I have a 3D curve, why can t I use thes GH?

Excellent!!! thanks!! that is what I was looking for!

Hello Everyone

I've made this definition starting from David's. It can be used to find 45 degrees Overhangs for 3D printing.

Hope you'll find it useful :)

Attachments:

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