I took your question to be about whether the segment intersects the boundary, 
and solved a quadratic equation to find possible intersections: if the 
quadratic 
has a root between 0 and 1 inclusive there is an intersection.  t is "set" in 
the line

( t e. (C o E) (+ , -) %: D )

which uses the quadratic formula

(2*a) %~ (-b) (+ , -) %: (*: b) - 4*a*c

It would be simpler to use p. to find the roots, then check whether one of them 
is between 0 and 1 inclusive.

As your question was about whether the segment intersects the boundary plus 
interior, I will have to think some more.

Kip


On 10/7/2010 7:04 AM, Henry Rich wrote:
> I'm taking it that the solution is three expressions ANDed together.
>
> But I don't see where t is set, so I don't see how to execute this.
>
> Henry Rich
>
> On 10/6/2010 11:30 PM, Kip Murray wrote:
>> Let us consider the case where S is the origin and E is a unit vector.  The
>> general problem can be reduced to that case.  The segment SE intersects the
>> sphere with center C and radius R provided
>>
>> (*: R) = *: length (t*E) - C
>>
>> for some number t with (0<: t) *. (t<: 1) .
>>
>> Using (V o V) = *: length V  where o is +/ . * we arrive at
>>
>> ( 0<: D =: (*: R) + (*: C o E) - (C o C) )
>>
>> *.
>>
>> ( t e. (C o E) (+ , -) %: D )
>>
>> *.
>>
>> ( (0<: t) *. (t<: 1) )
>>
>> as the condition for segment ES to intersect the sphere.  --Kip Murray
>>
>>
>> On 10/6/2010 3:53 PM, Henry Rich wrote:
>>> Given circle/sphere with center C and radius R, and a line-segment with
>>> startpoint S and endpoint E, write the J code to tell whether the
>>> line-segment intersects the circle/sphere.
>>>
>>> R is an atom, the rest are lists with 2 or 3 atoms.
>>>
>>> This problem arises in collision detection for games and simulators, or
>>> if you are trying to see whether a path intersects a round obstacle.
>>>
>>> I found a solution whose brevity surprised me.
>>>
>>> Henry Rich
>>> ----------------------------------------------------------------------
>>> For information about J forums see http://www.jsoftware.com/forums.htm
>> ----------------------------------------------------------------------
>> For information about J forums see http://www.jsoftware.com/forums.htm
>>
> ----------------------------------------------------------------------
> For information about J forums see http://www.jsoftware.com/forums.htm
----------------------------------------------------------------------
For information about J forums see http://www.jsoftware.com/forums.htm

Reply via email to