Last change
on this file since 239 was 2, checked in by Rick van der Zwet, 15 years ago |
Initial import of data of old repository ('data') worth keeping (e.g. tracking
means of URL access statistics)
|
File size:
1.2 KB
|
Line | |
---|
1 | function B = rotate(A,degrees)
|
---|
2 | % With a litle help of
|
---|
3 | % http://www.mathworks.com/matlabcentral/
|
---|
4 | % fileexchange/loadFile.do?objectId=4071
|
---|
5 | %
|
---|
6 | % bepaal dimentie
|
---|
7 | B = A;
|
---|
8 | degrees_rad = degrees * pi / 180;
|
---|
9 | %rotatiematrix
|
---|
10 | R = [ cos(degrees_rad), sin(degrees_rad), 0;
|
---|
11 | sin(-degrees_rad), cos(degrees_rad), 0;
|
---|
12 | 0, 0, 1];
|
---|
13 | %bepaal buitenzijden en midden
|
---|
14 | [in_size_x, in_size_y] = size(A);
|
---|
15 | in_mid_x = ( in_size_x-1) / 2;
|
---|
16 | in_mid_y = ( in_size_y-1) / 2;
|
---|
17 | %max grootte van het nieuwe plaatje is de helft de diameter
|
---|
18 | % en dan 'rechtop'
|
---|
19 | dia = int64(sqrt(in_size_x^2 + in_size_y^2 ));
|
---|
20 | B = zeros([dia,dia]);
|
---|
21 | %grootte van de nieuwe matrix
|
---|
22 | [out_size_x, out_size_y] = size(B);
|
---|
23 | out_mid_x = ( out_size_x-1) / 2;
|
---|
24 | out_mid_y = ( out_size_y-1) / 2;
|
---|
25 | %
|
---|
26 | %translatiematrix
|
---|
27 | Tout = [ 1, 0, out_mid_x;
|
---|
28 | 0, 1, out_mid_y;
|
---|
29 | 0, 0, 1;];
|
---|
30 | Tin = [ 1, 0, -in_mid_x;
|
---|
31 | 0, 1, -in_mid_y;
|
---|
32 | 0, 0, 1; ];
|
---|
33 | Trans = Tout * R * Tin;
|
---|
34 | % Laten we maar gaan draaien ;-)
|
---|
35 | for i=1:in_size_x
|
---|
36 | for j=1:in_size_y
|
---|
37 | out = round(Trans * [i;j;1;]);
|
---|
38 | %gegevens overhevelen
|
---|
39 | B(out(1),out(2)) = A(i,j);
|
---|
40 | end
|
---|
41 | end
|
---|
42 |
|
---|
43 |
|
---|
44 |
|
---|
Note:
See
TracBrowser
for help on using the repository browser.