Question: (Use JAVA) 6. Add the following accessor method to the Point class public boolean isCollinear(Point pl, Point p2) Returns whether this Point is collinear with

 (Use JAVA) 6. Add the following accessor method to the Point

(Use JAVA)

6. Add the following accessor method to the Point class public boolean isCollinear(Point pl, Point p2) Returns whether this Point is collinear with the given two other Points. Points are collinear if a straight line can be drawn that connects them. Two basic examples are three points that have the same x or y-coordinale. The more gen- eral case can be determined by calculating the slope of the line between each pair of points and checking whether this slope is the same for all pairs of points. Use the formula (2-y/2-to determine the slope between two points X y and (y2). (Note that this formula fails for points with identicalx-coordinates so this will have to be a special case in your code.) Since Java's double type is imprecise, round all slope values to a reasonable accuracy such as four digits past the decimal point before you compare them

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!