Services & Resources / Wolfram Forums
-----
 /
MathGroup Archive
2006
*January
*February
*March
*April
*May
*June
*July
*August
*September
*October
*November
*December
*Archive Index
*Ask about this page
*Print this page
*Give us feedback
*Sign up for the Wolfram Insider

MathGroup Archive 2006

[Date Index] [Thread Index] [Author Index]

Search the Archive

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

  • To: mathgroup at smc.vnet.net
  • Subject: [mg65158] Re: [mg65135] Finding a shorter form for coplanar point in 3D space
  • From: Daniel Lichtblau <danl at wolfram.com>
  • Date: Wed, 15 Mar 2006 23:59:32 -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).
> 
>  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[1]:=
> m = {{xa, ya, 0}, {xb, yb,
>      zb}, {xd, yd, zd}}
> 
> In[2]:=
> eqn1 = Det[m] == 0
> Out[2]=
> xd*ya*zb - xa*yd*zb -
>     xb*ya*zd + xa*yb*zd == 0
> 
> The second equation is coming from the fact that the distance between  
> C and D is "l":
> 
> In[11]:=
> eqn2 = (xc - xd)^2 +
>      (yc - yd)^2 + zd^2 == l^2
> 
> 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[22]:=
> solzd = Solve[eqn3, zd]
> Out[22]=
> {{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[8]:=
> eqn1
> Out[8]=
> 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[13]:=
> eqn2
> Out[13]=
> (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[22]:=
> solyd = Flatten[Solve[eqn1,
>      yd]]
> Out[22]=
> {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[28]:=
> eqn21 = eqn2 /. yd ->
>      solyd[[1,2]]
> Out[28]=
> (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[33]:=
> eqn22 = eqn2 /. yd ->
>      solyd[[2,2]]
> Out[33]=
> (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 ?
> 
> Thanks ahead,
> 
> János
> 
> 
> ----------------------------------------------
> Trying to argue with a politician is like lifting up the head of a  
> corpse.
> (S. Lem: His Master Voice)


I don't know offhand how small or otherwise "nice" one can make the 
symbolic solution e.g. by changing coordinate systems. I will speculate 
that this will not much help because the conversion back will inflate 
the solution size and generally defeat simplicity.

I would set it up a bit differently. Enforce coplanarity by having D's 
coordinates lie on the line AB using a point-and-direction-vector 
formulation. This will add a variable but give three equations. This 
formulation is a NASC (necessary and sufficient condition) for D to be 
on the line AB; your determinant is necessary but only enforces that D 
lie in the plane containing A, B, and the origin. The last equation I'll 
use is for distance CD.

Also I would expect two solutions based on geometric considerations. 
Once you fix C in the x-y coordinate plane, and proceed to intersect the 
segment CD, at D, with the line AB, you realize there will be at most 
two real solutions, one on each side of the perp from C to line AB. In 
general there will be exactly two (possibly complex valued) solutions. 
Algebraically one sees this because we have three linear and one 
quadratic equation.

Below I change the naming conventions a bit so, for example, the {x,y,z} 
coordinates of the first point are {a[1],a[2],a[3]}.

aa = Array[a,3];
bb = Array[b,3];
cc = Array[c,3];
dd = Array[d,3];

InputForm[polys = Flatten[{dd - (1-t)*aa + t*bb, (cc-dd).(cc-dd) - ll}]]
Out[25]//InputForm=
{-((1 - t)*a[1]) + t*b[1] + d[1], -((1 - t)*a[2]) + t*b[2] + d[2],
  -((1 - t)*a[3]) + t*b[3] + d[3], -ll + (c[1] - d[1])^2 +
  (c[2] - d[2])^2 + (c[3] - d[3])^2}

In[18]:= Timing[soln = Solve[polys==0, dd, t];]
Out[18]= {2.23614 Second, Null}

In[19]:= Length[soln]
Out[19]= 2

In[20]:= LeafCount[soln]
Out[20]= 12761

When I run the solutions through Simplify the leaf count drops to a bit 
under 5000.


Daniel Lichtblau
Wolfram Research






  • Prev by Date: Re: Finding a shorter form for coplanar point in 3D space
  • Next by Date: Re: Unevaluated a[[1]]*a[[2]]
  • Previous by thread: Re: Finding a shorter form for coplanar point in 3D space
  • Next by thread: Re: Finding a shorter form for coplanar point in 3D space