-
Notifications
You must be signed in to change notification settings - Fork 115
/
affine.scad
631 lines (585 loc) · 18.3 KB
/
affine.scad
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
//////////////////////////////////////////////////////////////////////
// LibFile: affine.scad
// Matrix math and affine transformation matrices.
// Includes:
// include <BOSL2/std.scad>
//////////////////////////////////////////////////////////////////////
// Section: Affine2d 3x3 Transformation Matrices
// Function: affine2d_identity()
// Synopsis: Returns a 2D (3x3) identity transformation matrix.
// SynTags: Mat
// Topics: Affine, Matrices, Transforms
// See Also: affine3d_identity(), ident(), IDENT
// Usage:
// mat = affine2d_identify();
// Description:
// Create a 3x3 affine2d identity matrix.
// Example:
// mat = affine2d_identity();
// // Returns:
// // [
// // [1, 0, 0],
// // [0, 1, 0],
// // [0, 0, 1]
// // ]
function affine2d_identity() = ident(3);
// Function: affine2d_translate()
// Synopsis: Returns a 2D (3x3) translation transformation matrix.
// SynTags: Mat
// Topics: Affine, Matrices, Transforms, Translation
// See Also: affine3d_translate(), move(), translate(), left(), right(), fwd(), back(), down(), up()
// Usage:
// mat = affine2d_translate(v);
// Description:
// Returns the 3x3 affine2d matrix to perform a 2D translation.
// Arguments:
// v = 2D Offset to translate by. [X,Y]
// Example:
// mat = affine2d_translate([30,40]);
// // Returns:
// // [
// // [1, 0, 30],
// // [0, 1, 40],
// // [0, 0, 1]
// // ]
function affine2d_translate(v=[0,0]) =
assert(is_vector(v),2)
[
[1, 0, v.x],
[0, 1, v.y],
[0 ,0, 1]
];
// Function: affine2d_scale()
// Synopsis: Returns a 2D (3x3) scaling transformation matrix.
// SynTags: Mat
// Topics: Affine, Matrices, Transforms, Scaling
// See Also: affine3d_scale(), scale(), xscale(), yscale(), zscale(), affine3d_scale()
// Usage:
// mat = affine2d_scale(v);
// Description:
// Returns the 3x3 affine2d matrix to perform a 2D scaling transformation.
// Arguments:
// v = 2D vector of scaling factors. [X,Y]
// Example:
// mat = affine2d_scale([3,4]);
// // Returns:
// // [
// // [3, 0, 0],
// // [0, 4, 0],
// // [0, 0, 1]
// // ]
function affine2d_scale(v=[1,1]) =
assert(is_vector(v,2))
[
[v.x, 0, 0],
[ 0, v.y, 0],
[ 0, 0, 1]
];
// Function: affine2d_zrot()
// Synopsis: Returns a 2D (3x3) rotation transformation matrix.
// SynTags: Mat
// Topics: Affine, Matrices, Transforms, Rotation
// See Also: rot(), xrot(), yrot(), zrot(), affine3d_zrot()
// Usage:
// mat = affine2d_zrot(ang);
// Description:
// Returns the 3x3 affine2d matrix to perform a rotation of a 2D vector around the Z axis.
// Arguments:
// ang = Number of degrees to rotate.
// Example:
// mat = affine2d_zrot(90);
// // Returns:
// // [
// // [0,-1, 0],
// // [1, 0, 0],
// // [0, 0, 1]
// // ]
function affine2d_zrot(ang=0) =
assert(is_finite(ang))
[
[cos(ang), -sin(ang), 0],
[sin(ang), cos(ang), 0],
[ 0, 0, 1]
];
// Function: affine2d_mirror()
// Synopsis: Returns a 2D (3x3) reflection transformation matrix.
// SynTags: Mat
// Topics: Affine, Matrices, Transforms, Reflection, Mirroring
// See Also: mirror(), xflip(), yflip(), zflip(), affine3d_mirror()
// Usage:
// mat = affine2d_mirror(v);
// Description:
// Returns the 3x3 affine2d matrix to perform a reflection of a 2D vector across the line given by its normal vector.
// Arguments:
// v = The normal vector of the line to reflect across.
// Example:
// mat = affine2d_mirror([0,1]);
// // Returns:
// // [
// // [ 1, 0, 0],
// // [ 0,-1, 0],
// // [ 0, 0, 1]
// // ]
// Example:
// mat = affine2d_mirror([1,0]);
// // Returns:
// // [
// // [-1, 0, 0],
// // [ 0, 1, 0],
// // [ 0, 0, 1]
// // ]
// Example:
// mat = affine2d_mirror([1,1]);
// // Returns approximately:
// // [
// // [ 0,-1, 0],
// // [-1, 0, 0],
// // [ 0, 0, 1]
// // ]
function affine2d_mirror(v) =
assert(is_vector(v,2))
let(v=unit(point2d(v)), a=v.x, b=v.y)
[
[1-2*a*a, 0-2*a*b, 0],
[0-2*a*b, 1-2*b*b, 0],
[ 0, 0, 1]
];
// Function: affine2d_skew()
// Synopsis: Returns a 2D (3x3) skewing transformation matrix.
// SynTags: Mat
// Topics: Affine, Matrices, Transforms, Skewing
// See Also: skew(), affine3d_skew()
// Usage:
// mat = affine2d_skew(xa);
// mat = affine2d_skew(ya=);
// mat = affine2d_skew(xa, ya);
// Description:
// Returns the 3x3 affine2d matrix to skew a 2D vector along the XY plane.
// Arguments:
// xa = Skew angle, in degrees, in the direction of the X axis. Default: 0
// ya = Skew angle, in degrees, in the direction of the Y axis. Default: 0
// Example:
// mat = affine2d_skew(xa=45,ya=-45);
// // Returns approximately:
// // [
// // [ 1, 1, 0],
// // [-1, 1, 0],
// // [ 0, 0, 1]
// // ]
function affine2d_skew(xa=0, ya=0) =
assert(is_finite(xa))
assert(is_finite(ya))
[
[1, tan(xa), 0],
[tan(ya), 1, 0],
[0, 0, 1]
];
// Section: Affine3d 4x4 Transformation Matrices
// Function: affine3d_identity()
// Synopsis: Returns a 3D (4x4) identity transformation matrix.
// SynTags: Mat
// Topics: Affine, Matrices, Transforms
// See Also: affine2d_identity(), ident(), IDENT
// Usage:
// mat = affine3d_identity();
// Description:
// Create a 4x4 affine3d identity matrix.
// Example:
// mat = affine2d_identity();
// // Returns:
// // [
// // [1, 0, 0, 0],
// // [0, 1, 0, 0],
// // [0, 0, 1, 0],
// // [0, 0, 0, 1]
// // ]
function affine3d_identity() = ident(4);
// Function: affine3d_translate()
// Synopsis: Returns a 3D (4x4) translation transformation matrix.
// SynTags: Mat
// Topics: Affine, Matrices, Transforms, Translation
// See Also: move(), translate(), left(), right(), fwd(), back(), down(), up(), affine2d_translate()
// Usage:
// mat = affine3d_translate(v);
// Description:
// Returns the 4x4 affine3d matrix to perform a 3D translation.
// Arguments:
// v = 3D offset to translate by. [X,Y,Z]
// Example:
// mat = affine2d_translate([30,40,50]);
// // Returns:
// // [
// // [1, 0, 0, 30],
// // [0, 1, 0, 40],
// // [0, 0, 1, 50]
// // [0, 0, 0, 1]
// // ]
function affine3d_translate(v=[0,0,0]) =
assert(is_list(v))
let( v = [for (i=[0:2]) default(v[i],0)] )
[
[1, 0, 0, v.x],
[0, 1, 0, v.y],
[0, 0, 1, v.z],
[0 ,0, 0, 1]
];
// Function: affine3d_scale()
// Synopsis: Returns a 3D (4x4) scaling transformation matrix.
// SynTags: Mat
// Topics: Affine, Matrices, Transforms, Scaling
// See Also: scale(), affine2d_scale()
// Usage:
// mat = affine3d_scale(v);
// Description:
// Returns the 4x4 affine3d matrix to perform a 3D scaling transformation.
// Arguments:
// v = 3D vector of scaling factors. [X,Y,Z]
// Example:
// mat = affine3d_scale([3,4,5]);
// // Returns:
// // [
// // [3, 0, 0, 0],
// // [0, 4, 0, 0],
// // [0, 0, 5, 0],
// // [0, 0, 0, 1]
// // ]
function affine3d_scale(v=[1,1,1]) =
assert(is_list(v))
let( v = [for (i=[0:2]) default(v[i],1)] )
[
[v.x, 0, 0, 0],
[ 0, v.y, 0, 0],
[ 0, 0, v.z, 0],
[ 0, 0, 0, 1]
];
// Function: affine3d_xrot()
// Synopsis: Returns a 3D (4x4) X-axis rotation transformation matrix.
// SynTags: Mat
// Topics: Affine, Matrices, Transforms, Rotation
// See Also: rot(), xrot(), yrot(), zrot(), affine2d_zrot()
// Usage:
// mat = affine3d_xrot(ang);
// Description:
// Returns the 4x4 affine3d matrix to perform a rotation of a 3D vector around the X axis.
// Arguments:
// ang = number of degrees to rotate.
// Example:
// mat = affine3d_xrot(90);
// // Returns:
// // [
// // [1, 0, 0, 0],
// // [0, 0,-1, 0],
// // [0, 1, 0, 0],
// // [0, 0, 0, 1]
// // ]
function affine3d_xrot(ang=0) =
assert(is_finite(ang))
[
[1, 0, 0, 0],
[0, cos(ang), -sin(ang), 0],
[0, sin(ang), cos(ang), 0],
[0, 0, 0, 1]
];
// Function: affine3d_yrot()
// Synopsis: Returns a 3D (4x4) Y-axis rotation transformation matrix.
// SynTags: Mat
// Topics: Affine, Matrices, Transforms, Rotation
// See Also: rot(), xrot(), yrot(), zrot(), affine2d_zrot()
// Usage:
// mat = affine3d_yrot(ang);
// Description:
// Returns the 4x4 affine3d matrix to perform a rotation of a 3D vector around the Y axis.
// Arguments:
// ang = Number of degrees to rotate.
// Example:
// mat = affine3d_yrot(90);
// // Returns:
// // [
// // [ 0, 0, 1, 0],
// // [ 0, 1, 0, 0],
// // [-1, 0, 0, 0],
// // [ 0, 0, 0, 1]
// // ]
function affine3d_yrot(ang=0) =
assert(is_finite(ang))
[
[ cos(ang), 0, sin(ang), 0],
[ 0, 1, 0, 0],
[-sin(ang), 0, cos(ang), 0],
[ 0, 0, 0, 1]
];
// Function: affine3d_zrot()
// Synopsis: Returns a 3D (4x4) Z-axis rotation transformation matrix.
// SynTags: Mat
// Topics: Affine, Matrices, Transforms, Rotation
// See Also: rot(), xrot(), yrot(), zrot(), affine2d_zrot()
// Usage:
// mat = affine3d_zrot(ang);
// Description:
// Returns the 4x4 affine3d matrix to perform a rotation of a 3D vector around the Z axis.
// Arguments:
// ang = number of degrees to rotate.
// Example:
// mat = affine3d_zrot(90);
// // Returns:
// // [
// // [ 0,-1, 0, 0],
// // [ 1, 0, 0, 0],
// // [ 0, 0, 1, 0],
// // [ 0, 0, 0, 1]
// // ]
function affine3d_zrot(ang=0) =
assert(is_finite(ang))
[
[cos(ang), -sin(ang), 0, 0],
[sin(ang), cos(ang), 0, 0],
[ 0, 0, 1, 0],
[ 0, 0, 0, 1]
];
// Function: affine3d_rot_by_axis()
// Synopsis: Returns a 3D (4x4) arbitrary-axis rotation transformation matrix.
// SynTags: Mat
// Topics: Affine, Matrices, Transforms, Rotation
// See Also: rot(), xrot(), yrot(), zrot(), affine2d_zrot()
// Usage:
// mat = affine3d_rot_by_axis(u, ang);
// Description:
// Returns the 4x4 affine3d matrix to perform a rotation of a 3D vector around an axis.
// Arguments:
// u = 3D axis vector to rotate around.
// ang = number of degrees to rotate.
// Example:
// mat = affine3d_rot_by_axis([1,1,1], 120);
// // Returns approx:
// // [
// // [ 0, 0, 1, 0],
// // [ 1, 0, 0, 0],
// // [ 0, 1, 0, 0],
// // [ 0, 0, 0, 1]
// // ]
function affine3d_rot_by_axis(u=UP, ang=0) =
assert(is_finite(ang))
assert(is_vector(u,3))
approx(ang,0)? affine3d_identity() :
let(
u = unit(u),
c = cos(ang),
c2 = 1-c,
s = sin(ang)
) [
[u.x*u.x*c2+c , u.x*u.y*c2-u.z*s, u.x*u.z*c2+u.y*s, 0],
[u.y*u.x*c2+u.z*s, u.y*u.y*c2+c , u.y*u.z*c2-u.x*s, 0],
[u.z*u.x*c2-u.y*s, u.z*u.y*c2+u.x*s, u.z*u.z*c2+c , 0],
[ 0, 0, 0, 1]
];
// Function: affine3d_rot_from_to()
// Synopsis: Returns a 3D (4x4) tilt rotation transformation matrix.
// SynTags: Mat
// Topics: Affine, Matrices, Transforms, Rotation
// See Also: rot(), xrot(), yrot(), zrot(), affine2d_zrot()
// Usage:
// mat = affine3d_rot_from_to(from, to);
// Description:
// Returns the 4x4 affine3d matrix to perform a rotation of a 3D vector from one vector direction to another.
// Arguments:
// from = 3D axis vector to rotate from.
// to = 3D axis vector to rotate to.
// Example:
// mat = affine3d_rot_from_to(UP, RIGHT);
// // Returns:
// // [
// // [ 0, 0, 1, 0],
// // [ 0, 1, 0, 0],
// // [-1, 0, 0, 0],
// // [ 0, 0, 0, 1]
// // ]
function affine3d_rot_from_to(from, to) =
assert(is_vector(from))
assert(is_vector(to))
assert(len(from)==len(to))
let(
from = unit(point3d(from)),
to = unit(point3d(to))
) approx(from,to)? affine3d_identity() :
from.z==0 && to.z==0 ? affine3d_zrot(v_theta(point2d(to)) - v_theta(point2d(from)))
:
let(
u = vector_axis(from,to),
ang = vector_angle(from,to),
c = cos(ang),
c2 = 1-c,
s = sin(ang)
) [
[u.x*u.x*c2+c , u.x*u.y*c2-u.z*s, u.x*u.z*c2+u.y*s, 0],
[u.y*u.x*c2+u.z*s, u.y*u.y*c2+c , u.y*u.z*c2-u.x*s, 0],
[u.z*u.x*c2-u.y*s, u.z*u.y*c2+u.x*s, u.z*u.z*c2+c , 0],
[ 0, 0, 0, 1]
];
// Function: affine3d_mirror()
// Synopsis: Returns a 3D (4x4) reflection transformation matrix.
// SynTags: Mat
// Topics: Affine, Matrices, Transforms, Reflection, Mirroring
// See Also: mirror(), xflip(), yflip(), zflip(), affine2d_mirror()
// Usage:
// mat = affine3d_mirror(v);
// Description:
// Returns the 4x4 affine3d matrix to perform a reflection of a 3D vector across the plane given by its normal vector.
// Arguments:
// v = The normal vector of the plane to reflect across.
// Example:
// mat = affine3d_mirror([1,0,0]);
// // Returns:
// // [
// // [-1, 0, 0, 0],
// // [ 0, 1, 0, 0],
// // [ 0, 0, 1, 0],
// // [ 0, 0, 0, 1]
// // ]
// Example:
// mat = affine3d_mirror([0,1,0]);
// // Returns:
// // [
// // [ 1, 0, 0, 0],
// // [ 0,-1, 0, 0],
// // [ 0, 0, 1, 0],
// // [ 0, 0, 0, 1]
// // ]
function affine3d_mirror(v) =
assert(is_vector(v))
let(
v=unit(point3d(v)),
a=v.x, b=v.y, c=v.z
) [
[1-2*a*a, -2*a*b, -2*a*c, 0],
[ -2*b*a, 1-2*b*b, -2*b*c, 0],
[ -2*c*a, -2*c*b, 1-2*c*c, 0],
[ 0, 0, 0, 1]
];
// Function: affine3d_skew()
// Synopsis: Returns a 3D (4x4) skewing transformation matrix.
// SynTags: Mat
// Topics: Affine, Matrices, Transforms, Skewing
// See Also: skew(), affine3d_skew_xy(), affine3d_skew_xz(), affine3d_skew_yz(), affine2d_skew()
// Usage:
// mat = affine3d_skew([sxy=], [sxz=], [syx=], [syz=], [szx=], [szy=]);
// Description:
// Returns the 4x4 affine3d matrix to perform a skew transformation.
// Arguments:
// sxy = Skew factor multiplier for skewing along the X axis as you get farther from the Y axis. Default: 0
// sxz = Skew factor multiplier for skewing along the X axis as you get farther from the Z axis. Default: 0
// syx = Skew factor multiplier for skewing along the Y axis as you get farther from the X axis. Default: 0
// syz = Skew factor multiplier for skewing along the Y axis as you get farther from the Z axis. Default: 0
// szx = Skew factor multiplier for skewing along the Z axis as you get farther from the X axis. Default: 0
// szy = Skew factor multiplier for skewing along the Z axis as you get farther from the Y axis. Default: 0
// Example:
// mat = affine3d_skew(sxy=2,szx=3);
// // Returns:
// // [
// // [ 1, 2, 0, 0],
// // [ 0, 1, 0, 0],
// // [ 0, 0, 1, 0],
// // [ 3, 0, 0, 1]
// // ]
function affine3d_skew(sxy=0, sxz=0, syx=0, syz=0, szx=0, szy=0) = [
[ 1, sxy, sxz, 0],
[syx, 1, syz, 0],
[szx, szy, 1, 0],
[ 0, 0, 0, 1]
];
// Function: affine3d_skew_xy()
// Synopsis: Returns a 3D (4x4) XY-plane skewing transformation matrix.
// SynTags: Mat
// Topics: Affine, Matrices, Transforms, Skewing
// See Also: skew(), affine3d_skew(), affine3d_skew_xz(), affine3d_skew_yz(), affine2d_skew()
// Usage:
// mat = affine3d_skew_xy(xa);
// mat = affine3d_skew_xy(ya=);
// mat = affine3d_skew_xy(xa, ya);
// Description:
// Returns the 4x4 affine3d matrix to perform a skew transformation along the XY plane.
// Arguments:
// xa = Skew angle, in degrees, in the direction of the X axis. Default: 0
// ya = Skew angle, in degrees, in the direction of the Y axis. Default: 0
// Example:
// mat = affine3d_skew_xy(xa=45,ya=-45);
// // Returns:
// // [
// // [ 1, 0, 1, 0],
// // [ 0, 1,-1, 0],
// // [ 0, 0, 1, 0],
// // [ 0, 0, 0, 1]
// // ]
function affine3d_skew_xy(xa=0, ya=0) =
assert(is_finite(xa))
assert(is_finite(ya))
[
[ 1, tan(xa), 0, 0],
[tan(ya), 1, 0, 0],
[ 0, 0, 1, 0],
[ 0, 0, 0, 1]
];
// Function: affine3d_skew_xz()
// Synopsis: Returns a 3D (4x4) XZ-plane skewing transformation matrix.
// SynTags: Mat
// Topics: Affine, Matrices, Transforms, Skewing
// See Also: skew(), affine3d_skew(), affine3d_skew_xy(), affine3d_skew_yz(), affine2d_skew()
// Usage:
// mat = affine3d_skew_xz(xa);
// mat = affine3d_skew_xz(za=);
// mat = affine3d_skew_xz(xa, za);
// Description:
// Returns the 4x4 affine3d matrix to perform a skew transformation along the XZ plane.
// Arguments:
// xa = Skew angle, in degrees, in the direction of the X axis. Default: 0
// za = Skew angle, in degrees, in the direction of the Z axis. Default: 0
// Example:
// mat = affine3d_skew_xz(xa=45,za=-45);
// // Returns:
// // [
// // [ 1, 1, 0, 0],
// // [ 0, 1, 0, 0],
// // [ 0,-1, 1, 0],
// // [ 0, 0, 0, 1]
// // ]
function affine3d_skew_xz(xa=0, za=0) =
assert(is_finite(xa))
assert(is_finite(za))
[
[ 1, 0, tan(xa), 0],
[ 0, 1, 0, 0],
[tan(za), 0, 1, 0],
[ 0, 0, 0, 1]
];
// Function: affine3d_skew_yz()
// Synopsis: Returns a 3D (4x4) YZ-plane skewing transformation matrix.
// SynTags: Mat
// Topics: Affine, Matrices, Transforms, Skewing
// See Also: skew(), affine3d_skew(), affine3d_skew_xy(), affine3d_skew_xz(), affine2d_skew()
// Usage:
// mat = affine3d_skew_yz(ya);
// mat = affine3d_skew_yz(za=);
// mat = affine3d_skew_yz(ya, za);
// Description:
// Returns the 4x4 affine3d matrix to perform a skew transformation along the YZ plane.
// Arguments:
// ya = Skew angle, in degrees, in the direction of the Y axis. Default: 0
// za = Skew angle, in degrees, in the direction of the Z axis. Default: 0
// Example:
// mat = affine3d_skew_yz(ya=45,za=-45);
// // Returns:
// // [
// // [ 1, 0, 0, 0],
// // [ 1, 1, 0, 0],
// // [-1, 0, 1, 0],
// // [ 0, 0, 0, 1]
// // ]
function affine3d_skew_yz(ya=0, za=0) =
assert(is_finite(ya))
assert(is_finite(za))
[
[1, 0, 0, 0],
[0, 1, tan(ya), 0],
[0, tan(za), 1, 0],
[0, 0, 0, 1]
];
// vim: expandtab tabstop=4 shiftwidth=4 softtabstop=4 nowrap