solution to removing intersecting lines? :S
in
Share your Work
•
2 years ago
I chopped out everything necessary. I'm trying to solve this in 2d and then move up to 3d with it, so im trying to find a solution that will work for either case. Essentially I'm trying to create a plane out of connected scattered points, and in order to do so in 3d I have found that the easiest way would be to plot all connection lines, and then run something that wont draw any lines that intersect any other lines, so the result is a triangulated landscape. So i'm not looking for the intersection point but how to tell lines are intersecting and boolean them out.
i really didn't understand what was on the wiki page
nor could I find any existing examples. any help would be much appreciated. thanks!
**i just realized that it will count the end points as intersections and delete them as well. anyone have any other suggestions?
- Attractor[] attractor = new Attractor[7];
- //////////////////////////////////////////////////////////////
- void setup() {
- size(800, 800);
- smooth();
- for (int i = 0; i < attractor.length; i++) {
- attractor[i] = new Attractor( random(width), random(height) );
- }
- }
- void draw() {
- //background(0);
- for (int i=0; i < attractor.length; i++) {
- attractor[i].update();
- }
- }
- //////////////////////////////////////////////////////////////
- class Attractor {
- float x,y;
- Attractor(float _x, float _y ) {
- x = _x;
- y = _y;
- }
- void update() {
- stroke(255,0,0);
- strokeWeight(.025);
- line(x-4, y, x+4, y);
- line(x, y-4, x, y+4);
- for (int i = 0; i < attractor.length; i++) {
- //if (dist(x, y, attractor[i].x, attractor[i].y) < 100 ) {
- stroke(#ff0000);
- line(x, y, attractor[i].x, attractor[i].y);
- //}
- }
- }
- }
1