diff --git a/src/util/Pos3.hx b/src/util/Pos3.hx new file mode 100644 index 0000000..bb97e9e --- /dev/null +++ b/src/util/Pos3.hx @@ -0,0 +1,51 @@ +package util; + +import util.Vec.Vec3; + +/** + Reporesents a Point in a 3D `Int` System. + Basicly a wrapper for Vec3 with some extra functions. + `Y` represents the height of the point. +**/ +@:forward(x,y,z) +abstract Pos3(Vec3) from Vec3 to Vec3{ + inline public function new(i:Vec3) { + this = i; + } + + @:op(A + B) + public function add(rhs: Vec3):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):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): 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 + }); + } +}