2022-12-19 20:06:23 +00:00
|
|
|
package lib;
|
2022-04-26 17:42:58 +00:00
|
|
|
|
2022-12-19 20:06:23 +00:00
|
|
|
import lib.Vec.Vec3;
|
2022-04-26 17:42:58 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
Reporesents a Point in a 3D `Int` System.
|
|
|
|
Basicly a wrapper for Vec3<Int> with some extra functions.
|
|
|
|
`Y` represents the height of the point.
|
|
|
|
**/
|
|
|
|
@:forward(x,y,z)
|
|
|
|
abstract Pos3(Vec3<Int>) from Vec3<Int> to Vec3<Int>{
|
|
|
|
inline public function new(i:Vec3<Int>) {
|
|
|
|
this = i;
|
|
|
|
}
|
|
|
|
|
|
|
|
@:op(A + B)
|
|
|
|
public function add(rhs: Vec3<Int>):Pos3 {
|
|
|
|
return new Pos3({
|
|
|
|
y: this.y + rhs.y,
|
|
|
|
x: this.x + rhs.x,
|
|
|
|
z: this.z + rhs.z
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
|
|
|
@:op(A - B)
|
|
|
|
public function sub(rhs: Vec3<Int>):Pos3 {
|
|
|
|
return new Pos3({
|
|
|
|
y: this.y - rhs.y,
|
|
|
|
x: this.x - rhs.x,
|
|
|
|
z: this.z - rhs.z
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
|
|
|
@:op(A * B)
|
|
|
|
public function multiply(rhs: Vec3<Int>): Pos3 {
|
|
|
|
return new Pos3({
|
|
|
|
y: this.y * rhs.y,
|
|
|
|
x: this.x * rhs.x,
|
|
|
|
z: this.z * rhs.z
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
|
|
|
@:op(-A)
|
|
|
|
public function negate(): Pos3 {
|
|
|
|
return new Pos3({
|
|
|
|
y: -this.y,
|
|
|
|
x: -this.x,
|
|
|
|
z: -this.z
|
|
|
|
});
|
|
|
|
}
|
|
|
|
}
|