Answer the question
In order to leave comments, you need to log in
How do you know if a point falls on a diagonal line?
So far I've come up with this, but it doesn't work correctly.
var x1 = 10
var y1 = 10
var x2 = 500
var y2 = 400
// ...
var a = (x2 - x1) / (y2 - y1)
// ...
var x = mouseX - x1
var y = mouseY - y1
var isLine = (x > 0 && y > 0)
&& Math.abs(a - x / y) / < 0.5
&& x < (x2 - x1)
&& y < (y2 - y1);
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question