How to find the coordinate of a point perpendicular to 3D line with desired scalar distance?

4 次查看(过去 30 天)
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 个评论
Matt J
Matt J 2021-7-14
编辑:Matt J 2021-7-14
The solution is under-determined. For any 3D line segment, there is an entire circle of points at a specified distance d which project perpendicularly to its midpoint.
Mesut Sahin
Mesut Sahin 2021-7-14
Hi Matt,
Yes, I realised it after I posted the question. Indeed, I have many lines as this that are spatially distributed. My final objective to define circular cross-section between points 1 and 2 which I can easily do in another platform.
I need to attain 3rd node on the cylindrical surface as an orientation purpose consistently. Is it possible to solve this infinite possible 3rd point location by defining element connectivity vector fields or a reference point?

请先登录,再进行评论。

回答(1 个)

Nipun
Nipun 2024-6-4
编辑:Nipun 2024-6-4
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

类别

Help CenterFile Exchange 中查找有关 Surface and Mesh Plots 的更多信息

产品


版本

R2020b

Community Treasure Hunt

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

Start Hunting!

Translated by