Using a little bit of trigonometry, you can set up an equation:
Solving this for x, you get
You can convert this almost directly into
Java using the
Math class:
The Math class also provides methods for cosine, tangent, and other nifty mathematical functions. See the link provided above for the Javadocs for this class.
HTH
Layne
[ March 10, 2005: Message edited by: Layne Lund ]