the projected distances between the line and edge A
2 views (last 30 days)
Show older comments
I have rectangular 3D surface with coordinates of 4 sides A=[1.6 0.8441 1.53]; B=[1.6 2.5441 1.53]; C=[1.6 2.5441 1.23]; D=[1.6 0.8441 1.23];
and ray passing throug it with ends p1= [-8.4153 6.5982 2.6492] , p2=[ 2.5736 1.6997 1.3800].
The line is intersecting the surface at point I=[ 1.6000 1.6977 1.4930]
i want to find projected distances between the line and edge A.
for that i have to find projection point of line. (like gram smith )
how can i find projection of line on surface and then calculate its distance to edge A
4 Comments
Torsten
on 6 Jan 2022
??
An edge is a line connecting two points. A is a point, thus it cannot be an edge.
Do we only have problems communicating in English or do you mean something else with "edge" ?
Accepted Answer
Torsten
on 6 Jan 2022
You will have to check for correctness:
% Project p1 on plane ABC (gives point p1-proj)
Mat = [(B-A)*(B-A).' , (B-A)*(C-A).';(B-A)*(C-A).' ,(C-A)*(C-A).'];
rhs = [(B-A)*(p1-A).';(C-A)*(p1-A).'];
coord = Mat\rhs;
p1_proj = A + coord(1)*(B-A) + coord(2)*(C-A);
% Project A on line connecting p1_proj and I
P = p1_proj + ( (I-p1_proj).'\(A-p1_proj).' )*(I-p1_proj);
% Calculate distance
distance = norm(P-A)
3 Comments
Torsten
on 6 Jan 2022
Edited: Torsten
on 6 Jan 2022
Solve
minimize: (p1-(A+lambda*(B-A)+mu*(C-A)))*(p1-(A+lambda*(B-A)+mu*(C-A)))'
for lambda and mu. Call the solution lambda_sol and mu_sol.
Then
p1_proj = A+lambda_sol*(B-A)+mu_sol*(C-A)
is the projection of p1 on the plane ABCD.
We know that I is in the plane ABCD. Thus the line through p1_proj and I is the projection of the ray
through p1 and p2 on ABCD. To find the point P on this line with minimum distance to A,
solve
minimize: (A-(I+nu*(p1_proj-I)))*(A-(I+nu*(p1_proj-I)))'
for nu. Call the solution nu_sol.
Then
P = I+nu_sol*(p1_proj-I)
is the point on the line through p1_proj and I with minimum distance to A.
You know how to solve the two unconstrained minimization problems ?
Building partial derivatives with respect to the unknowns, setting the partial derivatives to 0 and solving for the unknowns ?
Torsten
on 6 Jan 2022
In your special case, everything is of course much simpler since the points A,B,C and D share the same x-coordinate.
This means that p1 and p2 projected on the plane spanned by A,B,C and D are
p1_proj = [1.6 6.5982 2.6492]
p2_proj = [1.6 1.6997 1.3800]
Now you can work in two instead of three dimensions and calculate the distance of A' = [0.8441 1.53] to the line passing through p1_proj' = [6.5982 2.6492] and p2_proj' = [1.6997 1.3800]. This gives you the distance of A to the projected ray through p1 and p2.
I guess that you should have a formula for this in your lecture notes.
More Answers (0)
See Also
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!