- Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathOperations.java
More file actions
Latest commit
33 lines (29 loc) · 849 Bytes
/
Copy pathOperations.java
File metadata and controls
33 lines (29 loc) · 849 Bytes
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
importjava.lang.Math;
publicclassOperationsextendsVector
{
publicOperations(intxI, intyI){
super(xI, yI);
}
publicintdot(Vectora)
{
return (super.x * a.x) + (super.y * a.y);
}
publicdoublemagnitude(){
doublelen = Math.sqrt( Math.pow(super.x, 2) + Math.pow(super.y, 2) );
super.display();
returnlen;
}
publicdouble[] convertToPolar(){
doubletheta = Math.atan(super.y/super.x) * (180.0/Math.PI);
doubleradius = Math.sqrt( Math.pow(super.x,2) + Math.pow(super.y, 2) );
if(super.x > 0){
if(super.y < 0){
theta = theta + 360;
}
} else {
theta = theta + 180;
}
double[] polar = {radius,theta};
returnpolar;
}
}