# How to get array/list of results of RotationMatrix?

For most other functions, passing in a list of arguments will return a list of results. E.g.

t = Range[0, 10];
m = N[Sin[t]]


returns

{0., 0.841471, 0.909297, 0.14112, -0.756802, -0.958924, -0.279415,
0.656987, 0.989358, 0.412118, -0.544021}


I would like a list of rotation matrices for each element in t like this

matList = RotationMatrix[t]


but it returns an error. Is there a way I can do this?

Thanks!

• Print[{Attributes[Sin], Attributes[RotationMatrix]} ];(* then you need*) RotationMatrix /@ Range@10 – Dr. belisarius Feb 18 '15 at 0:31
• RotationMatrix does not have attribute Listable. So map it over the list... – ciao Feb 18 '15 at 0:31
• Indeed RotationMatrix is not Listable, in part because the function can take a list of two vectors as arguments to compute the rotation matrix that takes vector 1 to vector 2. – David G. Stork Feb 18 '15 at 0:50

RotationMatrix is not Listable

Attributes[RotationMatrix]


So you have to use Map (or Table) here

matList = RotationMatrix /@ t
(* {{{1, 0}, {0, 1}}, {{Cos, -Sin}, {Sin, Cos}}, ...} *)


You can define custom listable function like this

r[t_] := RotationMatrix[t]
SetAttributes[r, Listable]

r[t]
(* {{{1, 0}, {0, 1}}, {{Cos, -Sin}, {Sin, Cos}}, ... } *)


Yet another approach is to calculate the rotation matrix analytically. It contains Sin and Cos which are Listable. You can effectively do it with Block

Block[{t}, RotationMatrix[t]]
(* {{{1, Cos, ...}, {0, -Sin, ...}}, {{0, Sin, ...}, {1, Cos, ...}}} *)


Note the another order of dimensions.