APL(NARS), 116 chars
r←a C w;d;v;m;p
r←d←1+(2≠↑a)×w-1⋄m←w×wׯ1⋄p←2⊃a⋄v←0 1-(2=↑a)
→0×⍳0≥p-←1⋄r+←d×←m÷×/v+←2⋄→2
z←⎕⋄6⍕1 z[2]C↑z⋄6⍕2 z[2]C↑z
15+44+28+2+27=116
the last line call the function C that is a sin and cos function depend of input (input ≠2 is sin input =2 is cos)
z←⎕⋄6⍕1 z[2]C↑z⋄6⍕2 z[2]C↑z
⎕:
5 3
10.208333
14.541667
z←⎕⋄6⍕1 z[2]C↑z⋄6⍕2 z[2]C↑z
⎕:
8.555 13
0.765431
¯0.641092
z←⎕⋄6⍕1 z[2]C↑z⋄6⍕2 z[2]C↑z
⎕:
9.26 10
¯3.154677
¯8.404354
z←⎕⋄6⍕1 z[2]C↑z⋄6⍕2 z[2]C↑z
⎕:
6.54 12
0.253986
0.967147
z←⎕⋄6⍕1 z[2]C↑z⋄6⍕2 z[2]C↑z
⎕:
5 1
5.000000
1.000000
z←⎕⋄6⍕1 z[2]C↑z⋄6⍕2 z[2]C↑z
⎕:
20 20
¯5364.411846
¯10898.499385
OT it would be possible to calculate the exact answer using rationals and input rational
z←⎕⋄1 z[2]C↑z⋄2 z[2]C↑z
⎕:
1r4 10
8264318085745811128158727r33404146443928530321408000
17051609536099989115458551r17598710837038136237752320