vec3=: [: ((* {.)~ , {:@[)/ 2 1 o.~/~ ]

In the end though the most readable is probably Bo’s. No distracting array 
tricks.

Louis

> On 7 Jan 2018, at 02:26, Jimmy Gauvin <[email protected]> wrote:
> 
> This might be easier on the eyes:
> 
>   vc=:_2 */\ 1 2 1 1 2 o. 5 $ o.
> 
>   vc 1.25,_0.55
> 0.110616 0.698401 _0.707107
> 
> 
>> On Sat, Jan 6, 2018 at 7:05 PM, Henry Rich <[email protected]> wrote:
>> 
>> Not really any better, but you might enjoy playing with it:
>> 
>> vec2 =: ((+.@:(* {:) , {.@]) +.)~/@:(^@:j.)
>> 
>> Henry Rich
>> 
>> 
>>> On 1/6/2018 5:07 PM, Jerry wrote:
>>> 
>>> I am a relative newbie and am trying to teach myself the intricacies by
>>> addressing a simple problem: some geometric operations on the surface of a
>>> unit sphere.  The first step is to take latitude and longitude angles and
>>> create a Cartesian vector pointing from the center of the sphere to that
>>> point.  I can do that via:
>>> 
>>> vec =: ((1 o. }:)*(2 o. {:)),((1 o. }:)*(1 o. {:)),(2 o. }:)
>>> 
>>> this verb yields the desired vector
>>> 
>>>    [vec o. (1.25,_0.55)
>>> 
>>> 0.110616 0.698401 _0.707107
>>> 
>>>   +/([vec o. (1.25,_0.55))^2
>>> 
>>> 1
>>> 
>>> Is there a shorter, less verbose way of writing the verb 'vec'?
>>> 
>>> ----------------------------------------------------------------------
>>> For information about J forums see http://www.jsoftware.com/forums.htm
>>> 
>> 
>> 
>> ---
>> This email has been checked for viruses by AVG.
>> http://www.avg.com
>> 
>> 
>> ----------------------------------------------------------------------
>> 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