PDA

View Full Version : calculating intersection

christus
02-10-2006, 03:16 PM
Hi,
I know there are many wise people out there and surely couple of them can help me. I am developing some twisted simulator of cell growth and division. I need one particular function. I made it by my self, but I think I made some kind of mistake and I didn't have much to do with geometry past few years, bla bla. Anyway it doesn't work, so I need help.

This is the idea: function receives 4 points as parameters A1, A2, B1, B2. Now, it should calculate the perpendicular surface to the section |A1A2| in the middle of it and then the point where this calculated surface intersects with section |B1B2| if so. Any help would be really appreciated cause this is causing delays in my thesis and I may get into troubles if I don't solve this soon.

Thanks

msx68k
02-13-2006, 03:29 PM
Hi. Do you need the (x,y,z) coords of the intersection point of the surface and |B1 B2| line?
If so, IŽll try help you. I am working on that right now.

Michael Steinberg
02-16-2006, 06:22 PM
Alright, so i hope i don't do any mistakes here...
* is to be understood as dot-product.

Say you have your plane definition in normal-form (getting that shouldnt be a problem, eh?).
N is the normal vector, P is the placement vector of the plane.
A and B define the line that is to be intersected with the plane. A+x(B-A)=Y is a definition of the straight with parameter x. Say Y is the intersection-point. The straight from P to Y must be perpendicular to N of course, as it must lie in the plane. If a dotproduct of two non-degenerated vectors is 0 then they are perpendicular to each others. So from that we get:
(Y-P)*N = 0
<=> (A+x(B-A)-P)*N = 0
<=> A*N + x(B-A)*N - P*N = 0
<=> x(B-A)*N = (P-A)*N
<=> x = ((P-A)*N)/((B-A)*N)

We see that this will be undefined if (A-B)*N = 0. This happens if A = B (the points dont define a straight) or if (A-B) is perpendicular to N, hence the straight is parallel or inside the plane. To check for the latter two cases you will have to look at (P-B)*N. If that is zero too then the straight lies inside, otherwise not.
And if i didnt make a mistake (it's late around here, hehe) and you respect the special cases, then x should be the value you search. I 0<=x<=1 then the straight intersected between points A and B. Insert x into the definition of the straight to get the intersection-point then.

PS: I'm sorry i couldnt really make vectors apart from points apart from real numbers :)

christus
02-17-2006, 12:05 PM
Yes, I need x, y, z coords, of the intersection point of the surface and the |B1B2|. I will be very grateful.

Overmind
02-18-2006, 01:09 AM
Just calculate x with the formula of Michael, and then plug it into the formula A+x(B-A)=Y to get Y. This is the point you are looking for ;)

christus
02-25-2006, 12:47 PM
Thanx Michael, your post was really helpful. :cool: