Write a program that accepts (x1, y1) and (x2, y2) to specify line 1, (x3, y3) and (x4, y4) to specify line 2, computes and output the intersection of the two lines and the angle between them.
Code -
class xyPoint
{
double x,y;
public xyPoint(double x, double y)
{
this.x = x;
this.y = y;
}
//this method return the x, y coordinate of the
point
static void diplayCoordinate(xyPoint p)
{
System.out.println("(" + p.x + ", "
+ p.y + ")");
}
}
class Main
{
static xyPoint pointOfIntersection(xyPoint A, xyPoint
B, xyPoint C, xyPoint D)
{
//line A-B
double a1 = B.y - A.y;
double b1 = A.x - B.x;
double c1 = a1*(A.x) +
b1*(A.y);
//LINE C-D
double a2 = D.y - C.y;
double b2 = C.x - D.x;
double c2 = a2*(C.x)+
b2*(C.y);
double detarminant = a1*b2 -
a2*b1;
if (detarminant == 0)
{
//line are
parallel
return new
xyPoint(Double.MAX_VALUE, Double.MAX_VALUE);
}
else
{
//return the intersection point
double x =
(b2*c1 - b1*c2)/detarminant;
double y =
(a1*c2 - a2*c1)/detarminant;
return new
xyPoint(x, y);
}
}
static double angleBetweenLine(xyPoint A, xyPoint B,
xyPoint C, xyPoint D) {
double m1 = (B.y-A.y)/(B.x-A.x);
double m2 = (D.y-C.y)/(D.x-C.x);
double angle = (double)
Math.toDegrees(Math.atan((m2-m1)/(1-(m1*m2))));
if(angle < 0){
angle += 360;
}
return angle;
}
public static void main(String args[])
{
xyPoint A = new xyPoint(1,
1);
xyPoint B = new xyPoint(4,
4);
xyPoint C = new xyPoint(1,
8);
xyPoint D = new xyPoint(2,
4);
xyPoint intersection =
pointOfIntersection(A, B, C, D);
double angle = angleBetweenLine(A,
B, C, D);
System.out.println("Angle between
line "+angle+"degree");
//if the lines are parallel
if (intersection.x ==
Double.MAX_VALUE &&
intersection.y
== Double.MAX_VALUE)
{
System.out.println("The given lines AB and CD are
parallel.");
}
//print the intersection point
else
{
System.out.print("The intersection
of the given lines AB " +
"and CD is: ");
xyPoint.diplayCoordinate(intersection);
}
}
}
Screenshots -

Write a program that accepts (x1, y1) and (x2, y2) to specify line 1, (x3, y3)...
x1 = 1, y1 = 2 x2 = 2, y2 = 3 x3 = 3, y3 = 0 x4 = 4, y4 = 4 x5 = 5, y5 = 7 Conduct a hypothesis test of whether there is a linear relationship between variable X and Y. Calculate the p-value of your test of significance.
Write a program that prompts the user to enter three points (x1, y1), (x2, y2), (x3, y3) of a triangle and displays its area. The formula for computing the distance of two points (x1, y1) and (x2, y2) is d = Math.sqrt((x2 - x1) * (x2 - x1) + (y2 - y1) * (y2 - y1)); or d = Math.pow((x2 - x1) * (x2 - x1) + (y2 - y1) * (y2 - y1), 0.5); The formula for computing the...
с раиси от к. Show that the function that takes ((X1, X2, X3), (y1, y2, y3)) E to xi yi + x3y3 is not an inner product on R. ((X1, X2, X3), (y1, y2, y3)) E R3 x R3 von SE
1(a) Write a python program using a function name slope(x1, y1, x2, y2) that returns the slope of the line through the points (x1, y1) and (x2, y2). 1(b) For problem 1(a), write a python program using a function name Euclidean_dist(x1, y1, x2, y2) which will calculate and return the Euclidean distance between the points (x1, y1) and (x2, y2).
Let Y1, Y2, and Y3 be independent, N(0, 1)-distributed random variables, and set X1 = Y1 − Y3, X2 = 2Y1 + Y2 − 2Y3, X3 = −2Y1 + 3Y3.Determine the conditional distribution of X2 given that X1 + X3 = x.
Problem #1 Write a user-defined function called mysecant. (Not an an please!) The purpose of the function is: Given two points, compute the line between them and so where the corresponding y3-0. If there is no solution, Hint: The governing equations are: (y3-y1)-(y2-y1) / (x2-x1) * (x3-x1) if y3-0, then solve for x3, and so, x3-x1-y1 * (x2-x1) / (y2-y Inputs: x1, y1, x2, y2 Output: x3
= = 3, Cov(X1, X2) = 2, Cov(X2, X3) = -2, Let Var(X1) = Var(X3) = 2, Var(X2) Cov(X1, X3) = -1. i) Suppose Y1 = X1 - X2. Find Var(Y1). ii) Suppose Y2 = X1 – 2X2 – X3. Find Var(Y2) and Cov(Yı, Y2). Assuming that (X1, X2, X3) are multivariate normal, with mean 0 and covariances as specified above, find the joint density function fxı,Y,(y1, y2). iii) Suppose Y3 = X1 + X2 + X3. Compute the covariance...
Let X1, X2, X3 be independent Binomial(3,p) random variables. Define Y1 = X1 + X3 and Y2 = X2 + X3. Define Z1 = 1 if Y1 = 0; and 0 otherwise. Define Z2 = 1 if Y2 = 0; and 0 otherwise. As Z1 and Z3 both contain X3, are Z1 and Z3 independent? What is the marginal PMF of Z1 and Z2 and joint PMF of (Z1, Z2) and what is the correlation coefficient between Z1 and Z2?
Set A contains three numbers x1, x2 and x3. Set B contains four numbers y1, y2, y3 and y4. These two sets have the following characteristics: Set Mean Standard deviation A 10 2 B 45 5 Set X consists of the following eight numbers: u1 =70, u2 =7x1, u3 =7x2, u4 =7x3, u5 =2y1, u6 =2y2, u7 =2y3, u8 =2y4. Find the mean and standard deviation of the numbers in set X.
3) Let (x, y), (X2, y2), and (X3. Y3) be three points in R2 with X1 < x2 < X3. Suppose that y = ax + by + c is a parabola passing through the three points (x1, yı), (x2, y), and (x3, Y3). We have that a, b, and c must satisfy i = ax + bx + C V2 = ax + bx2 + c y3 = ax} + bx3 + c Let D = x X2 1....