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:
am i on the right way?
or does anyone know a better way to do this?
thanks

Ranch Hand
Posts: 83
• • • • Note that sin^(-1) != 1/sin. Generally, mathematicians use sin^(-1) to represent the inverse function of the sine function, known as the arcsine function, or in javaspeak, Math.asin. In general, Math.asin(x) != 1/Math.sin(x). Think of asin(x) as the angle between -pi/2 and pi/2 you have to take the sine of to get x. For instance, sin(45 degrees) = sqrt(2)/2, so asin(sqrt(2)/2) = 45 degrees. Note that it's only legal to pass asin() values between -1 and 1, and that you'll always get an answer back between -pi/2 (-90 degrees) and pi/2 (90 degrees).
I'd recommend researching the definition of the sine and cosine functions and their inverses, and drawing pictures. You might find the problem easier if you restrict x and y to nonnegative values at first.
If you're given x and r, then you'll unfortunately have two answers for your angle. One will be between 0 and pi (y is positive), and one will be between pi and 2*pi (y is negative). The airline is called "Virgin"? Don't you want a plane to go all the way? This tiny ad will go all the way: the value of filler advertising in 2020 https://coderanch.com/t/730886/filler-advertising