How to find the coordinate of a point perpendicular to 3D line with desired scalar distance?
4 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
Hi Community!
I need advices about how to generate code for shifting mid-point of 3D line by pre-known distance perpendicularly.
I know the coordinate of points 1, 2 and 3. (3rd point is mid-point between points 1 and 2.) My main objective is to find the coordinate of point 4 which is located on perpendicular 3d line. I have also preknown distance parameter (d) as a scalar value.
Thanks for helping.
Mesut
3 comentarios
Respuestas (1)
Nipun
el 4 de Jun. de 2024
Editada: Nipun
el 4 de Jun. de 2024
Hi Mesut,
I understand that you intend to know a way to calculate the coordinates of "point 4" such that line formed by points 3,4 is perpendicular to line by points 1,2 and the distance between point 4 and point 3 is "d".
Since the complete geometry is 3D, there is a complete circular cross-section where "point 4" lies, with radius "d" and centre point 3.
Given the coordinates points 1,2,3 and parameter "d", I recommend using the "cross" function in MATLAB to get a vector perpendicular to point 3 as follows:
% Coordinates of P1 and P2
P1 = [x1, y1, z1];
P2 = [x2, y2, z2];
% Calculate midpoint P3
P3 = (P1 + P2) / 2;
% Calculate a direction vector perpendicular to the line P1P2
% Assuming the line is not vertical; otherwise, change the vector [0, 0, 1] accordingly
direction_vector = cross(P2 - P1, [0, 0, 1]);
direction_vector = direction_vector / norm(direction_vector); % Normalize
% Calculate P4
d = %your_known_distance;
P4 = P3 + d * direction_vector;
% Display the result
disp('Coordinates of P4:');
disp(P4);
This method will yield one vector of the many possible that lie on the required circle. Changing the vector "[0 0 1]" vector will yield a different vector.
Refer to the following MathWorks documentation for more information on "cross" function (vector cross product) in MATLAB: https://www.mathworks.com/help/matlab/ref/cross.html
Hope this helps.
Regards,
Nipun
0 comentarios
Ver también
Categorías
Más información sobre Surface and Mesh Plots en Help Center y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!