Rodrigues’ rotation formula: Difference between revisions

m
→‎JavaScript: ES6: Tidied dotProduct, matrixMultiply
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));
sum,
zipWith(a => b => a * b)(xs)
);
 
 
const matrixMultiply = matrix =>
compose(
v => matrix.map(flip(dotProduct)(v));
flip(map)(matrix),
v => matrix.map(flip( dotProduct)(v));
);
 
 
Line 392 ⟶ 397:
// its arguments reversed.
x => y => op(y)(x);
 
 
// dotProductmap :: [[Float]](a -> b) -> [[Float]a] -> [[Float]b]
const map = f =>
// The list obtained by applying f
// to each element of xs.
// (The image of xs under f).
xs => [...xs].map(f);
 
 
9,655

edits