A general rotation plus scaling can be defined by multiplying a vector with a transformation matrix:
![]()
This can also be written as the following equations:
![]()
![]()
The matrix will rotate any vector over an angle
, and
enlarge it with a factor
. Note that by convention the angle is positive for a
rotation from the positive X axis towards the positive Y axis (i.e.
anti-clockwise).
So, for example, a +90° rotation with no scaling, we have
,
and
, which
results in the matrix:
Note: In order to make fractions possible, the RISC OS transformation
matrices have values in fixed-point notation, with 16 bits after the
'decimal' point. So a value of '1' must be given as
.
If we want no rotation and a magnification with a factor of 2, we have
, so
and
, and
. This gives
the matrix:
As an example of combined rotation and scaling, we will try a -90°
rotation with a reduction in size with a factor 2. This gives
,
and
:
In fixed-point notation the value of 0.5 can be represented as
and -0.5 as
.
Note that any angle is potentionally possible. Also note that it is not mandatory to make the scaling factor the same for all directions. If we use the matrix:
then the result is magnified (after rotation) in the
direction
with a factor
and in the
direction with a factor
.
Equations (1.1) and (1.2) can be modified to incorporate translations by adding an extra term:
![]()
![]()
This is sometimes written in matrix form as:
![]()
Note: for the transformations in RISC OS, the terms e and f are
also written in fixed-point notation, only now with 8 bits after the
'decimal' point. So a value of 1 should be given as
.