Clear Filters
Clear Filters

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

4 views (last 30 days)
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 Comments
Matt J
Matt J on 14 Jul 2021
Edited: Matt J on 14 Jul 2021
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 on 14 Jul 2021
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?

Sign in to comment.

Answers (1)

Nipun
Nipun on 4 Jun 2024
Edited: Nipun on 4 Jun 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

Products


Release

R2020b

Community Treasure Hunt

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

Start Hunting!