M3ROTATE
M3ROTATE BYREF M, angle [, x, y]
Multiply the 2D transformation matrix M
by a rotation
matrix with an angle angle
and a rotation center
x
,y
. M
is a 3x3 matrix.
If x = 0 and y = 0 the rotation matrix has the form:
cos(angle) -sin(angle) 0 |
| sin(angle) cos(angle) 0 |
MRot = | 0 0 1 | |
else:
cos(angle) -sin(angle) (1 - cos(angle))*x + sin(angle) * y |
| sin(angle) cos(angle) (1 - cos(angle))*y - sin(angle) * x |
MRot = | 0 0 1 | |
Example
DIM M(2,2)
1,-1, 1,-1, 1,1, -1,1, -1,-1] ' Create a rectangular polygon
Rectangle = [-
M3IDENT M ' Create Identity Matrix
M3Trans M, 100,100 ' Move rectangle to position (100,100)
M3SCALE M, 0, 0, 50, 50 ' Scale rectangle by factor 50 in x and y
M3ROTATE M, 45*pi/180 ' Rotate by 45°
M3APPLY M, Rectangle ' Transform the rectangle
DRAWPOLY Rectangle
M3TRANS, M3SCALE and M3ROTATE perform a matrix multiplication. When performing matrix multiplication, then last matrix is applied first. 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 be different.
Math
ABS
ABSMAX
ABSMIN
ACOS
ACOSH
ACOT
ACOTH
ACSC
ACSCH
ASEC
ASECH
ASIN
ASINH
ATAN
ATAN2
ATANH
ATN
CEIL
COS
COSH
COT
COTH
CSC
CSCH
DEG
DERIV
DETERM
DIFFEQN
EXP
EXPRSEQ
FIX
FLOOR
FRAC
INT
INTERSECT
INVERSE
LINEQN
LOG
LOG10
M3APPLY
M3IDENT
M3ROTATE
M3SCALE
M3TRANS
MAX
MIN
POLYAREA
POLYCENT
POLYEXT
POW
PTDISTLN
PTDISTSEG
PTSIGN
RAD
RND
ROOT
ROUND
SEC
SECH
SEGCOS
SEGLEN
SEGSIN
SEQ
SGN
SIN
SINH
SQR
STATMEAN
STATMEANDEV
STATMEDIAN
STATSPREADP
STATSPREADS
STATSTD
SUM
SUMSQ
TAN
TANH
TRANSPOSE
If there is insufficient information on this page and you wish learn more about M3ROTATE,
please send an email to smallbasic@gmail.com. You can help to improve information about
M3ROTATE by submitting a pull request,
click View Source for details. Note, an offline language reference text file is also available - see the Download section.