I wrote:
> Bearing in mind that I have no idea what I’m doing ..
> 
> load’trig'
> PROJ     =:  2 3 0 , 4 2 0 ,: 0 0 1
> 
> rotate   =:  [: +/ .*/ 0 1 0 eul2rot"0 +&0 0 0
>  eul2rot =:  rotM proj { f
>    rotM  =:  (2 # [) |. ]
>    f     =:  0:, 1:, cos, sin, -@sin
> …
> 
> One may also consider doing something like ( PROJ { 0:`1:`cos`sin`(-@sin) ) 
> `:0 but at the moment I’m not seeing a lot of advantage in that (and some 
> disadvantages).

Here’s one way to do that:

eul2rot2 =: ] 4 : 'y`:0 x' 0:`1:`cos`sin`(-@sin) {~ rotM&PROJ@[

Or, if the ][ bugs you:

eul2rot2 =: (4 : 'y`:0 x' 0:`1:`cos`sin`(-@sin) {~ rotM&PROJ)~

The disadvantage, of course, is that the need for (`:0) puts a lot of pressure 
on us to use explicit code, in an otherwise function-level formulation.

But what I like about the gerund approach is that 

  a. we create and apply matrix of gerunds, which is the closest approximation 
to the mathematical formulation (e.g. [1]) I think we’re going to get
  b. one can see immediately what angular functions are being applied,
  c. the rotation has been distilled, and is now applied to the most attract 
representation of the rotation matrix: the integers representing the various 
angular functions.

In re: (c), if we wanted to rotate the array of gerunds instead, we could do 
that instead, of course.

I still think it would be cleaner to construct the matrix analytically, i.e. 
re-derive the reasons those angular functions are applied at those particular 
indices.  Build it up, array-wise, from first principles (as it were).

-Dan

[1] Representation of rotation with a matrix of functions:
    http://nghiaho.com/?page_id=846 <http://nghiaho.com/?page_id=846>


----------------------------------------------------------------------
For information about J forums see http://www.jsoftware.com/forums.htm

Reply via email to