
Perpendicular??
Hi, how would I get the computer to tell me if two lines are perpendicular?
This is the first part of the ifstatement I'm using to tell if they are:
if (m1 == 1.0 / m2 )
System.out.println("The lines are perpendicular.");
I know division sometimes causes problems with decimals.
Can anyone help me correct this?

Hi Moondrop,
I am no expert at this but you could consider to check whether they almost match:
Code:
if ((m1  1.0 / m2) < precision) {
System.out.println("The lines are perpendicular.");
}
Hope this helps.
Erik

Thank you. :) I finally got it.

A slope is perpendicular to another if it is the negative inverse of the other. Also, since you don't know if the math error is positive or negative, then closer perhaps is if you do,
(Math.abs(m1 + 1.0/m2) < precision)