Last change
on this file since 360 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.4 KB
|
Line | |
---|
1 | function B = rotateB(A,degrees)
|
---|
2 | % Translate backwards
|
---|
3 | % bepaal dimentie
|
---|
4 | B = A;
|
---|
5 | degrees_rad = degrees * pi / 180;
|
---|
6 | %rotatiematrix
|
---|
7 | R = [ cos(-degrees_rad), sin(-degrees_rad), 0;
|
---|
8 | sin(degrees_rad), cos(-degrees_rad), 0;
|
---|
9 | 0, 0, 1];
|
---|
10 | %bepaal buitenzijden en midden
|
---|
11 | [in_size_x, in_size_y] = size(A);
|
---|
12 | in_mid_x = ( in_size_x-1) / 2;
|
---|
13 | in_mid_y = ( in_size_y-1) / 2;
|
---|
14 | %max grootte van het nieuwe plaatje is de helft de diameter
|
---|
15 | % en dan 'rechtop'
|
---|
16 | dia = int64(sqrt(in_size_x^2 + in_size_y^2 ));
|
---|
17 | B = zeros([dia,dia]);
|
---|
18 | %grootte van de nieuwe matrix
|
---|
19 | [out_size_x, out_size_y] = size(B);
|
---|
20 | out_mid_x = ( out_size_x-1) / 2;
|
---|
21 | out_mid_y = ( out_size_y-1) / 2;
|
---|
22 | %
|
---|
23 | %translatiematrix
|
---|
24 | Tout = [ 1, 0, -out_mid_x;
|
---|
25 | 0, 1, -out_mid_y;
|
---|
26 | 0, 0, 1;];
|
---|
27 | Tin = [ 1, 0, in_mid_x;
|
---|
28 | 0, 1, in_mid_y;
|
---|
29 | 0, 0, 1; ];
|
---|
30 | Trans = Tin * R * Tout;
|
---|
31 | % Laten we maar gaan draaien ;-)
|
---|
32 | for i=1:out_size_x
|
---|
33 | for j=1:out_size_y
|
---|
34 | out = round(Trans * [i;j;1;]);
|
---|
35 | %controleren of punt bestaat
|
---|
36 | if ( out(1) >= 1 && out(1) <= in_size_x && ...
|
---|
37 | out(2) >= 1 && out(2) <= in_size_y )
|
---|
38 | %gegevens overhevelen
|
---|
39 | B(i,j) = A(out(1),out(2));
|
---|
40 | else
|
---|
41 | %puntje zwart maken
|
---|
42 | B(i,j) = 0;
|
---|
43 | end
|
---|
44 | end
|
---|
45 | end
|
---|
46 |
|
---|
47 |
|
---|
48 |
|
---|
Note:
See
TracBrowser
for help on using the repository browser.