1

I have a plain with known four co-ordinates and a line with two known co-ordinates as shown in figure. enter image description here

The four co-ordinates of plane are

 A = (-5    -5    -8)
 B = ( 15    15    -8)
 C = ( 15    15    12)
 D = ( -5    -5    12)

The co-ordinates of line are

M = (1.3978,40,6.1149)
N = 4.3943, 4.8078,0.3551)

In this case line and plain intersects,then how can I find point of intersection of line and plane in 3D space by using MATLAB? or How can I check both are intersecting or not?

I have tried to find solution by following video tutorial to find equation of plane from three points and tutorial for finding point where line intersects a plain

But in my case, equation of plane is zero. So I am confused. Can anyone help me?

Thanks in advance, Manu

manoos
  • 1,675
  • 3
  • 21
  • 46

1 Answers1

2

I would use simple linear algebra to find the intersection point.

Let n be normal to the plain (you can calculate it as a vector product of say N = cross(AB, AD), then unit n = N / |N| where |N| = sqrt(dot(N, N)) is length of vector N.

You can use the following function from matlabcentral which covers all the corner cases as well (such as when the line is parallel to the plane) and describes them in the comments.

Example from comment:

A =[ -6.8756 39.9090 10.0000],B =[ -6.0096 40.4090 10.0000],C =[ -6.0096 40.4090 11.0000],D=[ -6.8756 39.9090 11.0000];
P0 =[ 1.3978 40.0000 6.1149],P1 =[ 4.3943 -4.8078 0.3551];

I don't know where you made a mistake, but I am pretty sure there is an intersection point which is outside your segment. So you should have got check=3. Here is the output of step by step operation:

>> AB = B-A
AB = 0.8660    0.5000         0
>> AD = D-A
AD = 0     0     1
>> n = cross(AB,AD)/sqrt(dot(cross(AB,AD),cross(AB,AD)))
n = 0.5000   -0.8660         0
>> [I,check]=plane_line_intersect(n,A,P0,P1)
I = 1.0961   44.5116    6.6948
check = 3

It produces the same results with any other point (B, C or D) passed in. check=3 means there is an intersection point I, which is outside of the P01 segment.

As a verification step, notice that normal n has Nz = 0 which means that it's perpendicular to the Z axis. The only way a line wouldn't intersect with it is if it would be parallel to Z axis (and therefore vector P01 would be parallel to Z and have zero Z component).

Your P01 is not aligned with Z:

>> P01 = P1 - P0
P01 = 2.9965  -44.8078   -5.7598
isp-zax
  • 3,833
  • 13
  • 21
  • when I checked for plane points A =[ -6.8756 39.9090 10.0000],B =[ -6.0096 40.4090 10.0000],C =[ -6.0096 40.4090 11.0000],D=[ -6.8756 39.9090 11.0000] and line points P0 =[ 1.3978 40.0000 6.1149],P1 =[ 4.3943 -4.8078 0.3551], it results when using your function, check=1 and I=[-21.2205 31.6268 -6.3689]. Actually there is no intersecting. Can you please explain, why it result like this? – manoos Oct 03 '17 at 23:28
  • You only need 3 points to define the plane, 4 points could be not co-planar. Yours are, so this isn't a problem. However, I am failing to reproduce your output and result I'm getting looks reasonable to me. Please take a look at the output I'm getting with your inputs. Hopefully you'll spot a mistake. – isp-zax Oct 04 '17 at 00:37
  • This doesn't change what I wrote above with regards to your example, but I corrected the normal calculation - the one I had initially wasn't unit vector in case of non-orthogonal AB and AD. In your example they were, so don't know if that somehow happened to be the problem. – isp-zax Oct 04 '17 at 00:47
  • Sorry, there is a change in line points, P0 =[6.3300 -1.8031 2.5170] and P1 =[15.0000 91.9500 -22.4032]. Plane points are the same as above. In this case also check=1 but expected is 3. Can you please check? I need to find intersecting point of line inside the rectangular plane with above corner co-ordinates. Sometimes, it may be the confusion – manoos Oct 04 '17 at 00:59
  • I followed following link, I think that now I find solution https://math.oregonstate.edu/home/programs/undergrad/CalculusQuestStudyGuides/vcalc/dotprod/dotprod.html Thanks a lot @isp-zax – manoos Oct 04 '17 at 01:31