Win a copy of Zero to AI - A non-technical, hype-free guide to prospering in the AI era this week in the Artificial Intelligence and Machine Learning forum!
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
• Campbell Ritchie
• Liutauras Vilda
• Paul Clapham
• Bear Bibeault
• Jeanne Boyarsky
Sheriffs:
• Ron McLeod
• Tim Cooke
• Devaka Cooray
Saloon Keepers:
• Tim Moores
• Tim Holloway
• Jj Roberts
• Stephan van Hulst
• Carey Brown
Bartenders:
• salvin francis
• Scott Selikoff
• fred rosenberger

# calculating cosec or sec

Greenhorn
Posts: 21
hi, i need to calculate this term:
a = sin^(-1)(x/r)
sin^(-1) == sec
how do i calculate the invertet sinus or cosinus?
thanks!

Ranch Hand
Posts: 3451
Hi Martin,
Welcome to JavaRanch. The sin, cos and tan functions along with their inverts are located in the Math class. To do what you want would be:

I'm not sure what you mean by sin^(-1) == sec. The secant function is the reciprocal of the cosine so you would get it by doing something like:

All of these return doubles and take radians as their arguments. But if you have degrees the Math class also has a toRadians() method to do the conversion. You should take a look at the API docs on the Math class.

martin chile
Greenhorn
Posts: 21
i have tried this before, but it doesnt work or im making something completly wrong.
i want to get the degrees of elevation(0 <= a < 360) of a certain point relative to the middle of the screen.
the formula is (sin a = x / r) .x is point.y - panel.getHeight()/2 . r is the distance between the middle and the point.
this is my solution but im not getting a usefully value: