-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathPoint.java
More file actions
64 lines (49 loc) · 1.24 KB
/
Point.java
File metadata and controls
64 lines (49 loc) · 1.24 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
package ImageAnalysisLibrary;
public class Point {
public double x,y,z;
public Point(){
x=y=z=0;
}
public Point(double X,double Y,double Z){
x=X;
y=Y;
z=Z;
}
public Point(Point copy){
this.x=copy.x;
this.y=copy.y;
this.z =copy.z;
}
public void Add(Point B) {
this.x+=B.x;
this.y+=B.y;
this.z+=B.z;
}
public double Distance(Point B) {
double distance ;
distance = Math.sqrt((B.x - this.x)*(B.x - this.x) + (B.y - this.y)*(B.y - this.y) + (B.z - this.z)*(B.z - this.z));
return distance;
}
public void Divide_All(int Divider) {
this.x /= Divider;
this.y /= Divider;
this.z /= Divider;
}
@Override
public String toString() {
return "[X: " + this.x +"]" +" [Y: " + this.y +"]" + " [Z: " + this.z +"]"+ "\n";
}
public double X_Linear_Interpolation(Point B,double y_value) {
return (((y_value - this.y)*(B.x - this.x)) / (B.y - this.y) + this.x);
}
public double Y_Linear_Interpolation(Point B,double x_value) {
return (x_value - this.x)*(B.y - this.y) / (B.x - this.x) + this.y;
}
public Point lerp(Point B ,double amount) {
Point ret = new Point();
ret.x = this.x + (B.x -this.x)*amount;
ret.y = this.y + (B.y -this.y)*amount;
ret.z = this.z + (B.z -this.z)*amount;
return ret;
}
}