Rodrigues’ rotation formula: Difference between revisions
m
→JavaScript: ES6: Tidied dotProduct, matrixMultiply
Thundergnat (talk | contribs) m (→{{header|Raku}}: minor stylistic tweaks) |
m (→JavaScript: ES6: Tidied dotProduct, matrixMultiply) |
||
Line 353:
// dotProduct :: [[Float]] -> [[Float]] -> [[Float]]▼
const dotProduct = xs =>
compose(
sum,
zipWith(a => b => a * b)(xs)
);
const matrixMultiply = matrix =>
compose(
v => matrix.map(flip(dotProduct)(v));▼
flip(map)(matrix),
);
Line 392 ⟶ 397:
// its arguments reversed.
x => y => op(y)(x);
const map = f =>
// The list obtained by applying f
// to each element of xs.
// (The image of xs under f).
xs => [...xs].map(f);
|