-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathPoint.java
85 lines (76 loc) · 1.33 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
77
78
79
80
81
82
83
84
85
/**
* Created by Nick on 11/25/2015.
*/
public class Point
{
public double x;
public double y;
public double z;
public Point()
{
x = 0;
y = 0;
z = 0;
}
public Point(double x, double y, double z)
{
this.x = x;
this.y = y;
this.z = z;
}
public Point(double x, double y)
{
this.x = x;
this.y = y;
this.z = 0;
}
public void setX(double x)
{
this.x = x;
}
public double getX()
{
return x;
}
public void setY(double y)
{
this.y = y;
}
public double getY()
{
return y;
}
public void setZ(double z)
{
this.z = z;
}
public double getZ()
{
return z;
}
public void change(double x, double y, double z)
{
this.x = x;
this.y = y;
this.z = z;
}
public void translate(double Tx, double Ty, double Tz)
{
this.x += Tx;
this.y += Ty;
this.z += Tz;
}
public static double distanceBetween(Point a, Point b)
{
double x1, y1, x2, y2;
double x, y, d;
x1 = a.getX();
y1 = a.getY();
x2 = b.getX();
y2 = b.getY();
x = x2-x1;
y = y2-y1;
d = Math.sqrt(x*x + y*y);
return d;
}
}