% PLANE generates a hyperplane with a prespecified rotation
%
% USAGE: [x, y, z] = plane (grid, phi, theta)
%
% parameters: grid vector of grid points
% phi rotation of plane around z axis
% theta rotation of plane around y axis
% x x-coordinates of the mesh grid
% y y-coordinates of the mesh grid
% z z-coordinates of the mesh grid
%
% (c) 2001 Microsoft Corporation. Reproduced with permission. All rights reserved.
function [x, y, z] = plane (grid, phi, theta)
N = length (grid);
%% generate grid
for i = 1:N
for j = 1:N
x (i,j) = grid (i);
y (i,j) = grid (j);
z (i,j) = 0;
end
end
%% rotate coordinates
R = [[cos(phi) * cos(theta), sin(phi), -cos(phi) * sin(theta)];
[-sin(phi) * cos(theta), cos(phi), sin(phi) * sin(theta)];
[sin(theta), 0, cos(theta)]];
D = R*[x(:) y(:) z(:)]';
x = reshape (D(1,:),N,N);
y = reshape (D(2,:),N,N);
z = reshape (D(3,:),N,N);