Acdream 1203 Kidx ' s Triangle (solution triangle)

Source: Internet
Author: User

Topic Link: Portal

Analysis

A,b,c,d for a given angle. Then the angle AED, the problem is actually the high school computational Geometry solution triangle problem.

Sine theorem: A/sin (A) = B/sin (B) = C/sin (C) =2*r (R is the radius of the Triangle circumscribed circle)

Cosine theorem: a^2 = b^2 + C^2-2*b*c*cos (A).

Then we set ab = x, then we can find the ad,bd,be,ae by the sine theorem, and then pass the cosine theorem

We can find out that the de finally can find the angle aed by the sine theorem. It is important to note that the range of ASIN () is

[-PI/2,PI/2], we also need to determine the range of the angle after we get the value of sin (AED). This question needs

The case for a few horns is 0. See Code for concrete implementations.

The code is as follows:

#include <iostream> #include <cstring> #include <cstdio> #include <cmath>using namespace std; Const double PI = ACOs ( -1.0);d ouble getr (double x) {return x/180.0*pi;}    int main () {double a,b,c,d; while (cin>>a>>b>>c>>d) {if (a==0| |            c==0) {printf ("0.00\n");        Continue            } else if (b==0) {printf ("%.2lf\n", c);        Continue            } else if (d==0) {printf ("%.2lf\n", b+c);        Continue        } Double ab = 10.0;        A = Getr (a);        b = Getr (b);        c = Getr (c);        D = Getr (d);        Double ad = Ab*sin (c)/sin (PI-B-C-A);        DOUBLE BD = Ab*sin (a+b)/sin (pi-b-c-a);        Double be = Ab*sin (b)/sin (pi-b-c-d);        Double AE = ab*sin (d+c)/sin (pi-b-c-d);        Double de = sqrt (Bd*bd+be*be-2*bd*be*cos (d));        Double Sinans = Ad/de*sin (a);        Double ans;        if (ad*ad>de*de+ae*ae) ans = 180-asin (Sinans)/pi*180.0; else ans = aSin (sinans)/pi*180.0;    printf ("%.2lf\n", ans); } return 0;}


Copyright NOTICE: This article for Bo Master original article, without Bo Master permission not reproduced.

Acdream 1203 Kidx ' s Triangle (solution triangle)

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.