0123456789 0123456789
0 ABCDEFGHIJ 0 A
1 1 B
2 2 D
3 3 E
4 4 G
5 5 H
6 6 J
7 7
8 8
9 9
The end coordinates of the destination line only needs to be calculated (ie using sine & cosine) once.
You'd have a source pixel pointer, starting at (0, 0), increment by (9/6, 0) each pass through the loop,
and a destination pixel pointer, starting at (0, 0), increment by (1, 1) each pass through the loop,
number of loops is number of destination pixels, which is max of horizontal and vertical lengths of destination line
Source Destination
============ ============
X Y Pixel X Y
========= ===== ===== ===== ===== =====
Increment 9/6 1 1 1
Start 0+0/6 0 A 0 0
1+3/6 0 B 1 1
3+0/6 0 D 2 2
4+3/6 0 E 3 3
6+0/6 0 G 4 4
7+3/6 0 H 5 5
Finish 9+0/6 0 J 6 6
Note that not only does this rotate the line, but by starting the destination line somewhere other than (0, 0) you can also translate/displace/move the line at the same time, plus the same transformation can scale/resize the line larger or smaller, at the same time... bonus!!!
Rectangular transformations are just repeated line transformations, with the starting and destination points incremented for each scan line.