-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtest.m
More file actions
43 lines (27 loc) · 776 Bytes
/
test.m
File metadata and controls
43 lines (27 loc) · 776 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
clc; clear all; close all;
bathy = peaks(100);
x = 0:99;
y = 0:99;
[X, Y] = meshgrid(x, y);
bathy = reshape(bathy,[100,100]);
i = -10:10;
j = -5:5;
[I, J] = meshgrid(i, j);
view = [reshape(I,[1,231]); reshape(J,[1,231]); zeros(1, 231)];
theta = pi/4;
R = [cos(theta) sin(theta);
-sin(theta) cos(theta)];
trans_x = 50;
trans_y = 50;
view = [R*view(1:2, :); view(3, :)] + [trans_x; trans_y; 0];
for k=1:length(view)
view(3, k) = bathy(floor(view(1, k)), floor(view(2, k))) + 1;
end
figure; hold on;
surf(X, Y, bathy);
plot3(view(1, :), view(2, :), view(3, :), 'r.');
view = [R\view(1:2, :); view(3, :)];
figure;
plot3(view(1, :), view(2, :), view(3, :), 'r.');
figure;
contour(I, J, reshape(view(3, :),[11,21]));