Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

Difficulty calculating Law of Sines in Java

In this, I’m trying to follow law of sines in order to find angle A. The correct answer for this is 39.41 but for some reason, I’m not getting the correct inverse sine value. How can I fix this?

Visualization of the problem

import static java.lang.Math.*;
public class test
{
    public static void calculateAzimuth()
    {
        double a = 90;
        double A = 0;
        double c = 132.3459;
        double C = 111;
        
        //         a          C     c
        //sine^-1( 90* ( (sine111) /132.3459)) = A
        C = sin(toRadians(C));
        A = C/c; 
        A = (A*a);
        A = asin(A);
        System.out.println("Angle " + A);
    }
}

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

>Solution :

call toDegrees on your result

public static void main(String[] args) {
    double a = 90;
    double A = 0;
    double c = 132.3459;
    double C = 111;

    A = asin( sin(toRadians(C)) / c * a);
    System.out.println("Angle " + toDegrees(A));
}
Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading