-2

I tried the algorithms in Line of intersection between two planes

but all not return correct results

I have two rectangle in 3D each defined by three points , I want to get the two points on the line of intersection such that the two points at the end of the intersection I do the following steps:

  • convert each rectangle to two planes , using three points
  • get the line direction by do the cross product of the normal of each plane

I want to get the actual end points of line that lie on the boundary of the plane

Best regards

Community
  • 1
  • 1
AMH
  • 6,363
  • 27
  • 84
  • 135
  • 1
    Can you show some test results, code, test cases? Maybe it's a bug in a code, nobody can tell without checking it, maybe you are misunderstanding the idea. Are you sure that you are not dealing with special case when your planes have infinite number of intersection points or none at all? (same a,b,c, same or different d) – Marcin Deptuła Aug 09 '11 at 08:51
  • Do you just need the line segment that constitutes the intersection of the 2 rectangles? – Rafał Dowgird Aug 09 '11 at 08:57
  • @Rafal yes I need the line segment – AMH Aug 09 '11 at 09:19
  • @jean , I cannot understand u , what the problem – AMH Aug 09 '11 at 09:30
  • I said that I have two rectangles, I converted them to planes – AMH Aug 09 '11 at 11:22

1 Answers1

0

The link you provided most probably has the correct solution :) Did you correctly transform your three points info the Ax+By+Cz+D = 0 form? Check if all those points satisfy this formula. If you have the correct {A, B, C, D} then it's easy to calculate the rest as described in the link..


Here is a link which explains how to get this formula using 3 points.


Ok, here a simple summary:

  • Given three points in space (x1,y1,z1), (x2,y2,z2), (x3,y3,z3), calculate this:

    A = y1 (z2 - z3) + y2 (z3 - z1) + y3 (z1 - z2)

    B = z1 (x2 - x3) + z2 (x3 - x1) + z3 (x1 - x2)

    C = x1 (y2 - y3) + x2 (y3 - y1) + x3 (y1 - y2)

    D = -(x1 (y2 z3 - y3 z2) + x2 (y3 z1 - y1 z3) + x3 (y1 z2 - y2 z1))

    for both planes. Which means you have A1, B1, C1, D1 and A2, B2, C2, D2.

  • Using A, B, C, D calculate this:

    x1 = 0

    z1 = (B2/B1)*D1 - D2)/(C2 - C1*B2/B1)

    y1 = (-C1 * z1 - D1) / B1

  • Then this:

    x2 = some value..

    z2 = (B2/B1)*(A1 * x2 + D1) - A2 * x2 - D2)/(C2 - C1*B2/B1)

    y2 = (-C1 * z2 -A1 * x2 - D1) / B1

Basically just combine both ways described in those two links..

duedl0r
  • 9,289
  • 3
  • 30
  • 45
  • the problem is the two planes represent two rectangles , so I need to get them correctly, I get y,z correctly, but x value fail – AMH Aug 09 '11 at 09:08
  • what do you mean by that? I think you're problem is how to convert your rectangle (or 3 points) into Ax+By+Cz+D=0, right? – duedl0r Aug 09 '11 at 09:11
  • No I got the line direction by the cross product , I want to get the two points on the line and I successfully got it , the problem is to get the x value , do u have skype account to chat, what's the need to get the Ax+Bc+Cz+D = 0 – AMH Aug 09 '11 at 09:16
  • This is not a real answer... belongs in comments. – Jean-François Corbett Aug 09 '11 at 09:22
  • @AMH: I think you should clarify what you really have and what not, now I don't really see your problem anymore :) Since you don't have {A,B,C,D}, you can't use the solution you provided in your link.. – duedl0r Aug 09 '11 at 09:31
  • @duedOr, how to use a,b,c,d to get the actual line segment of intersection , because the cross product return the direction – AMH Aug 09 '11 at 09:40
  • @duedOr, I use it , but the problem it return for example two points (1,3,2) and (2,3,2) which is not the actual line segment of intersection – AMH Aug 09 '11 at 09:41
  • @duedro could u give me the steps to solve that , in my link he use cross product to get line direction – AMH Aug 09 '11 at 09:49
  • @duedl0r let us [continue this discussion in chat](http://chat.stackoverflow.com/rooms/2258/discussion-between-amh-and-duedl0r) – AMH Aug 09 '11 at 09:57
  • but this is not the actual line segement – AMH Aug 09 '11 at 10:00
  • of course it is :) if not, we have a different understanding of "intersection line of two planes". – duedl0r Aug 09 '11 at 10:03
  • @dudOr , could u come to chat for just 1 minute – AMH Aug 09 '11 at 10:14
  • @duedOr, yes it work well, but the problem it not the planes is rectangles – AMH Aug 09 '11 at 12:33