       Re: Finding a shorter form for coplanar point in 3D space

• To: mathgroup at smc.vnet.net
• Subject: [mg65168] Re: [mg65135] Finding a shorter form for coplanar point in 3D space
• From: "Carl K. Woll" <carlw at wolfram.com>
• Date: Wed, 15 Mar 2006 23:59:59 -0500 (EST)
• References: <200603151129.GAA23276@smc.vnet.net>
• Sender: owner-wri-mathgroup at wolfram.com

```JÃ¡nos wrote:
> Hi,
>
> Let say I have a Line in 3D with points A(xa,ya,0) and B(xb,yb,zb)
> and the distance between the two points in space is "l"  -small "L".
> Then I move this line into another position where the end points will
> be C(xc,yc,0) and D(xd,yd,zd).  The move is such that A,B and D are
> collinear, A and C remain in the xy-plane and A,B,C and D are
> coplanar.   The distance between C and D are also "l".  Let's say I
> know the coordinates of  A, B, and C and I am looking for D(xd,yd,zd).
>

Why wouldn't you define point D as

{xa+(xb-xa)t,ya+(yb-ya)t,zb t}

Then collinearity of D with A and B is guaranteed, and you only have one
unknown to solve for instead of 3.

>  From the condition of collinearity of A,B,C is coming that the
> determinant of the matrix created from the coordinates has to vanish
> so my first equation eqn1:
>
> In:=
> m = {{xa, ya, 0}, {xb, yb,
>      zb}, {xd, yd, zd}}
>
> In:=
> eqn1 = Det[m] == 0
> Out=
> xd*ya*zb - xa*yd*zb -
>     xb*ya*zd + xa*yb*zd == 0
>

This equation is unnecessary when using the parametric form of D I gave
above.

> The second equation is coming from the fact that the distance between
> C and D is "l":
>
> In:=
> eqn2 = (xc - xd)^2 +
>      (yc - yd)^2 + zd^2 == l^2
>

With one unknown, this is the only equation you need. Defining the points:

pa = {xa, ya, 0};
pb = {xb, yb, zb};
pc = {xc, yc, 0};
pd = {xa + (xb - xa) t, ya + (yb - ya) t, zb t};

Solve the resulting distance equation, where I suppress the output as
its a little messy:

In:=
Solve[(pb - pa) . (pb - pa) == (pd - pc) . (pd - pc), t];

We get two solutions, as expected for a quadratic equation in t. We can
obtain the coordinates of pd by substituting this value of t into it.
Perhaps I'm misunderstanding your problem, as you state that you
expected 16 solutions.

Carl Woll
Wolfram Research

> The third equation is given by similar triangles.  Let say if the
> vertical projection of D down to the xy-plane is Dxy and the same for
> B is Bxy, then BBxy:BxyA == DDxy:DxyA.  In coordinates:
>
> eqn3 = zb/Sqrt[(xa - xb)^2 +
>        (ya - yb)^2] ==
>     zd/Sqrt[(xa - xd)^2 +
>        (ya - yd)^2]
>
> Well, if I put all three into Solve, like this innocent looking
> sol=Solve[{eqn1,eqn2,eqn3},{xd,yd,zd}], Solve will take my G5 duo
> into the bushes forever.  It looks to me that I should have up to max
> 16 solutions for {xd,yd,zd}.
>
> If I try to be cleaver and solve eqn3 for zd:
>
> In:=
> solzd = Solve[eqn3, zd]
> Out=
> {{zd -> (Sqrt[(xa - xd)^2 +
>          (ya - yd)^2]*zb)/
>       Sqrt[(xa - xb)^2 +
>         (ya - yb)^2]}}
>
> and punch it back to eqn1 and eqn2 then I get
>
> In:=
> eqn1
> Out=
> xd*ya*zb -
>     (xb*ya*Sqrt[(xa - xd)^2 +
>         (ya - yd)^2]*zb)/
>      Sqrt[(xa - xb)^2 +
>        (ya - yb)^2] +
>     (xa*yb*Sqrt[(xa - xd)^2 +
>         (ya - yd)^2]*zb)/
>      Sqrt[(xa - xb)^2 +
>        (ya - yb)^2] -
>     xa*yd*zb == 0
>
> and
>
> In:=
> eqn2
> Out=
> (xc - xd)^2 + (yc - yd)^2 +
>     (((xa - xd)^2 + (ya - yd)^
>         2)*zb^2)/
>      ((xa - xb)^2 + (ya - yb)^
>        2) == l^2
>
> Now these two still take my G5 Duo to the laundry if I try Solve
> [{eqn1,eqn2},{xd,yd}].
> The next step to do is to solve eqn1 for yd:
>
> In:=
> solyd = Flatten[Solve[eqn1,
>      yd]]
> Out=
> {yd -> ((-xb)*ya + xd*ya +
>       xa*yb - xd*yb)/
>      (xa - xb), yd ->
>     (xa^2*xb*ya + xa^2*xd*ya -
>       2*xa*xb*xd*ya +
>       xb*ya^3 + xd*ya^3 -
>       xa^3*yb + xa^2*xd*yb -
>       xa*ya^2*yb - xd*ya^2*yb)/
>      (xa^3 - xa^2*xb +
>       xa*ya^2 + xb*ya^2 -
>       2*xa*ya*yb)}
>
> and punch it back to eqn2.  Eqn2 will become two equations, eqn21 and
> eqn22.
>
> In:=
> eqn21 = eqn2 /. yd ->
>      solyd[[1,2]]
> Out=
> (xc - xd)^2 +
>     (-(((-xb)*ya + xd*ya +
>          xa*yb - xd*yb)/
>         (xa - xb)) + yc)^2 +
>     (((xa - xd)^2 +
>        (ya - ((-xb)*ya +
>            xd*ya + xa*yb -
>            xd*yb)/(xa - xb))^
>         2)*zb^2)/
>      ((xa - xb)^2 + (ya - yb)^
>        2) == l^2
>
> and
>
> In:=
> eqn22 = eqn2 /. yd ->
>      solyd[[2,2]]
> Out=
> (xc - xd)^2 +
>     (-((xa^2*xb*ya + xa^2*xd*
>           ya - 2*xa*xb*xd*ya +
>          xb*ya^3 + xd*ya^3 -
>          xa^3*yb + xa^2*xd*
>           yb - xa*ya^2*yb -
>          xd*ya^2*yb)/(xa^3 -
>          xa^2*xb + xa*ya^2 +
>          xb*ya^2 - 2*xa*ya*
>           yb)) + yc)^2 +
>     (((xa - xd)^2 +
>        (ya - (xa^2*xb*ya +
>            xa^2*xd*ya -
>            2*xa*xb*xd*ya +
>            xb*ya^3 + xd*ya^3 -
>            xa^3*yb + xa^2*xd*
>            yb - xa*ya^2*yb -
>            xd*ya^2*yb)/
>           (xa^3 - xa^2*xb +
>            xa*ya^2 + xb*ya^2 -
>            2*xa*ya*yb))^2)*
>       zb^2)/((xa - xb)^2 +
>       (ya - yb)^2) == l^2
>
>
> Solving these two is now a breeze for the G5 duo and both give two
> solutions.  The third and fourth solutions for xd are quite a few
> pages long.
>
> I am wondering if there is another way - like using cylindrical
> coordinate system or using Reduce - to get shorter looking
> solutions.  Does Solve do a FullSimplify on its findings ?
>
>
> Jç?£os
>
>
> ----------------------------------------------
> Trying to argue with a politician is like lifting up the head of a
> corpse.
> (S. Lem: His Master Voice)

```

• Prev by Date: Re: 3D-plot over a triangle
• Next by Date: Re: Finding a shorter form for coplanar point in 3D space
• Previous by thread: Finding a shorter form for coplanar point in 3D space
• Next by thread: Re: Finding a shorter form for coplanar point in 3D space