- Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathVector.java
More file actions
Latest commit
73 lines (49 loc) · 1.61 KB
/
Copy pathVector.java
File metadata and controls
73 lines (49 loc) · 1.61 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
publicclassVector
{
intx;
inty;
publicVector(intxI, intyI)
{
x = xI;
y = yI;
}
publicintgetX(){
returnx;
}
publicintgetY(){
returny;
}
publicvoiddisplay()
{
System.out.println("------------------");
System.out.println("X: " + x + "\nY: " + y);
System.out.println("------------------");
}
publicstaticvoidmain(Stringargs[]){
Arithmeticvec1 = newArithmetic(5, 8);
vec1.multiplyByScalar(3);
vec1.display();
vec1.divideByScalar(3);
vec1.display();
vec1.addByVector(newVector(6, 2));
vec1.display();
vec1.subtractByVector(newVector(5, 4));
vec1.display();
Operationsvec2 = newOperations(2, -5);
intvalue = vec2.dot(newVector(2, 8));
System.out.println(value);
System.out.println(vec2.magnitude());
System.out.println(vec2.convertToPolar()[0]);
System.out.println(vec2.convertToPolar()[1]);
Polarvec3 = newPolar(6, 100);
Vectorvec4 = vec3.convert2Rec();
vec4.display();
MatrixmyMatrix = newMatrix(newVector(2, 3), newVector(5, 4));
System.out.print("EigenValues: ");
double[] ev = myMatrix.eigenValues();
for(doublei : ev){
System.out.print(i + " ");
}
System.out.println("\ndet: " + myMatrix.det());
}
}