I would be tempted to use something like:
R=: (2 1,:1 2) o. _1 1&*
For example:
R"0(0 30p1 45p1 60p1%180)
1 0
0 1
0.866025 _0.5
0.5 0.866025
0.707107 _0.707107
0.707107 0.707107
0.5 _0.866025
0.866025 0.5
FYI,
--
Raul
On Fri, Dec 18, 2020 at 2:59 AM Francesco Pedulla' <[email protected]> wrote:
>
> Dear all,
> I need to represent the 2D rotation matrix 'R'
>
> R = |cos(t) -sin(t)|
> |sin(t) cos(t)|
>
> and compute it for different values of the rotation angle 't'. I am aware
> the matrix of function can be represented as a gerund, which I like:
>
> R =: 2 2$cos`(-@sin)`sin`cos .
>
> To compute R(t), I wrote the following definition:
>
> mf =: conjunction : '($x)$,(,x)/.((+/$x)$y)'
>
>
> so that "R mf pi%4" returns R(pi/4). But I find the code for 'mf' not very
> elegant. Is there a better way to achieve this?
> Thanks in advance for any hint,
>
> Francesco
> ----------------------------------------------------------------------
> For information about J forums see http://www.jsoftware.com/forums.htm
----------------------------------------------------------------------
For information about J forums see http://www.jsoftware.com/forums.htm