glmaths 0.0.2 → 0.0.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,34 +1,34 @@
1
1
  import { describe, it } from 'node:test'
2
2
  import assert from 'node:assert/strict'
3
- import glmaths, { Mat2, mat2, Vec2 } from '../dist/esm/glmaths'
3
+ import glmaths, { mat2, Mat2, vec2, Vec2 } from '../dist/esm/glmaths'
4
4
 
5
5
  function closeTo(actual: number, expected: number, numDigits = 5) { const pass = Math.abs(actual - expected) < Math.pow(10, -numDigits) / 2; assert.ok(pass, `expected ${actual} to be close to ${expected}`) }
6
6
 
7
7
  describe('Mat2', () => {
8
8
  describe('constructor', () => {
9
9
  it('creates zero matrix by default', () => {
10
- const m = new Mat2()
10
+ const m = mat2()
11
11
  assert.strictEqual(m[0], 0)
12
12
  assert.strictEqual(m[1], 0)
13
13
  assert.strictEqual(m[2], 0)
14
14
  assert.strictEqual(m[3], 0)
15
15
  })
16
16
  it('creates with given values', () => {
17
- const m = new Mat2(1, 2, 3, 4)
17
+ const m = mat2(1, 2, 3, 4)
18
18
  assert.strictEqual(m[0], 1)
19
19
  assert.strictEqual(m[1], 2)
20
20
  assert.strictEqual(m[2], 3)
21
21
  assert.strictEqual(m[3], 4)
22
22
  })
23
23
  it('extends Float32Array with length 4', () => {
24
- assert.ok(new Mat2() instanceof Float32Array)
25
- assert.strictEqual(new Mat2().length, 4)
24
+ assert.ok(mat2() instanceof Float32Array)
25
+ assert.strictEqual(mat2().length, 4)
26
26
  })
27
27
  })
28
28
 
29
29
  describe('identity', () => {
30
30
  it('creates identity matrix', () => {
31
- const m = Mat2.identity
31
+ const m = mat2.identity
32
32
  assert.strictEqual(m[0], 1)
33
33
  assert.strictEqual(m[1], 0)
34
34
  assert.strictEqual(m[2], 0)
@@ -38,7 +38,7 @@ describe('Mat2', () => {
38
38
 
39
39
  describe('clone', () => {
40
40
  it('creates independent copy', () => {
41
- const a = new Mat2(1, 2, 3, 4)
41
+ const a = mat2(1, 2, 3, 4)
42
42
  const b = a.clone()
43
43
  assert.strictEqual(b[0], 1)
44
44
  b[0] = 99
@@ -48,7 +48,7 @@ describe('Mat2', () => {
48
48
 
49
49
  describe('transpose', () => {
50
50
  it('transposes in-place', () => {
51
- const m = new Mat2(1, 2, 3, 4)
51
+ const m = mat2(1, 2, 3, 4)
52
52
  const r = m.transpose()
53
53
  assert.strictEqual(r[0], 1)
54
54
  assert.strictEqual(r[1], 3)
@@ -56,8 +56,8 @@ describe('Mat2', () => {
56
56
  assert.strictEqual(r[3], 4)
57
57
  })
58
58
  it('transposes to out', () => {
59
- const m = new Mat2(1, 2, 3, 4)
60
- const out = new Mat2()
59
+ const m = mat2(1, 2, 3, 4)
60
+ const out = mat2()
61
61
  m.transpose(out)
62
62
  assert.strictEqual(out[0], 1)
63
63
  assert.strictEqual(out[1], 3)
@@ -68,33 +68,33 @@ describe('Mat2', () => {
68
68
 
69
69
  describe('invert', () => {
70
70
  it('inverts a matrix', () => {
71
- const m = Mat2.identity
71
+ const m = mat2.identity
72
72
  const inv = m.invert()
73
73
  assert.notStrictEqual(inv, null)
74
74
  assert.strictEqual(m[0], 1)
75
75
  assert.strictEqual(m[3], 1)
76
76
  })
77
77
  it('inverts correctly', () => {
78
- const m = new Mat2(1, 2, 3, 4)
79
- const out = new Mat2()
78
+ const m = mat2(1, 2, 3, 4)
79
+ const out = mat2()
80
80
  m.invert(out)
81
81
  // m * m^-1 = identity
82
- const result = m.multiply(out!, new Mat2())
82
+ const result = m.multiply(out!, mat2())
83
83
  closeTo(result[0], 1)
84
84
  closeTo(result[1], 0)
85
85
  closeTo(result[2], 0)
86
86
  closeTo(result[3], 1)
87
87
  })
88
88
  it('returns null for singular matrix', () => {
89
- const m = new Mat2(1, 2, 2, 4)
90
- assert.strictEqual(m.invert(new Mat2()), null)
89
+ const m = mat2(1, 2, 2, 4)
90
+ assert.strictEqual(m.invert(mat2()), null)
91
91
  })
92
92
  })
93
93
 
94
94
  describe('adjoint', () => {
95
95
  it('calculates adjugate', () => {
96
- const m = new Mat2(1, 2, 3, 4)
97
- const out = new Mat2()
96
+ const m = mat2(1, 2, 3, 4)
97
+ const out = mat2()
98
98
  m.adjoint(out)
99
99
  assert.strictEqual(out[0], 4)
100
100
  assert.strictEqual(out[1], -2)
@@ -105,17 +105,17 @@ describe('Mat2', () => {
105
105
 
106
106
  describe('determinant', () => {
107
107
  it('calculates determinant', () => {
108
- const m = new Mat2(1, 2, 3, 4)
108
+ const m = mat2(1, 2, 3, 4)
109
109
  assert.strictEqual(m.determinant(), -2)
110
110
  })
111
111
  it('identity determinant is 1', () => {
112
- assert.strictEqual(Mat2.identity.determinant(), 1)
112
+ assert.strictEqual(mat2.identity.determinant(), 1)
113
113
  })
114
114
  })
115
115
 
116
116
  describe('rotate', () => {
117
117
  it('rotates identity by 90 degrees', () => {
118
- const m = Mat2.identity
118
+ const m = mat2.identity
119
119
  const r = m.rotate(Math.PI / 2)
120
120
  closeTo(r[0], 0)
121
121
  closeTo(r[1], 1)
@@ -126,8 +126,8 @@ describe('Mat2', () => {
126
126
 
127
127
  describe('scale', () => {
128
128
  it('scales identity matrix', () => {
129
- const m = Mat2.identity
130
- const r = m.scale(new Vec2(2, 3))
129
+ const m = mat2.identity
130
+ const r = m.scale(vec2(2, 3))
131
131
  assert.strictEqual(r[0], 2)
132
132
  assert.strictEqual(r[1], 0)
133
133
  assert.strictEqual(r[2], 0)
@@ -137,7 +137,7 @@ describe('Mat2', () => {
137
137
 
138
138
  describe('static fromRotation', () => {
139
139
  it('creates rotation matrix', () => {
140
- const m = Mat2.fromRotation(Math.PI / 2)
140
+ const m = mat2.fromRotation(Math.PI / 2)
141
141
  closeTo(m[0], 0)
142
142
  closeTo(m[1], 1)
143
143
  closeTo(m[2], -1)
@@ -147,7 +147,7 @@ describe('Mat2', () => {
147
147
 
148
148
  describe('static fromScaling', () => {
149
149
  it('creates scaling matrix', () => {
150
- const m = Mat2.fromScaling(new Vec2(2, 3))
150
+ const m = mat2.fromScaling(vec2(2, 3))
151
151
  assert.strictEqual(m[0], 2)
152
152
  assert.strictEqual(m[1], 0)
153
153
  assert.strictEqual(m[2], 0)
@@ -157,9 +157,9 @@ describe('Mat2', () => {
157
157
 
158
158
  describe('multiply', () => {
159
159
  it('multiplies two matrices', () => {
160
- const a = new Mat2(1, 2, 3, 4)
161
- const b = new Mat2(5, 6, 7, 8)
162
- const out = new Mat2()
160
+ const a = mat2(1, 2, 3, 4)
161
+ const b = mat2(5, 6, 7, 8)
162
+ const out = mat2()
163
163
  a.multiply(b, out)
164
164
  assert.strictEqual(out[0], 1 * 5 + 3 * 6)
165
165
  assert.strictEqual(out[1], 2 * 5 + 4 * 6)
@@ -167,9 +167,9 @@ describe('Mat2', () => {
167
167
  assert.strictEqual(out[3], 2 * 7 + 4 * 8)
168
168
  })
169
169
  it('identity * A = A', () => {
170
- const a = new Mat2(1, 2, 3, 4)
171
- const out = new Mat2()
172
- Mat2.identity.multiply(a, out)
170
+ const a = mat2(1, 2, 3, 4)
171
+ const out = mat2()
172
+ mat2.identity.multiply(a, out)
173
173
  assert.strictEqual(out[0], 1)
174
174
  assert.strictEqual(out[1], 2)
175
175
  assert.strictEqual(out[2], 3)
@@ -179,9 +179,9 @@ describe('Mat2', () => {
179
179
 
180
180
  describe('plus / minus', () => {
181
181
  it('adds matrices', () => {
182
- const a = new Mat2(1, 2, 3, 4)
183
- const b = new Mat2(5, 6, 7, 8)
184
- const out = new Mat2()
182
+ const a = mat2(1, 2, 3, 4)
183
+ const b = mat2(5, 6, 7, 8)
184
+ const out = mat2()
185
185
  a.plus(b, out)
186
186
  assert.strictEqual(out[0], 6)
187
187
  assert.strictEqual(out[1], 8)
@@ -189,9 +189,9 @@ describe('Mat2', () => {
189
189
  assert.strictEqual(out[3], 12)
190
190
  })
191
191
  it('subtracts matrices', () => {
192
- const a = new Mat2(5, 6, 7, 8)
193
- const b = new Mat2(1, 2, 3, 4)
194
- const out = new Mat2()
192
+ const a = mat2(5, 6, 7, 8)
193
+ const b = mat2(1, 2, 3, 4)
194
+ const out = mat2()
195
195
  a.minus(b, out)
196
196
  assert.strictEqual(out[0], 4)
197
197
  assert.strictEqual(out[1], 4)
@@ -202,7 +202,7 @@ describe('Mat2', () => {
202
202
 
203
203
  describe('scaleScalar', () => {
204
204
  it('scales all elements', () => {
205
- const m = new Mat2(1, 2, 3, 4)
205
+ const m = mat2(1, 2, 3, 4)
206
206
  const r = m.scaleScalar(2)
207
207
  assert.strictEqual(r[0], 2)
208
208
  assert.strictEqual(r[1], 4)
@@ -213,31 +213,31 @@ describe('Mat2', () => {
213
213
 
214
214
  describe('equals / exactEquals', () => {
215
215
  it('exactEquals', () => {
216
- assert.strictEqual(new Mat2(1, 2, 3, 4).exactEquals(new Mat2(1, 2, 3, 4)), true)
217
- assert.strictEqual(new Mat2(1, 2, 3, 4).exactEquals(new Mat2(1, 2, 3, 5)), false)
216
+ assert.strictEqual(mat2(1, 2, 3, 4).exactEquals(mat2(1, 2, 3, 4)), true)
217
+ assert.strictEqual(mat2(1, 2, 3, 4).exactEquals(mat2(1, 2, 3, 5)), false)
218
218
  })
219
219
  it('equals with epsilon', () => {
220
- const a = new Mat2(1, 2, 3, 4)
221
- const b = new Mat2(1 + glmaths.EPSILON * 0.1, 2, 3, 4)
220
+ const a = mat2(1, 2, 3, 4)
221
+ const b = mat2(1 + glmaths.EPSILON * 0.1, 2, 3, 4)
222
222
  assert.strictEqual(a.equals(b), true)
223
223
  })
224
224
  })
225
225
 
226
226
  describe('toString', () => {
227
227
  it('returns string representation', () => {
228
- assert.strictEqual(new Mat2(1, 2, 3, 4).toString(), 'mat2x2(1, 2, 3, 4)')
228
+ assert.strictEqual(mat2(1, 2, 3, 4).toString(), 'mat2x2(1, 2, 3, 4)')
229
229
  })
230
230
  })
231
231
 
232
232
  describe('frob', () => {
233
233
  it('frobenius norm of identity', () => {
234
- closeTo(Mat2.identity.frob(), Math.sqrt(2))
234
+ closeTo(mat2.identity.frob(), Math.sqrt(2))
235
235
  })
236
236
  })
237
237
 
238
238
  describe('LDU', () => {
239
239
  it('factors a matrix', () => {
240
- const m = new Mat2(4, 3, 6, 3)
240
+ const m = mat2(4, 3, 6, 3)
241
241
  const [L, D, U] = m.LDU()
242
242
  assert.ok(L instanceof Mat2)
243
243
  assert.ok(D instanceof Mat2)
@@ -255,20 +255,20 @@ describe('Mat2', () => {
255
255
 
256
256
  describe('mat * vec operators', () => {
257
257
  it('Mat2 * Vec2 rotation', () => {
258
- const m = Mat2.fromRotation(Math.PI / 3)
259
- const v = new Vec2(3, 4)
260
- const expected = v.transformMat2(m, new Vec2())
258
+ const m = mat2.fromRotation(Math.PI / 3)
259
+ const v = vec2(3, 4)
260
+ const expected = v.transformMat2(m, vec2())
261
261
  const r = m * v
262
262
  assert.ok(r instanceof Vec2)
263
263
  closeTo(r.x, expected.x)
264
264
  closeTo(r.y, expected.y)
265
265
  })
266
266
  it('Mat2 * Vec2 scale + rotation', () => {
267
- const m = Mat2.fromScaling(new Vec2(2, 3))
268
- const rot = Mat2.fromRotation(Math.PI / 5)
269
- const combined = rot.multiply(m, new Mat2())
270
- const v = new Vec2(7, -2)
271
- const expected = v.transformMat2(combined, new Vec2())
267
+ const m = mat2.fromScaling(vec2(2, 3))
268
+ const rot = mat2.fromRotation(Math.PI / 5)
269
+ const combined = rot.multiply(m, mat2())
270
+ const v = vec2(7, -2)
271
+ const expected = v.transformMat2(combined, vec2())
272
272
  const r = combined * v
273
273
  closeTo(r.x, expected.x)
274
274
  closeTo(r.y, expected.y)
@@ -1,6 +1,6 @@
1
1
  import { describe, it } from 'node:test'
2
2
  import assert from 'node:assert/strict'
3
- import glmaths, { Mat2x3, mat2x3, Vec2 } from '../dist/esm/glmaths'
3
+ import glmaths, { Mat2x3, mat2x3, vec2, Vec2 } from '../dist/esm/glmaths'
4
4
 
5
5
  function closeTo(actual: number, expected: number, numDigits = 5) {
6
6
  const pass = Math.abs(actual - expected) < Math.pow(10, -numDigits) / 2
@@ -10,23 +10,23 @@ function closeTo(actual: number, expected: number, numDigits = 5) {
10
10
  describe('Mat2x3', () => {
11
11
  describe('constructor', () => {
12
12
  it('creates zero matrix by default', () => {
13
- const m = new Mat2x3()
13
+ const m = mat2x3()
14
14
  for (let i = 0; i < 6; i++) assert.strictEqual(m[i], 0)
15
15
  })
16
16
  it('creates with given values', () => {
17
- const m = new Mat2x3(1, 2, 3, 4, 5, 6)
17
+ const m = mat2x3(1, 2, 3, 4, 5, 6)
18
18
  assert.strictEqual(m[0], 1)
19
19
  assert.strictEqual(m[5], 6)
20
20
  })
21
21
  it('extends Float32Array with length 6', () => {
22
- assert.ok(new Mat2x3() instanceof Float32Array)
23
- assert.strictEqual(new Mat2x3().length, 6)
22
+ assert.ok(mat2x3() instanceof Float32Array)
23
+ assert.strictEqual(mat2x3().length, 6)
24
24
  })
25
25
  })
26
26
 
27
27
  describe('identity', () => {
28
28
  it('creates identity', () => {
29
- const m = Mat2x3.identity
29
+ const m = mat2x3.identity
30
30
  assert.strictEqual(m[0], 1)
31
31
  assert.strictEqual(m[1], 0)
32
32
  assert.strictEqual(m[2], 0)
@@ -38,18 +38,18 @@ describe('Mat2x3', () => {
38
38
 
39
39
  describe('determinant', () => {
40
40
  it('identity determinant is 1', () => {
41
- assert.strictEqual(Mat2x3.identity.determinant(), 1)
41
+ assert.strictEqual(mat2x3.identity.determinant(), 1)
42
42
  })
43
43
  it('calculates determinant', () => {
44
- const m = new Mat2x3(1, 2, 3, 4, 5, 6)
44
+ const m = mat2x3(1, 2, 3, 4, 5, 6)
45
45
  assert.strictEqual(m.determinant(), 1 * 4 - 2 * 3)
46
46
  })
47
47
  })
48
48
 
49
49
  describe('invert', () => {
50
50
  it('inverts identity to identity', () => {
51
- const m = Mat2x3.identity
52
- const out = new Mat2x3()
51
+ const m = mat2x3.identity
52
+ const out = mat2x3()
53
53
  m.invert(out)
54
54
  assert.strictEqual(out[0], 1)
55
55
  assert.strictEqual(out[3], 1)
@@ -57,15 +57,15 @@ describe('Mat2x3', () => {
57
57
  assert.strictEqual(out[5], 0)
58
58
  })
59
59
  it('returns null for singular matrix', () => {
60
- const m = new Mat2x3(1, 2, 2, 4, 0, 0)
61
- assert.strictEqual(m.invert(new Mat2x3()), null)
60
+ const m = mat2x3(1, 2, 2, 4, 0, 0)
61
+ assert.strictEqual(m.invert(mat2x3()), null)
62
62
  })
63
63
  it('inverse * original = identity (for the 2x2 part)', () => {
64
- const m = new Mat2x3(2, 1, 1, 3, 5, 7)
65
- const inv = new Mat2x3()
64
+ const m = mat2x3(2, 1, 1, 3, 5, 7)
65
+ const inv = mat2x3()
66
66
  m.invert(inv)
67
- const result = new Mat2x3()
68
- Mat2x3.identity.multiply.call(m, inv!, result)
67
+ const result = mat2x3()
68
+ mat2x3.identity.multiply.call(m, inv!, result)
69
69
  closeTo(result[0], 1)
70
70
  closeTo(result[1], 0)
71
71
  closeTo(result[2], 0)
@@ -75,7 +75,7 @@ describe('Mat2x3', () => {
75
75
 
76
76
  describe('rotate', () => {
77
77
  it('rotates identity by PI/2', () => {
78
- const m = Mat2x3.identity
78
+ const m = mat2x3.identity
79
79
  const r = m.rotate(Math.PI / 2)
80
80
  closeTo(r[0], 0)
81
81
  closeTo(r[1], 1)
@@ -86,8 +86,8 @@ describe('Mat2x3', () => {
86
86
 
87
87
  describe('scale', () => {
88
88
  it('scales identity', () => {
89
- const m = Mat2x3.identity
90
- const r = m.scale(new Vec2(2, 3))
89
+ const m = mat2x3.identity
90
+ const r = m.scale(vec2(2, 3))
91
91
  assert.strictEqual(r[0], 2)
92
92
  assert.strictEqual(r[3], 3)
93
93
  })
@@ -95,8 +95,8 @@ describe('Mat2x3', () => {
95
95
 
96
96
  describe('translate', () => {
97
97
  it('translates identity', () => {
98
- const m = Mat2x3.identity
99
- const r = m.translate(new Vec2(5, 10))
98
+ const m = mat2x3.identity
99
+ const r = m.translate(vec2(5, 10))
100
100
  assert.strictEqual(r[4], 5)
101
101
  assert.strictEqual(r[5], 10)
102
102
  })
@@ -114,7 +114,7 @@ describe('Mat2x3', () => {
114
114
 
115
115
  describe('static fromScaling', () => {
116
116
  it('creates scaling matrix', () => {
117
- const m = Mat2x3.fromScaling(new Vec2(2, 3))
117
+ const m = Mat2x3.fromScaling(vec2(2, 3))
118
118
  assert.strictEqual(m[0], 2)
119
119
  assert.strictEqual(m[3], 3)
120
120
  })
@@ -122,7 +122,7 @@ describe('Mat2x3', () => {
122
122
 
123
123
  describe('static fromTranslation', () => {
124
124
  it('creates translation matrix', () => {
125
- const m = Mat2x3.fromTranslation(new Vec2(5, 10))
125
+ const m = Mat2x3.fromTranslation(vec2(5, 10))
126
126
  assert.strictEqual(m[0], 1)
127
127
  assert.strictEqual(m[3], 1)
128
128
  assert.strictEqual(m[4], 5)
@@ -132,26 +132,26 @@ describe('Mat2x3', () => {
132
132
 
133
133
  describe('multiply', () => {
134
134
  it('identity * A = A', () => {
135
- const a = new Mat2x3(1, 2, 3, 4, 5, 6)
136
- const out = new Mat2x3()
137
- Mat2x3.identity.multiply(a, out)
135
+ const a = mat2x3(1, 2, 3, 4, 5, 6)
136
+ const out = mat2x3()
137
+ mat2x3.identity.multiply(a, out)
138
138
  for (let i = 0; i < 6; i++) assert.strictEqual(out[i], a[i])
139
139
  })
140
140
  })
141
141
 
142
142
  describe('plus / minus', () => {
143
143
  it('adds', () => {
144
- const a = new Mat2x3(1, 2, 3, 4, 5, 6)
145
- const b = new Mat2x3(6, 5, 4, 3, 2, 1)
146
- const out = new Mat2x3()
144
+ const a = mat2x3(1, 2, 3, 4, 5, 6)
145
+ const b = mat2x3(6, 5, 4, 3, 2, 1)
146
+ const out = mat2x3()
147
147
  a.plus(b, out)
148
148
  assert.strictEqual(out[0], 7)
149
149
  assert.strictEqual(out[5], 7)
150
150
  })
151
151
  it('subtracts', () => {
152
- const a = new Mat2x3(6, 5, 4, 3, 2, 1)
153
- const b = new Mat2x3(1, 2, 3, 4, 5, 6)
154
- const out = new Mat2x3()
152
+ const a = mat2x3(6, 5, 4, 3, 2, 1)
153
+ const b = mat2x3(1, 2, 3, 4, 5, 6)
154
+ const out = mat2x3()
155
155
  a.minus(b, out)
156
156
  assert.strictEqual(out[0], 5)
157
157
  assert.strictEqual(out[5], -5)
@@ -160,27 +160,27 @@ describe('Mat2x3', () => {
160
160
 
161
161
  describe('equals / exactEquals', () => {
162
162
  it('exactEquals', () => {
163
- const a = new Mat2x3(1, 2, 3, 4, 5, 6)
164
- const b = new Mat2x3(1, 2, 3, 4, 5, 6)
163
+ const a = mat2x3(1, 2, 3, 4, 5, 6)
164
+ const b = mat2x3(1, 2, 3, 4, 5, 6)
165
165
  assert.strictEqual(a.exactEquals(b), true)
166
166
  })
167
167
  it('equals with epsilon', () => {
168
- const a = new Mat2x3(1, 2, 3, 4, 5, 6)
169
- const b = new Mat2x3(1 + glmaths.EPSILON * 0.1, 2, 3, 4, 5, 6)
168
+ const a = mat2x3(1, 2, 3, 4, 5, 6)
169
+ const b = mat2x3(1 + glmaths.EPSILON * 0.1, 2, 3, 4, 5, 6)
170
170
  assert.strictEqual(a.equals(b), true)
171
171
  })
172
172
  })
173
173
 
174
174
  describe('toString', () => {
175
175
  it('returns string', () => {
176
- const m = new Mat2x3(1, 0, 0, 1, 0, 0)
176
+ const m = mat2x3(1, 0, 0, 1, 0, 0)
177
177
  assert.ok(m.toString().includes('mat2x3'))
178
178
  })
179
179
  })
180
180
 
181
181
  describe('frob', () => {
182
182
  it('frobenius norm of identity', () => {
183
- closeTo(Mat2x3.identity.frob(), Math.sqrt(3))
183
+ closeTo(mat2x3.identity.frob(), Math.sqrt(3))
184
184
  })
185
185
  })
186
186
 
@@ -194,21 +194,21 @@ describe('Mat2x3', () => {
194
194
  describe('mat * vec operators', () => {
195
195
  it('Mat2x3 * Vec2 rotation + translation', () => {
196
196
  const m = Mat2x3.fromRotation(Math.PI / 3)
197
- m.translate(new Vec2(10, 20))
198
- const v = new Vec2(4, -1)
199
- const expected = v.transformMat2x3(m, new Vec2())
197
+ m.translate(vec2(10, 20))
198
+ const v = vec2(4, -1)
199
+ const expected = v.transformMat2x3(m, vec2())
200
200
  const r = m * v
201
201
  assert.ok(r instanceof Vec2)
202
202
  closeTo(r.x, expected.x)
203
203
  closeTo(r.y, expected.y)
204
204
  })
205
205
  it('Mat2x3 * Vec2 scale + rotation + translation', () => {
206
- const m = Mat2x3.identity
207
- m.scale(new Vec2(2, 3))
206
+ const m = mat2x3.identity
207
+ m.scale(vec2(2, 3))
208
208
  m.rotate(Math.PI / 4)
209
- m.translate(new Vec2(5, 10))
210
- const v = new Vec2(3, 7)
211
- const expected = v.transformMat2x3(m, new Vec2())
209
+ m.translate(vec2(5, 10))
210
+ const v = vec2(3, 7)
211
+ const expected = v.transformMat2x3(m, vec2())
212
212
  const r = m * v
213
213
  closeTo(r.x, expected.x)
214
214
  closeTo(r.y, expected.y)