-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathPoint.java
76 lines (61 loc) · 1.06 KB
/
Point.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
74
75
76
public class Point {
private double x = 0;
private double y = 0;
public Point(){}
public Point(double x, double y)
{
this.x = x;
this.y = y;
}
public double getX()
{
return x;
}
public double getY()
{
return y;
}
public void setX(double f)
{
this.x = f;
}
public void setY(double y)
{
this.y = y;
}
public boolean equal(Point compared)
{
if(this.x == compared.getX()&& this.y == compared.getY())
{
return true;
}
else
{
return false;
}
}
public float get_length()
{
return (float)Math.sqrt(x*x + y*y);
}
public Point minus(Point m)
{
return new Point(x - m.getX(), y - m.getY());
}
public Point add(Point m)
{
return new Point(x + m.getX(), y+ m.getY());
}
public Point divide(double value)
{
return new Point((int) (x/value) , (int)(y/value) );
}
public Point multiply(double d)
{
return new Point( (x * d), y * d);
}
public Point Normal_vector()
{
return new Point( -1* y, x);
}
}