-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathVector.java
More file actions
30 lines (30 loc) · 797 Bytes
/
Vector.java
File metadata and controls
30 lines (30 loc) · 797 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
package fsa;
public class Vector {
public double x,y;
public Vector(double x, double y) {
this.x = x;
this.y = y;
}
public int getX() {
return (int)x;
}
public int getY() {
return (int)y;
}
//link a vector to a point to get the end
public static Vector add(Vector a,Vector b)
{
return new Vector(a.x+b.x,a.y+b.y);
}
public static Vector minus(Vector a,Vector b)
{
return new Vector(a.x-b.x,a.y-b.y);
}
public Vector rotate(double t)
{
ComplexNumber complexValue = new ComplexNumber(x,y);
ComplexNumber factor = ComplexNumber.Eto2PIiT(t);
ComplexNumber result = ComplexNumber.multiply(complexValue, factor);
return new Vector(result.x,result.y);
}
}