detecting when line intersects a point
in
Programming Questions
•
21 days ago
I can find a decent amount of info on how to detect if two lines intersect, but I want to try to find how to detect if line intersects a point or possible if it intersects with an ellipse.
here is what I have (this is processing.js)
I would like to know when the lines on line 24 intersects ellipse on line 25
- void setup() {
- stroke(255);
- smooth();
- }
- void draw() {
- background(0);
- var halfWidth = jQuery(document).height()/2;
- var halfHeight = jQuery(document).width()/2;
- fill(40);
- float x = width/2;
- float y = height/2;
- float d = width * 0.5;
- arc(halfHeight, halfWidth, d, d, 0, HALF_PI);
- fill(80);
- noStroke();
- float s = map(second(), 0, 60, 0, TWO_PI) - HALF_PI; // TWO_PI = 6.28318530717958647693, HALF_PI = 1.57079632679489661923;
- stroke(255);
- strokeWeight(1);
- ellipse( halfHeight,halfWidth,1,1);
- float y = sin(s) * 72 + halfWidth;
- float x = cos(s) * 72 + halfHeight;
- ellipse( x,y,10,10)
- stroke(55);
- line(halfHeight, halfWidth,x ,y);
- ellipse( halfHeight+10,halfWidth+10,1,1);
- }
1