We are about to switch to a new forum software. Until then we have removed the registration on this forum.
I'm guessing this is a fairly common question, but I need to make a line from, say, (100,100) with a length of 30 track the cursor. I tried converting to polar coordinates and back to cartesian, but I'm running into lots of errors.
PVector p = new PVector(0,0,0);
p.x = mouseX - width/2;
p.y = mouseY - height/2;
PVector origin, end;
float range = 30;
origin = new PVector (100,100);
end = new PVector (0,0);
float a = atan2(mouseY - origin.y, mouseX - origin.x);
end.x = origin.x + cos(a)*range;
end.y = origin.y + sin(a)*range;
line(origin.x, origin.y, end.x, end.y);