Re: Tan,Cos and Sin

new topic     » goto parent     » topic index » view thread      » older message » newer message

Lewis Townsend wrote:
>Isn't the inverse of a trig function just the
>function of the inverse of the ratio
> ex:  sin (1/3)
>      sin^-1 (3/1)
ummmm no.
sin(1/3)   = 0.0058
arcsin(3)  = *error*
sin(3)     = 0.0523
arcsin(1/3)= 19.471
however, arcsin, and arccos can be calculated with use
of the other functions we have available.


function arcsin(object x)
--returns the arccos expressed in *radians*
--here we know opp and hyp, and we need opp/adj
--we can assume hyp is 1, since we are given opp/hyp
--expressed as a ratio "over 1"
--object opp --we know this already, here for clarity
  object adj
   --opp=x                 --for clarity
   --adj=sqrt(1-opp*opp)   --for clarity
     adj=sqrt(1-x*x)
   --return arctan(opp/adj)--for clarity
     return arctan(x/adj)
end function

function arccos(object x)
--returns the arccos expressed in *radians*
--here we know adj and hyp and we need opp/adj,
--we can assume hyp is 1, since we are given opp/hyp
--expressed as a ratio "over 1"
  object opp
--object adj --we know this already, here for clarity
   --adj=x                 --for clarity
   --opp=sqrt(1-adj*adj)   --for clarity
     opp=sqrt(1-x*x)
   --return arctan(opp/adj)--for clarity
     return arctan(opp/x)
end function

you can test the above functions if you like :)
--Hawke'

new topic     » goto parent     » topic index » view thread      » older message » newer message

Search



Quick Links

User menu

Not signed in.

Misc Menu