Chris,
Here's your Lingo solution followed by a trig lesson as to how it was derived...

----------------------
-- The Lingo Lesson --
----------------------

--
on arcCos (thisValue)

  -- compute appropriate theta value using
  -- the arctan function
  numerator = sqrt(1 - (thisValue * thisValue))
  theta = arctan( numerator/thisValue )

  -- return the angle value
  return theta

end arcCos
--

--
on arcSin (thisValue)

  -- compute appropriate theta value using
  -- the arctan function
  denominator = sqrt(1 - (thisValue * thisValue))
  theta = arctan( thisValue/denominator )

  -- return the angle value
  return theta

end arcSin 
--


---------------------
-- The Trig Lesson --
---------------------

There is no inverse cosine, or inverse sine functions, we only have access to the 
inverse tangent function, arctan. But can can in fact get the desired information 
(inverse cosine/sine) using arctan and the following:

Whave a variable someValue and we want to find the inverse sine of that value. Let's 
start by declaring what we "know":

(1) sin(theta) = someValue

What we now want is the value of theta. What else do we know with respect to trig 
relationships (sine/cosine/tangent) and the mysterious theta angle:

(2) tan(theta) = sin(theta)/cos(theta)
(3) sin(theta)^2 + cos(theta)^2 = 1

Let's rewrite equation (3) to read:

(4) cos(theta) = sqrt(1 - sin(theta)^2)

and put that into equation (2) to get:

(5) tan(theta) = sin(theta)/(sqrt(1 - sin(theta)^2))

Ahhhh, but we know the numerical value of sin(theta), it is someValue (as stated above 
in equation (1)). Therefore we can rewrite (5) as:

(6) tan(theta) = someValue/(sqrt(1 - someValue^2))

And now, being able to calculate the value on the right, we can use the inverse 
tangent function to get the value of theta itself (the desired goal):

(7) theta = arctan( someValue/(sqrt(1 - someValue^2))

Now, you asked about cosine in particular whereas I discussed the sine option above, I 
guess that's just cause I wanted to teach a lil' general trig so that you can add this 
to your skillset in the future while mucking about in Lingo. ;) For the case of 
wanting to get the value of the inverse cosine, we'd need to change lines (1) and then 
(4) through (7) to be:

(1b) cos(theta) = someValue
(4b) sin(theta) = sqrt(1 - cos(theta)^2)
(5b) tan(theta) = (sqrt(1 - cos(theta)^2))/cos(theta)
(6b) tan(theta) = (sqrt(1 - someValue^2))/someValue
(7b) theta = arctan( (sqrt(1 - someValue^2))/someValue )


Rock on,
Tom

[To remove yourself from this list, or to change to digest mode, go to
http://www.penworks.com/LUJ/lingo-l.cgi  To post messages to the list,
email [EMAIL PROTECTED]  (Problems, email [EMAIL PROTECTED])
Lingo-L is for learning and helping with programming Lingo.  Thanks!]

Reply via email to