Question: Write a method that returns the intersecting point of two lines. The intersecting point of the two lines can be found by using the formula

Write a method that returns the intersecting point of two lines. The intersecting point of the two lines can be found by using the formula shown in Programming Exercise 3.25. Assume that (x1, y1) and (x2, y2) are the two points on line 1 and (x3, y3) and (x4, y4) are on line 2. The method header ispublic static double[] getIntersectingPoint(double[][] points)The points are stored in a 4-by-2 two-dimensional array points with (points[0][0], points[0][1]) for (x1, y1). The method returns the intersecting point or null if the two lines are parallel. Write a program that prompts the user to enter four points and displays the intersecting point. See Programming Exercise 3.25?for a sample run.

Two points on line 1 are given as (x1, y1) and (x2, y2) and on line 2 as (x3, y3) and (x4, y4), as shown in Figure.

The intersecting point of the two lines can be found by solving the following linear equation:

(y1?-?y2)x?- (x1?-?x2)y?= (y1?-?y2)x1?- (x1?-?x2)y1

(y3?-?y4)x?- (x3?-?x4)y?= (y3?-?y4)x3?- (x3?-?x4)y3

This linear equation can be solved using Cramer?s rule (see Programming Exercise). If the equation has no solutions, the two lines are parallel (Figure).

Write a program that prompts the user to enter four points and displays the intersecting point. Here are sample runs:

(x2, y2) (x3, y3) (x4, y4) (x1, yl) (a) (x2, y2) (x3,

y3) (x1, y1) (x4, y4) (b)

image

image

(x2, y2) (x3, y3) (x4, y4) (x1, yl) (a) (x2, y2) (x3, y3) (x1, y1) (x4, y4) (b)

Step by Step Solution

3.46 Rating (172 Votes )

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock

Program Plan 1 Create a class GeometryIntersectingPoint 2 Declare and Initialize double points new d... View full answer

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 Java Programming Questions!