# method

Andrew Lit

Ranch Hand

Posts: 135

posted 13 years ago

hi,

is there a method in java that determines if two points are placed in different sides of the straight line?

thank you

is there a method in java that determines if two points are placed in different sides of the straight line?

thank you

Dirk Schreckmann

Sheriff

Posts: 7023

Andrew Lit

Ranch Hand

Posts: 135

posted 13 years ago

yes it was easy, but it wasn't what i need.

so i decided to post what i need to do:

Graham's scan algorithm.

find if interior angle formed by Pa, Pb , Pc is greater than or equal to 180 degrees.

i stopped here and can't think of nothing. it's the only thing left to do.

could you suggest something to move on?

thank you.

so i decided to post what i need to do:

Graham's scan algorithm.

find if interior angle formed by Pa, Pb , Pc is greater than or equal to 180 degrees.

i stopped here and can't think of nothing. it's the only thing left to do.

could you suggest something to move on?

thank you.

Barry Gaunt

Ranch Hand

Posts: 7729

posted 13 years ago

There is an easy algorithm for testing whether a point is on the left of a line. If you apply that to the two points then you can find out whether the two points are on opposite sides of the line. Then the line through the two points must cut the first line.

Problem is I can't find a book I know has that algorithm (Haskel School of Expression). I'll keep looking but I'm sure the algorithm can be found with help of Google.

-Barry

Problem is I can't find a book I know has that algorithm (Haskel School of Expression). I'll keep looking but I'm sure the algorithm can be found with help of Google.

-Barry

Ask a Meaningful Question and HowToAskQuestionsOnJavaRanch

Getting someone to think and try something out is much more useful than just telling them the answer.

Barry Gaunt

Ranch Hand

Posts: 7729

posted 13 years ago

Or:

A line can be represented in the form:

F( x, y ) = a * x + b * y + c = 0 for a suitable choice of coefficients a, b, c.

F( s , t ) == 0 when ( s , t ) is on the line.

F( s , t ) > 0 when ( s , t ) is below the line.

F( s , t ) < 0 when ( s , t ) is above the line.

Maybe that will help.

-Barry

A line can be represented in the form:

F( x, y ) = a * x + b * y + c = 0 for a suitable choice of coefficients a, b, c.

F( s , t ) == 0 when ( s , t ) is on the line.

F( s , t ) > 0 when ( s , t ) is below the line.

F( s , t ) < 0 when ( s , t ) is above the line.

Maybe that will help.

-Barry

Getting someone to think and try something out is much more useful than just telling them the answer.