diff --git a/src/vector2-base.ts b/src/vector2-base.ts index d4bd730..7e25450 100644 --- a/src/vector2-base.ts +++ b/src/vector2-base.ts @@ -1,4 +1,5 @@ import { VectorBase } from './vector-base'; +import { Vector2 } from './vector2'; export abstract class Vector2Base extends VectorBase { get 0() { @@ -32,4 +33,12 @@ export abstract class Vector2Base extends VectorBase { set y(n: number) { this[1] = n; } + + get xy() { + return new Vector2(this.x, this.y); + } + + get yx() { + return new Vector2(this.y, this.x); + } } diff --git a/src/vector3-base.ts b/src/vector3-base.ts index ced02dc..9156118 100644 --- a/src/vector3-base.ts +++ b/src/vector3-base.ts @@ -1,4 +1,6 @@ import { Vector2Base } from './vector2-base'; +import { Vector2 } from './vector2'; +import { Vector3 } from './vector3'; export abstract class Vector3Base extends Vector2Base { get 2() { @@ -16,4 +18,44 @@ export abstract class Vector3Base extends Vector2Base { set z(n: number) { this[2] = n; } + + get xz() { + return new Vector2(this.x, this.z); + } + + get yz() { + return new Vector2(this.y, this.z); + } + + get zx() { + return new Vector2(this.z, this.x); + } + + get zy() { + return new Vector2(this.z, this.y); + } + + get xyz() { + return new Vector3(this.x, this.y, this.z); + } + + get xzy() { + return new Vector3(this.x, this.z, this.y); + } + + get yxz() { + return new Vector3(this.y, this.x, this.z); + } + + get yzx() { + return new Vector3(this.y, this.z, this.x); + } + + get zxy() { + return new Vector3(this.z, this.x, this.y); + } + + get zyx() { + return new Vector3(this.z, this.y, this.x); + } } diff --git a/src/vector4-base.ts b/src/vector4-base.ts index 4ac5061..5ca145d 100644 --- a/src/vector4-base.ts +++ b/src/vector4-base.ts @@ -1,4 +1,7 @@ import { Vector3Base } from './vector3-base'; +import { Vector2 } from './vector2'; +import { Vector3 } from './vector3'; +import { Vector4 } from './vector4'; export abstract class Vector4Base extends Vector3Base { get 3() { @@ -16,4 +19,196 @@ export abstract class Vector4Base extends Vector3Base { set w(n: number) { this[3] = n; } + + get xw() { + return new Vector2(this.x, this.w); + } + + get yw() { + return new Vector2(this.y, this.w); + } + + get zw() { + return new Vector2(this.z, this.w); + } + + get wx() { + return new Vector2(this.w, this.x); + } + + get wy() { + return new Vector2(this.w, this.y); + } + + get wz() { + return new Vector2(this.w, this.z); + } + + get xyw() { + return new Vector3(this.x, this.y, this.w); + } + + get xzw() { + return new Vector3(this.x, this.z, this.w); + } + + get xwy() { + return new Vector3(this.x, this.w, this.y); + } + + get xwz() { + return new Vector3(this.x, this.w, this.z); + } + + get yxw() { + return new Vector3(this.y, this.x, this.w); + } + + get yzw() { + return new Vector3(this.y, this.z, this.w); + } + + get ywx() { + return new Vector3(this.y, this.w, this.x); + } + + get ywz() { + return new Vector3(this.y, this.w, this.z); + } + + get zxw() { + return new Vector3(this.z, this.x, this.w); + } + + get zyw() { + return new Vector3(this.z, this.y, this.w); + } + + get zwx() { + return new Vector3(this.z, this.w, this.x); + } + + get zwy() { + return new Vector3(this.z, this.w, this.y); + } + + get wxy() { + return new Vector3(this.w, this.x, this.y); + } + + get wxz() { + return new Vector3(this.w, this.x, this.z); + } + + get wyx() { + return new Vector3(this.w, this.y, this.x); + } + + get wyz() { + return new Vector3(this.w, this.y, this.z); + } + + get wzx() { + return new Vector3(this.w, this.z, this.x); + } + + get wzy() { + return new Vector3(this.w, this.z, this.y); + } + + get xyzw() { + return new Vector4(this.x, this.y, this.z, this.w); + } + + get xywz() { + return new Vector4(this.x, this.y, this.w, this.z); + } + + get xzyw() { + return new Vector4(this.x, this.z, this.y, this.w); + } + + get xzwy() { + return new Vector4(this.x, this.z, this.w, this.y); + } + + get xwyz() { + return new Vector4(this.x, this.w, this.y, this.z); + } + + get xwzy() { + return new Vector4(this.x, this.w, this.z, this.y); + } + + get yxzw() { + return new Vector4(this.y, this.x, this.z, this.w); + } + + get yxwz() { + return new Vector4(this.y, this.x, this.w, this.z); + } + + get yzxw() { + return new Vector4(this.y, this.z, this.x, this.w); + } + + get yzwx() { + return new Vector4(this.y, this.z, this.w, this.x); + } + + get ywxz() { + return new Vector4(this.y, this.w, this.x, this.z); + } + + get ywzx() { + return new Vector4(this.y, this.w, this.z, this.x); + } + + get zxyw() { + return new Vector4(this.z, this.x, this.y, this.w); + } + + get zxwy() { + return new Vector4(this.z, this.x, this.w, this.y); + } + + get zyxw() { + return new Vector4(this.z, this.y, this.x, this.w); + } + + get zywx() { + return new Vector4(this.z, this.y, this.w, this.x); + } + + get zwxy() { + return new Vector4(this.z, this.w, this.x, this.y); + } + + get zwyx() { + return new Vector4(this.z, this.w, this.y, this.x); + } + + get wxyz() { + return new Vector4(this.w, this.x, this.y, this.z); + } + + get wxzy() { + return new Vector4(this.w, this.x, this.z, this.y); + } + + get wyxz() { + return new Vector4(this.w, this.y, this.x, this.z); + } + + get wyzx() { + return new Vector4(this.w, this.y, this.z, this.x); + } + + get wzxy() { + return new Vector4(this.w, this.z, this.x, this.y); + } + + get wzyx() { + return new Vector4(this.w, this.z, this.y, this.x); + } }