Skip to content

Commit 6d11cbe

Browse files
authored
Update 700-math-m3scale.markdown
1 parent 0a18dcf commit 6d11cbe

File tree

1 file changed

+24
-4
lines changed

1 file changed

+24
-4
lines changed

_build/reference/700-math-m3scale.markdown

Lines changed: 24 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,30 @@
22

33
> M3SCALE BYREF m3x3, x, y, Sx, Sy
44
5-
Scale matrix.
5+
Multiply the given matrix by a scale matrix. Sx and Sy are the scaling factors in x and y direction.
66

77
```
8-
| Sx 0 0|
9-
| 0 Sy 0|
10-
| * * 1|
8+
| Sx 0 0|
9+
MScale = | 0 Sy 0|
10+
| 0 0 1|
1111
```
12+
13+
```
14+
DIM M(2,2)
15+
16+
Rectangle = [-1,-1, 1,-1, 1,1, -1,1, -1,-1] ' Create a rectangular polygon
17+
18+
M3IDENT M ' Create Identity Matrix
19+
20+
M3Trans M, 100,100 ' Move rectangle to position (100,100)
21+
M3SCALE M, 0, 0, 50, 50 ' Scale rectangle by factor 50 in x and y
22+
M3ROTATE M, 45*pi/180 ' Rotate by 45°
23+
24+
M3APPLY M, Rectangle ' Transform the rectangle
25+
26+
DRAWPOLY Rectangle
27+
```
28+
29+
M3TRANS, M3SCALE and M3ROTATE perform a matrix multiplication. When performing matrix multiplication, then last matrix is applied first.
30+
In the example above, the rectangle is first rotated, then scaled and in the last step translated. If the order is changed, the outcome might
31+
be different.

0 commit comments

Comments
 (0)