I need a routine which makes rotation matrices for a given angle.
For example, let's say that my angle is 0.05p1, I would be wanting
these two rotation matrices:
3 3$(2 1 o./ (,-)0.05p1) 0 4 1 3}&,=i.3
0.987688 0.156434 0
_0.156434 0.987688 0
0 0 1
and
3 3$(2 1 o./ (,-)0.05p1) 4 8 5 7}&,=i.3
1 0 0
0 0.987688 0.156434
0 _0.156434 0.987688
Now, obviously, I could implement this directly:
rotmat=:dyad define
3 3$(2 1 o./ (,-)y) (0 4 1 3+4*x)}&,=i.3
)
But it seems to me that there ought to be a better way of doing this.
And by better I mean more concise and direct.
But I'm not seeing that.
The best alternative I have thought of so far is:
elcric=:dyad define"0
if. 1<|y do.
(_2+|y) o. x**y
else.
y
end.
)
rotmat=:dyad define
(1 1-x) |. y elcric 1 0 0,0 4 3,:0 _3 4
)
And while maybe that satisfies some concept of "prettier" it is not
more concise and it is not more direct. It is not even faster.
That said, what I really want to build would be this:
rotate=:monad define
+/ .*/ 0 1 0 rotmat"0 y+0 0 0
)
(I threw in the unnecessary +0 0 0 to emphasize that I expect three angles.)
In other words, I have three different euler angles and I want the
rotation matrix they represent. So maybe there is even something
already implemented for this purpose? (But when I search jsoftware.com
for mentions of euler angles, I don't see anything promising.)
Any ideas?
Thanks,
--
Raul
P.S. I imagine I could live with getting the rotation quaternion they
represent, instead of the rotation matrix. But I have not investigated
the details of that approach here.
----------------------------------------------------------------------
For information about J forums see http://www.jsoftware.com/forums.htm