-
Notifications
You must be signed in to change notification settings - Fork 16
Expand file tree
/
Copy pathPointD.java
More file actions
85 lines (68 loc) · 1.48 KB
/
PointD.java
File metadata and controls
85 lines (68 loc) · 1.48 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
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
package clipper2.core;
/**
* The PointD structure is used to represent a single floating point coordinate.
* A series of these coordinates forms a PathD structure.
*/
public final class PointD {
public double x;
public double y;
public PointD() {
}
public PointD(PointD pt) {
x = pt.x;
y = pt.y;
}
public PointD(Point64 pt) {
x = pt.x;
y = pt.y;
}
public PointD(PointD pt, double scale) {
x = pt.x * scale;
y = pt.y * scale;
}
public PointD(Point64 pt, double scale) {
x = pt.x * scale;
y = pt.y * scale;
}
public PointD(long x, long y) {
this.x = x;
this.y = y;
}
public PointD(double x, double y) {
this.x = x;
this.y = y;
}
public void Negate() {
x = -x;
y = -y;
}
public void negate() {
Negate();
}
@Override
public final String toString() {
return String.format("(%1$f,%2$f) ", x, y);
}
public static boolean opEquals(PointD lhs, PointD rhs) {
return InternalClipper.IsAlmostZero(lhs.x - rhs.x) && InternalClipper.IsAlmostZero(lhs.y - rhs.y);
}
public static boolean opNotEquals(PointD lhs, PointD rhs) {
return !InternalClipper.IsAlmostZero(lhs.x - rhs.x) || !InternalClipper.IsAlmostZero(lhs.y - rhs.y);
}
@Override
public final boolean equals(Object obj) {
if (obj instanceof PointD) {
PointD p = (PointD) obj;
return opEquals(this, p);
}
return false;
}
@Override
public final int hashCode() {
return Double.hashCode(x * 31 + y);
}
@Override
public PointD clone() {
return new PointD(x, y);
}
}