[futurebasic] Re: [FB] A Pointy Problem

Message: < previous - next > : Reply : Subscribe : Cleanse
Home   : January 2002 : Group Archive : Group : All Groups

From: "Ashley Butterworth" <macbse@...>
Date: Wed, 16 Jan 2002
>In vernacular the solid cone is a teepee:  D is
>its base; A is its peak; C is the fire in the
>center of the base; the axis is the smoke rising;
>and theta is the angle between the smoke rising
>and one of the support poles from the edge of the
>base to the peak.
>
>NASA gives you the coordinates of a mosquito M and
>you are asked to calculate (using FB on your ibook)
>whether the mosquito is inside the teepee. You
>already know the coordinates of A and C and the
>value of the angle theta, 0 < theta < pi/2
>
>Three things are easily calculated and will give the 
>solution.
>
>    (i) the distance AM, call it |AM|
>    (ii) the distance AC, , call it |AC|
>    (iii) tha angle (CAM), call it phi ( 0<= phi <= pi )
>
>Indeed the mosquito M is in the teepee precisely
>if
>
>(a)  |AM|*COS(phi) is greater than  0  and less than |AC|
>(b)  phi < theta
>
>You all know how to evaluate the distances.
>The vector inner product <AM,AC> determines
>phi by the equation:-
>
>           <AM,AC> = |AM|*|AC|*COS(phi)
>
>Here <AM,AC> is:
>
>          <AM,AC> = AM1*AC1 + AM2*AC2 + AM3*AC3
>
>   where 
>
>   AM = (AM1,AM2,AM3) = (A1-M1,A2-M2,A3-M3)   
>   AC = (AC1,AC2,AC3) = (A1-C1,A2-C2,A3-C3)
>
>Recall that |AM|=SQR(<AM,AM>), |AC|=SQR(<AC,AC>).
>
>That's a solution with a minimum of sweat.  And no
>special coordinate transformations are needed!
>
>Cheers
>
>Laurent S.

Laurent,
  Have I translated this into code correctly? (sX#,sY#,sZ#) is the coordinate of the peak (A), (lX#,lY#,lZ#) is the coordinate of the mosquito (M) and the center (C) is the origin (0,0,0). Looking at your suggestions and applying what I think are the correct equations I get the following code.

'-----Begin FB^3 Code-----
'This should format properly in the FB Editor

SLX# = lX#-sX# : SLY# = lY#-sY# : SLZ# = lZ#-sZ#
SL# = sqr(SLX#^2 + SLY#^2 +SLZ#^2)
SC# = sqr(sX#^2 + sY#^2 + sZ#^2)

SLSC# = SLX#*sX# + SLY#*sY# + SLZ#*sZ#
phi# = acos(SLSC#/(SL#*SC#)

SLcosphi# = SL# * cos(phi#)
long if SLcosphi# > 0 and SLcosphi# <= SC# and phi# <= theta#
inCone = _zTrue
xelse
inCone = _false
end if

'----- End FB^3 Code -----

  Thanks for the help so far,

  Regards,

  Ashley ~)~

=============================================================
Ashley Butterworth
Email: macbse@...
=============================================================


_________________________________________________________
Do You Yahoo!?
Get your free @yahoo.com address at http://mail.yahoo.com