There is no need for your boxing, just the parentheses suffice when
combined with concatenation.

mx =: +/ . *
sin =: 1&o.
cos=: 2&o.
rotation =: (cos , -@sin) ,:sin , cos
rotate =: (mx~ rotation)~ NB. φ rotate x y


If these are the first steps with J, prepare for some amazement indeed!

Eg. the power conjunction:

clean =: (* |@*) NB. clean small values from the output for clarity:
NB. rotate a point in steps of 45 degrees, nine steps

clean 1r4p1 rotate^:(<9) ] 1 1

You might want to check out the Lab: Fractals, Visualization & J. It
contains quite a bit on transformations.

Kind regards,

Jan-Pieter


2014-04-23 18:16 GMT+02:00 alexgian <[email protected]>:

> OK, this won't impress any old hands, but I loved the way this turned out
> so easy!
> A matrix of rotation for a point on a 2-d plane:
>
> rotation =: [: > (cos;-&sin),:sin;cos
>
> rotate =: (mx~ rotation)~ NB. φ rotate x y
>
>
> Hm, looking at it now, I could have the unbox in the rotate function rather
> than the rotation matrix, I'l go try that now.
> ----------------------------------------------------------------------
> 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