Add subtraction and scalar multiplication operators to `Coordinate` and `Coordinate3d`
This commit is contained in:
parent
ed3b577516
commit
0359bacf47
|
|
@ -10,6 +10,12 @@ public record Coordinate(long X, long Y)
|
||||||
|
|
||||||
public static Coordinate operator +(Coordinate left, Coordinate right) =>
|
public static Coordinate operator +(Coordinate left, Coordinate right) =>
|
||||||
new(left.X + right.X, left.Y + right.Y);
|
new(left.X + right.X, left.Y + right.Y);
|
||||||
|
|
||||||
|
public static Coordinate operator -(Coordinate left, Coordinate right) =>
|
||||||
|
new(left.X - right.X, left.Y - right.Y);
|
||||||
|
|
||||||
|
public static Coordinate operator *(Coordinate coord, int amount) =>
|
||||||
|
new(coord.X * amount, coord.Y * amount);
|
||||||
}
|
}
|
||||||
|
|
||||||
public record Coordinate3d(long X, long Y, long Z)
|
public record Coordinate3d(long X, long Y, long Z)
|
||||||
|
|
@ -22,4 +28,10 @@ public record Coordinate3d(long X, long Y, long Z)
|
||||||
|
|
||||||
public static Coordinate3d operator +(Coordinate3d left, Coordinate3d right) =>
|
public static Coordinate3d operator +(Coordinate3d left, Coordinate3d right) =>
|
||||||
new(left.X + right.X, left.Y + right.Y, left.Z + right.Z);
|
new(left.X + right.X, left.Y + right.Y, left.Z + right.Z);
|
||||||
|
|
||||||
|
public static Coordinate3d operator -(Coordinate3d left, Coordinate3d right) =>
|
||||||
|
new(left.X - right.X, left.Y - right.Y, left.Z - right.Z);
|
||||||
|
|
||||||
|
public static Coordinate3d operator *(Coordinate3d coord, int amount) =>
|
||||||
|
new(coord.X * amount, coord.Y * amount, coord.Z * amount);
|
||||||
}
|
}
|
||||||
Loading…
Reference in New Issue