creating nodes on an axis normal to a plane

1 view (last 30 days)
Hi! How can I generate more nodes along a normal to the plane? They must extend to a length L. I would like to arrange the nodes equidistant (if possible) along the entire length L. And I would like to define the number of nodes to be created.
center = [-24.3053980118084 -192.105601596377 -203.317238506250];
N = [-23.6570310355158 -189.024898446033 -200.846046641882
-22.0570447467006 -195.240274391531 -205.541295491453
-27.0374400021205 -194.342928913570 -205.337739878176];
figure
plot3(center(:,1),center(:,2),center(:,3),'b.','Markersize',30)
hold on
plot3(N(:,1),N(:,2),N(:,3),'r.','Markersize',30)
patch(N(:,1),N(:,2),N(:,3),'k')
hold off
grid on
xlabel('x')
ylabel('y')
zlabel('z')
axis equal
normal_N = N/norm(N);

Answers (3)

Matt J
Matt J on 18 Jan 2024
Edited: Matt J on 18 Jan 2024
You can generate equidistant points along any 3D ray as follows:
center = [-24.3053980118084 -192.105601596377 -203.317238506250]; %origin of ray
direction=[1,1,1]; %direction of ray
L=50; %length
n=10; %number of points
direction=direction(:)/norm(direction)*L;
points=num2cell(direction*linspace(0,1,n)+center(:),2);
plot3(points{:},'r.',center(:,1),center(:,2),center(:,3),'b.','Markersize',30); grid on

Hassaan
Hassaan on 18 Jan 2024
Edited: Hassaan on 18 Jan 2024
As per my understanding what you want to achieve. I hope it helps.
  1. Calculate the Normal Vector: First, determine the normal vector of the plane. Given three points on the plane (N), you can find two directional vectors that lie on the plane and then calculate their cross product to get the normal vector.
  2. Normalize the Normal Vector: Normalize this normal vector to have a unit length.
  3. Determine Node Spacing and Positions: Decide on the number of nodes n you want to create along the normal, and calculate the spacing between these nodes based on the total length L. Then, starting from the center point, incrementally add the normalized normal vector scaled by the spacing to get the positions of the new nodes.
% Define your points and normal
center = [-24.3053980118084, -192.105601596377, -203.317238506250];
N = [-23.6570310355158, -189.024898446033, -200.846046641882;
-22.0570447467006, -195.240274391531, -205.541295491453;
-27.0374400021205, -194.342928913570, -205.337739878176];
% Calculate the normal vector to the plane
v1 = N(2,:) - N(1,:);
v2 = N(3,:) - N(1,:);
normal_vector = cross(v1, v2);
normalized_normal = normal_vector / norm(normal_vector);
% Specify the number of nodes and length L
num_nodes = 5; % Number of nodes
L = 5; % Length along the normal
% Calculate the spacing between nodes
spacing = L / (num_nodes - 1);
% Generate the nodes
nodes = zeros(num_nodes, 3);
for i = 1:num_nodes
nodes(i,:) = center + (i-1) * spacing * normalized_normal;
end
% Plotting the nodes and the plane
figure;
plot3(center(1), center(2), center(3), 'b.', 'Markersize', 30);
hold on;
plot3(N(:,1), N(:,2), N(:,3), 'r.', 'Markersize', 30);
patch(N(:,1), N(:,2), N(:,3), 'k'); % Plotting the plane
plot3(nodes(:,1), nodes(:,2), nodes(:,3), 'g.', 'Markersize', 20); % Plotting the nodes
grid on;
xlabel('x');
ylabel('y');
zlabel('z');
axis equal;
hold off;
Plots the original points (the center and the points in N), the plane formed by N, and the new nodes along the normal to this plane. Adjust num_nodes and L as needed for your specific requirements.
-----------------------------------------------------------------------------------------------------------------------------------------------------
If you find the solution helpful and it resolves your issue, it would be greatly appreciated if you could accept the answer. Also, leaving an upvote and a comment are also wonderful ways to provide feedback.
Professional Interests
  • Technical Services and Consulting
  • Embedded Systems | Firmware Developement | Simulations
  • Electrical and Electronics Engineering
It's important to note that the advice and code are based on limited information and meant for educational purposes. Users should verify and adapt the code to their specific needs, ensuring compatibility and adherence to ethical standards.
Feel free to contact me.

Sulaymon Eshkabilov
Sulaymon Eshkabilov on 18 Jan 2024
Is this what you are looking for:
center = [-24.3053980118084 -192.105601596377 -203.317238506250];
N = [-23.6570310355158 -189.024898446033 -200.846046641882
-22.0570447467006 -195.240274391531 -205.541295491453
-27.0374400021205 -194.342928913570 -205.337739878176];
% Adjust these Parameters if necessary:
num_nodes = 10; % Number of nodes:
L = 10; % Length of each node:
% Normal vector:
normal_N = N(1,:) / norm(N(1,:));
% Compute equidistant nodes along the normal vector:
nodes = zeros(num_nodes, 3);
for i = 1:num_nodes
nodes(i, :) = center + i * (L/num_nodes) * normal_N;
end
figure
plot3(center(:,1), center(:,2), center(:,3), 'b.', 'Markersize', 30)
hold on
plot3(N(:,1), N(:,2), N(:,3), 'r.', 'Markersize', 30)
patch(N(:,1), N(:,2), N(:,3), 'k')
plot3(nodes(:,1), nodes(:,2), nodes(:,3), 'm+--', 'Markersize', 10)
hold off
grid on
xlabel('x')
ylabel('y')
zlabel('z')
axis equal;
view(-45, 45);

Products


Release

R2021b

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!