Create a node in the space between two nodes (A and B) and following the direction normal to a node (N)
Mostrar comentarios más antiguos
Hi. I need to create a node in the space between two nodes (A and B) and following the direction normal to a node (N) as in the figure.
Is there a function that can do this? The result are the coordinates of node C.
A = [-25.5530 -185.3199 -211.6502];
B = [-25.4769 -185.6468 -211.2523];
N = [-25.4602 -185.4676 -211.6694];
normal_plane = [0.2437 -0.62123 0.7447];
figure
plot3(N(:,1),N(:,2),N(:,3),'r.','Markersize',25);
hold on
plot3(A(:,1),A(:,2),A(:,3),'k.','Markersize',25);
plot3(B(:,1),B(:,2),B(:,3),'k.','Markersize',25);
hold off
axis equal
grid off

3 comentarios
William Rose
el 5 de Feb. de 2024
Yes there is a way D=(A+B)/2; % the location E=cross((A-B),(N-D)); % the direction
William Rose
el 5 de Feb. de 2024
Sorry about the formatting, doing it on phone
Catalytic
el 5 de Feb. de 2024
You've asked a million questions on coordinate goemetry on this forum. Surely you now by now how to find the equation of a plane and its intersection with a line.
Respuesta aceptada
Más respuestas (3)
William Rose
el 5 de Feb. de 2024
A = [-25.5530 -185.3199 -211.6502];
B = [-25.4769 -185.6468 -211.2523];
N = [-25.4602 -185.4676 -211.6694];
C=(B-A)'\(N-A)'*(B-A)+A
Shubham
el 6 de Feb. de 2024
Hi Alberto,
To create a node C in the space between two nodes A and B, following the direction normal to a node N, you can follow these steps:
- Calculate the midpoint (M) between nodes A and B. This gives you a point that lies directly between them.
- Determine the desired distance (d) you want node C to be from the midpoint M along the normal direction.
- Scale the normal vector (normal_plane) to have the desired length (d).
- Add the scaled normal vector to the midpoint M to find the coordinates of node C.
Here is how you can implement this in MATLAB:
A = [-25.5530, -185.3199, -211.6502];
B = [-25.4769, -185.6468, -211.2523];
N = [-25.4602, -185.4676, -211.6694];
normal_plane = [0.2437, -0.62123, 0.7447];
% Calculate the midpoint between A and B
M = (A + B) / 2;
% Determine the desired distance d for node C from the midpoint M
% This value is for illustration; you'll need to choose an appropriate value.
d = 10; % Replace with the desired distance
% Normalize the normal vector
normal_plane_unit = normal_plane / norm(normal_plane);
% Scale the normal vector to have the desired length d
normal_plane_scaled = normal_plane_unit * d;
% Calculate the coordinates of node C
C = M + normal_plane_scaled;
% Plotting
figure
plot3(N(1), N(2), N(3), 'r.', 'Markersize', 25); hold on;
plot3(A(1), A(2), A(3), 'k.', 'Markersize', 25);
plot3(B(1), B(2), B(3), 'k.', 'Markersize', 25);
plot3(C(1), C(2), C(3), 'b.', 'Markersize', 25); % Node C in blue
hold off;
axis equal;
grid on;
In the code above, d is a placeholder for the distance you want node C to be from the midpoint M along the normal direction. You'll need to define d based on your specific requirements. The normal vector is also scaled to this distance and then added to the midpoint M to find the coordinates of node C.
Node C is plotted in blue for distinction. Make sure to adjust the value of d as needed for your specific use case. If you want node C to be placed in a different way related to node N, you would need to adjust the calculation accordingly.
Categorías
Más información sobre Numeric Types en Centro de ayuda y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!





