|
|
|
@ -1,8 +1,8 @@
|
|
|
|
|
import { Vector2 } from "three";
|
|
|
|
|
import { Vector2, Vector3 } from "three";
|
|
|
|
|
|
|
|
|
|
export class Matrix2
|
|
|
|
|
{
|
|
|
|
|
el = [1, 0, 0, 1];
|
|
|
|
|
private el = [1, 0, 0, 1];
|
|
|
|
|
set(n11: number, n12: number, n21: number, n22: number)
|
|
|
|
|
{
|
|
|
|
|
let te = this.el;
|
|
|
|
@ -11,12 +11,14 @@ export class Matrix2
|
|
|
|
|
te[2] = n12; te[3] = n22;
|
|
|
|
|
return this;
|
|
|
|
|
}
|
|
|
|
|
applyVec2(vec: Vector2)
|
|
|
|
|
applyVector(vec: Vector2 | Vector3)
|
|
|
|
|
{
|
|
|
|
|
let x = vec.x, y = vec.y;
|
|
|
|
|
let e = this.el;
|
|
|
|
|
vec.x = e[0] * x + e[2] * y;
|
|
|
|
|
vec.y = e[1] * x + e[3] * y;
|
|
|
|
|
|
|
|
|
|
return this;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
setRotate(theta)
|
|
|
|
@ -24,7 +26,8 @@ export class Matrix2
|
|
|
|
|
let el = this.el;
|
|
|
|
|
let c = Math.cos(theta), s = Math.sin(theta);
|
|
|
|
|
|
|
|
|
|
el[0] = c; el[1] = -s;
|
|
|
|
|
el[2] = s; el[3] = c;
|
|
|
|
|
this.set(c, -s,
|
|
|
|
|
s, c);
|
|
|
|
|
return this;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|