-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathVector.java
73 lines (49 loc) · 1.61 KB
/
Vector.java
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
public class Vector
{
int x;
int y;
public Vector(int xI, int yI)
{
x = xI;
y = yI;
}
public int getX(){
return x;
}
public int getY(){
return y;
}
public void display()
{
System.out.println("------------------");
System.out.println("X: " + x + "\nY: " + y);
System.out.println("------------------");
}
public static void main(String args[]){
Arithmetic vec1 = new Arithmetic(5, 8);
vec1.multiplyByScalar(3);
vec1.display();
vec1.divideByScalar(3);
vec1.display();
vec1.addByVector(new Vector(6, 2));
vec1.display();
vec1.subtractByVector(new Vector(5, 4));
vec1.display();
Operations vec2 = new Operations(2, -5);
int value = vec2.dot(new Vector(2, 8));
System.out.println(value);
System.out.println(vec2.magnitude());
System.out.println(vec2.convertToPolar()[0]);
System.out.println(vec2.convertToPolar()[1]);
Polar vec3 = new Polar(6, 100);
Vector vec4 = vec3.convert2Rec();
vec4.display();
Matrix myMatrix = new Matrix(new Vector(2, 3), new Vector(5, 4));
System.out.print("EigenValues: ");
double[] ev = myMatrix.eigenValues();
for(double i : ev){
System.out.print(i + " ");
}
System.out.println("\ndet: " + myMatrix.det());
}
}