added Pos3
This commit is contained in:
parent
e1bb9c3ac3
commit
ceb55e86dc
51
src/util/Pos3.hx
Normal file
51
src/util/Pos3.hx
Normal file
@ -0,0 +1,51 @@
|
||||
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
|
||||
});
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user