Skip to content

Commit 7df366f

Browse files
committed
add int rounding methods
1 parent 2038c19 commit 7df366f

1 file changed

Lines changed: 20 additions & 4 deletions

File tree

src/main/java/org/comroid/api/data/Vector.java

Lines changed: 20 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,22 @@ static Vector of(double... dim) {
6969

7070
Vector setW(double value);
7171

72+
default Vector intCast() {
73+
return map(x -> (int) x);
74+
}
75+
76+
default Vector intRound() {
77+
return map(Math::round);
78+
}
79+
80+
default Vector intFloor() {
81+
return map(Math::floor);
82+
}
83+
84+
default Vector intCeil() {
85+
return map(Math::ceil);
86+
}
87+
7288
default DoubleStream stream() {
7389
return Arrays.stream(toArray());
7490
}
@@ -279,7 +295,7 @@ public final String toString() {
279295
@FieldDefaults(level = AccessLevel.PROTECTED)
280296
class N3 extends N2 {
281297
public static final N3 Zero = new N3();
282-
public static final N3 One = new N3(1, 1, 1);
298+
public static final N3 One = new N3(1, 1, 1);
283299
@Setter double z;
284300

285301
public N3(double x, double y, double z) {
@@ -337,9 +353,9 @@ public N3 convertToEntityAttribute(byte[] dbData) {
337353
@EqualsAndHashCode(callSuper = true)
338354
@FieldDefaults(level = AccessLevel.PROTECTED)
339355
class N4 extends N3 {
340-
public static final N4 Zero = new N4();
341-
public static final N4 One = new N4(1, 1, 1, 1);
342-
@Setter double w;
356+
public static final N4 Zero = new N4();
357+
public static final N4 One = new N4(1, 1, 1, 1);
358+
@Setter double w;
343359

344360
public N4(double x, double y, double z, double w) {
345361
super(x, y, z);

0 commit comments

Comments
 (0)