-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathPlaneIntersection.java
More file actions
82 lines (73 loc) · 1.81 KB
/
PlaneIntersection.java
File metadata and controls
82 lines (73 loc) · 1.81 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
/**
* planes intersect in a line
* 1. I will first of all take the coefficients of the two planes' equation
* 2. I will find the cross product of both vectors that came out of the equation
* 3. the product of the cross product will be used to construct the equation of the line
* 4. I will then find the gaussian elimination of the vector consiting of the coefficients
* 5. the product will the coefficients of my new line
*
* @author Anton Kopti
*
*/
import java.util.*;
public class PlaneIntersection extends BasicVectorProp
{
//data
public Scanner sc = new Scanner(System.in);
public double [][] planes;
//constructors
public PlaneIntersection()
{
planes = new double[2][4];
this.insertVal();
}
//methods
public void insertVal()
{
for(int i=0;i<2;i++)
{
if(i==0)
{
System.out.println("insert the coefficients of your equation, include the value after the equal sign");
}
else
{
System.out.println("insert the coefficients of your second equation in teh same manner");
}
for (int j=0;j<4;j++)
{
planes[i][j]= sc.nextDouble();
}
}
}
public void findEqu()
{
double [] newArr= crossProduct(planes[0],planes[1]); //this method was taken from the parent class
double [][] rowRed = rref(planes);
double x = 0,y=0,z = 0;
if(rowRed[1][1]!=1)
{
x=rowRed[0][3];
y=0;
z=rowRed[1][3];
}
else if(rowRed[0][2]!=1||rowRed[1][2]!=1)
{
x=rowRed[0][3];
y=rowRed[1][3];
z=0;
}
System.out.println("x=" + x + " + " +newArr[0]+"t");
System.out.println();
System.out.println("y=" + y + " + " +newArr[1]+"t");
System.out.println();
System.out.println("z=" + z + " + " +newArr[2]+"t");
}
//end methods
//main
public static void main(String args[])
{
PlaneIntersection PI = new PlaneIntersection();
PI.findEqu();
}
}