Questions about pararell planes in R3.
1 view (last 30 days)
Show older comments
Hi!
I got two parallel planes in R3 given by the equations 3x + 4y -5z = 0 & 3x + 4y - 5z = 20. I have plotted them with
z1 = @(x,y) 0.6*x + 0.8*y;
z2 = @(x,y) 0.6x + 0.8*y -4;
fsurf(z1);
hold on
fsurf(z2);
I would like to find the normal vector by using matlab, I know its [3 4 -5] from the equations but I'd like to know how I cand find it using matlab.
Then I would like to plot the normal vectors between the planes, and measure the distance between the planes. So my questions are;
How do I find a normal vector to a plane in Matlab?
How do I plot it between the two planes?
And how do I measure the distance?
Best regards
1 Comment
Answers (1)
Abhinaya Kennedy
on 3 Sep 2024
Finding the Normal Vector:
Since you've already identified the normal vector as ([3, 4, -5]), you can directly use this in MATLAB. However, if you wish to extract it programmatically from the equation, you can define it as follows:
% Coefficients of the plane equations
a = 3;
b = 4;
c = -5;
% Normal vector
normal_vector = [a, b, c];
Plotting the Normal Vector:
To plot the normal vector between the two parallel planes, you can use a point on one of the planes and draw the vector.
% Define the planes
z1 = @(x, y) 0.6*x + 0.8*y;
z2 = @(x, y) 0.6*x + 0.8*y - 4;
% Plot the planes
fsurf(z1, [-10, 10, -10, 10]);
hold on;
fsurf(z2, [-10, 10, -10, 10]);
% Choose a point on the first plane (e.g., x=0, y=0)
point_on_plane1 = [0, 0, z1(0, 0)];
% Calculate a point on the second plane using the normal vector
point_on_plane2 = point_on_plane1 + 4 * (normal_vector / norm(normal_vector));
% Plot the normal vector
quiver3(point_on_plane1(1), point_on_plane1(2), point_on_plane1(3), ...
normal_vector(1), normal_vector(2), normal_vector(3), 1, 'r', 'LineWidth', 2);
% Plot the line between the two points
line([point_on_plane1(1), point_on_plane2(1)], ...
[point_on_plane1(2), point_on_plane2(2)], ...
[point_on_plane1(3), point_on_plane2(3)], 'Color', 'k', 'LineWidth', 2);
% Adjust plot settings
xlabel('X');
ylabel('Y');
zlabel('Z');
axis equal;
grid on;
hold off;
Measuring the Distance Between the Planes:
The distance (d) between two parallel planes (ax + by + cz = d_1) and (ax + by + cz = d_2) is given by:
[ d = \frac{|d_2 - d_1|}{\sqrt{a^2 + b^2 + c^2}} ]
% Constants from the plane equations
d1 = 0;
d2 = 20;
% Calculate the distance
distance_between_planes = abs(d2 - d1) / norm(normal_vector);
% Display the distance
disp(['Distance between the planes: ', num2str(distance_between_planes)]);
0 Comments
See Also
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!