Part of the Khronos Group
OpenGL.org

The Industry's Foundation for High Performance Graphics

from games to virtual reality, mobile phones to supercomputers

Results 1 to 6 of 6

Thread: calculating intersection

  1. #1
    Junior Member Newbie
    Join Date
    Nov 2004
    Location
    Poland
    Posts
    18

    calculating intersection

    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

  2. #2
    Junior Member Newbie
    Join Date
    Feb 2006
    Location
    Buenos Aires, Argentina
    Posts
    1

    Re: calculating intersection

    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.

  3. #3
    Senior Member OpenGL Pro
    Join Date
    May 2000
    Location
    Hannover, Germany
    Posts
    1,258

    Re: calculating intersection

    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
    - Michael Steinberg

  4. #4
    Junior Member Newbie
    Join Date
    Nov 2004
    Location
    Poland
    Posts
    18

    Re: calculating intersection

    Yes, I need x, y, z coords, of the intersection point of the surface and the |B1B2|. I will be very grateful.

  5. #5
    Senior Member OpenGL Pro
    Join Date
    May 2000
    Location
    Naarn, Austria
    Posts
    1,142

    Re: calculating intersection

    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

  6. #6
    Junior Member Newbie
    Join Date
    Nov 2004
    Location
    Poland
    Posts
    18

    Re: calculating intersection

    Thanx Michael, your post was really helpful.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •