Calculating the normal of a (3D) line
조회 수: 21 (최근 30일)
이전 댓글 표시
Hi all,
I would like to calculate the normal vector of a 3D line. This normal vector should cross the origin (0,0,0), otherwise the normal vector is undefined.
How can I do this easily?
Many thanks in advance.
/Kees
댓글 수: 1
Kaninika Pant
2018년 6월 1일
How is this 3D line defined? ie. By a point and a direction vector? Or 2 points?
채택된 답변
Kaninika Pant
2018년 6월 1일
Note that the normal vector is only a direction (cannot pass through a point). I think what you are looking for is a line passing through the origin with a direction vector normal to the previous line.
Also, given a line in any form it is always possible to find the direction vector and a point on the line. So I will answer assuming that you have found those Consider a point (x,y,z) on this normal line. Let the direction vector of the original 3D line is (l,m,n) and a point on the line be (x1,y1,z1). To find this line you need to solve the following:
1. (x-0)l+(y-0)m+(z-0)n=0 (ie. direction vectors of both lines must be perpendicular) 2. (x-x1)/l + (y-y1)/m + (z-z1)/n = k(ie. (x,y,z) must lie on the original 3D line) So, x=l*k + x1; y=m*k + y1; z=n*k + z1
Thus you only have one variable k. Put this in the first equation and simplify to get: k=-(l*x1+m*y1+n*z1)/(l^2+m^2+n^2);
After finding k plug it back to get x,y,z. Note that (x,y,z) is a point on your normal line and also the direction vector. Now you can form the equation of your normal line.
추가 답변 (0개)
참고 항목
카테고리
Help Center 및 File Exchange에서 Surface and Mesh Plots에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!