Grasshopper

algorithmic modeling for Rhino

I've been working on a script that finds points on two lines based a specific area 

Currently the way I am getting the points are by intersecting a vertical plane from the point onto the other line. The problem is the projection continues even when the lines stop. The only stop parameter is the max vertical distance between top and bottom line.

Is there a way to terminate the loop by checking there no intersection is happening either through a empty parameter check or something like that?

This is the loop code

List< Point3d > bottoms = new List<Point3d>();
List< Point3d > tops = new List<Point3d>();
Listspan style="color: #3366ff;">double > horiz = new Listspan style="color: #3366ff;">double >();
Listspan style="color: #3366ff;">double > vert = new Listspan style="color: #3366ff;">double >();

int lastVert = 0;
int lastHoriz = 8500;
double lastParam = 0;


while(maxVert > lastVert && minHoriz < lastHoriz ) {
Point3d start = lineB.PointAt(lastParam);
Plane yz = new Plane(start, Vector3d.XAxis);
double param = 0;
Rhino.Geometry.Intersect.Intersection.LinePlane(lineA, yz, out param);
Point3d proj = lineA.PointAt(param);
double dist = start.DistanceTo(proj);
int intdist = (int) Math.Floor((dist / (double) step)) * step;
double length = (area / dist);
int intlength = (int) Math.Round((length / (double) roundfactor), MidpointRounding.AwayFromZero) * roundfactor;

Thank you!

Views: 558

Replies to This Discussion

If param is less than zero or larger than one, the intersection occurred on the 'exterior' of the line segment.

thank you that solved the problem!

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