52 lines
901 B
Haxe
52 lines
901 B
Haxe
|
package util;
|
||
|
|
||
|
import util.Vec.Vec3;
|
||
|
|
||
|
/**
|
||
|
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
|
||
|
});
|
||
|
}
|
||
|
}
|