Rodrigues’ rotation formula: Difference between revisions
m
→{{header|Wren}}: Changed to Wren S/H
Thundergnat (talk | contribs) m (syntax highlighting fixup automation) |
m (→{{header|Wren}}: Changed to Wren S/H) |
||
(2 intermediate revisions by one other user not shown) | |||
Line 1,085:
Rotated 170°: -4.1240220834695, 5.7201633384526, -5.2222766334692
Rotated 180°: -5.0000000000000, 6.0000000000000, -4.0000000000000</pre>
=={{header|RPL}}==
This is a direct transcription from Wikipedia's formula.
≪ DEG SWAP DUP ABS / <span style="color:grey">@ set degrees mode and normalize k</span>
→ v θ k
≪ v θ COS *
k v CROSS θ SIN * +
k DUP v DOT * 1 θ COS - * +
→NUM <span style="color:grey">@ can be removed if using HP-28/48 ROM versions</span>
≫ ≫ '<span style="color:blue">ROTV</span>' STO <span style="color:grey">@ ''( vector axis-vector angle → rotated-vector )''</span>
[-1 2 .4] [0 2 1] 18 <span style="color:blue">ROTV</span>
{{out}}
<pre>
[-1.11689243765 1.85005696279 .699886074428]
</pre>
=={{header|Wren}}==
{{trans|JavaScript}}
<syntaxhighlight lang="
var normalize = Fn.new { |v|
|