(For educational purposes) I defined the following functions:
Translation (in $\mathbb{R}^2$):
trM[vec_] := {{1, 0, vec[[1]]}, {0, 1, vec[[2]]}, {0, 0, 1}} Rotation (in R2$\mathbb{R}^2$):
rotM[angle_] := {{Cos[angle], -Sin[angle], 0}, {Sin[angle], Cos[angle], 0}, {0, 0, 1}} Rotation around a point (in $\mathbb{R}^2$):
rotM[pt_, angle_] := trM[pt].rotM[angle].trM[-pt] So far so good, now I want a function:
rotM[angle_, n_] := {{Cos[n angle], -Sin[n angle], 0}, {Sin[n angle], Cos[n angle], 0}, {0, 0, 1}} Now
rotM[angle_, n_] and
rotM[pt_, angle_] share — in Mathematica — the same signature, which breaks the polymorphism I intended to use, which then leads to the following question.
How can I type-check the arguments of a Mathematica function to enforce polymorphism?