Vert Point, Point2, P1, P2; Line surface, motionPath; float lineLineDist; float cPoint; void setup() { background(255); size(400, 200); Point = new Vert(200, 20); Point2 = new Vert(0, 0); P1 = new Vert(random(40, 120), random(100, 190)); P2 = new Vert(random(280, 360), random(100, 190)); surface = new Line(P1, P2); motionPath = new Line(Point, Point2); } float distTarget = 25; void draw() { fill(255); rect(0, 0, width, height); smooth(); stroke(0); strokeWeight(0.5); lineLineDist = distLineToLine(motionPath, surface); if (lineLineDist < 25) { background(225); } fill(255, 255, 255, 160); ellipse(mouseX, mouseY, 50, 50); Point.update(); Point2.update(); float totalDist = distance(Point, Point2); stroke(0, 0, 255); strokeWeight(8); motionPath.drawCpoint(); surface.drawCpoint(); float near = Point2.distPointToLine(surface); float far = Point.distPointToLine(surface); if (lineLineDist < 0.0001) near = -near; println(near); float distDiff = far - near; float distTrack = far - distTarget; float targetV = (distTrack / distDiff); stroke(0, 160, 255); motionPath.drawTargetPoint(targetV); stroke(0); strokeWeight(0.5); surface.update(); motionPath.update(mouseX, mouseY); };