Plane in 3D space
Show older comments
I'm trying to define a plane in 3D for interpolation. Since it needs to be able to be any plan, my though was to first define x and y and then rotate them. Then define z, independently of x and y. That way I wanted to z-plane tilt around the x axis and rotate with x and y. In short, it would all be defined by a center point and two angles (rotation and plane tilt). However, this doesn't work when i start rotating x and y. Tilt is working fine, but the rotation seems to cause z to be place wrong or smth. Can anyone help a bit? I posted the code below...
% Set variables (later to be function input
cp = [0.0 -0.0 0.04]; % Center point coordinats [m]
xsize = 0.08; % Size along x-dim of the sample plane [m]
ysize = 0.08; % Size aling y-dim of the sample plane [m]
N = 500; % Spatiel resolution [px]
angR = 90; % Rotational angle [deg]
angT = 90; % Tilt angle [deg]
% Define standard x and y
x = linspace(-xsize/2, xsize/2, N);
y = linspace(-ysize/2*cosd(angT), ysize/2*cosd(angT), N);
% Set rotation matrix
R = [cosd(angR) -sind(angR); ...
sind(angR) cosd(angR)];
% Rotate x and y coords
XY = R*[x; y];
X = cp(1)+repmat(XY(1,:), [N 1]);
Y = cp(2)+repmat(XY(2,:)', [1 N]);
% Define Z (does not depend on X or Y)
Z = linspace((-ysize/2)*sind(angT), (ysize/2)*sind(angT), N);
Z = cp(3)+repmat(Z', [1 N]);
Accepted Answer
More Answers (0)
Categories
Find more on Surface and Mesh Plots in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!