Math A Rescue The Princess

Source: Internet
Author: User
Tags acos cmath

Topic Portal

1 /*2 It is known that the constant amount (x, y) rotates it by the coordinates of the θ (x*cosθ-y * sinθθ, y*cosθ+ x * sinθθ)3 apply to the subject, X to (Xb-xa), Y to (Yb-ya) position relative to a point, that is, B rotates around a point 60 degrees to C point4 Note: Coordinates that are added back to point a after the calculation are the coordinates relative to the Origin .5 Detailed Explanation:http://www.tuicool.com/articles/FnEZJb6 */7#include <cstdio>8#include <cmath>9#include <algorithm>Ten#include <iostream> One#include <cstring> A using namespacestd; -  - Const DoublePI = ACOs (-1.0); the  - intMainvoid)//A Rescue the Princess - { -     //freopen ("A.txt", "R", stdin); +      -     intT; +      while(SCANF ("%d", &t) = =1) A     { at          while(t--) -         { -             Doublexa, ya, xb, YB, XD, yd; -scanf ("%LF%LF%LF%LF", &xa, &ya, &AMP;XB, &YB); -             DoubleXC = (XB-XA) * cos (pi/3.0)-(Yb-ya) * SIN (pi/3.0) +xa; -             DoubleYC = (yb-ya) * cos (pi/3.0) + (xb-xa) * SIN (pi/3.0) +ya; inprintf ("(%.2f,%.2f) \ n", XC, YC); -         } to     } +      -     return 0; the}
1 /*2 The increment of C point to point A is length * cos/sin, angle is 60 + slope angle3 */4#include <cstdio>5#include <cmath>6#include <algorithm>7#include <iostream>8#include <cstring>9 using namespacestd;Ten  One Const DoublePI = ACOs (-1.0); A  - intMainvoid)//A Rescue the Princess - { the     //freopen ("A.txt", "R", stdin); -      -     intT; -      while(SCANF ("%d", &t) = =1) +     { -          while(t--) +         { A             Doublexa, ya, xb, YB, XD, yd; atscanf ("%LF%LF%LF%LF", &xa, &ya, &AMP;XB, &YB); -             DoubleAB = sqrt ((XA-XB) * (XA-XB) + (YA-YB) * (ya-yb)); -             DoubleR = Atan ((ya-yb)/(XA-xb)); -             DoubleXC = xa + ab * cos (R + PI/3.0); -             DoubleYC = ya + ab * sin (R + PI/3.0); -printf ("(%.2f,%.2f) \ n", XC, YC); in         } -     } to      +     return 0; -}
1 /*2 The practice is similar to the previous one, but in various situations, it was written by me, and finally because I did not go to absolute value and WA several times,3 in comparison with the above, it is important to see how good thinking and mathematical literacy is:)4 */5#include <cstdio>6#include <cmath>7#include <algorithm>8#include <iostream>9#include <cstring>Ten using namespacestd; One  A intMainvoid)//A Rescue the Princess - { -     //freopen ("A.txt", "R", stdin); the      -     intT; -      while(SCANF ("%d", &t) = =1) -     { +          while(t--) -         { +             Doublexa, ya, xb, YB, XC, YC, XD, yd; Ascanf ("%LF%LF%LF%LF", &xa, &ya, &AMP;XB, &YB); at             DoubleAB = sqrt ((XA-XB) * (XA-XB) + (YA-YB) * (ya-yb)); -             Doublecd = sqrt (3.0) /2*AB; -xd = (xa + XB)/2; yd = (YA + yb)/2; -             if(ya =YB) -             { -XC = (xa + XB)/2; in                 if(Xa <AB) -                 { toYC = ya +cd; +                 } -                 Else the                 { *YC = Ya-cd;  $                 }Panax Notoginseng             } -             Else if(XA = =XB) the             { +YC = (ya + yb)/2; A                 if(Ya >YB) the                 { +XC = xa +cd; -                 } $                 Else $                 { -XC = XA-cd; -                 } the             } -             ElseWuyi             { the                 DoubleK = (ya-yb)/(XA-XB); -K =-1.0/K; Wu                 DoubleQ =Atan (k); -                 //printf ("%.2f%.2f%.2f%.2f%.2f%.2f\n", AB, CD, XD, yd, K, q); About                 if(k >0) $                 { -                     if(Xa <XB) -                     { -XC = XD + ABS (CD *cos (q)); AYC = yd + ABS (CD *sin (q)); +                     } the                     Else -                     { $XC = Xd-abs (CD *cos (q)); theYC = Yd-abs (CD *sin (q)); the                     } the                 } the                 Else -                 { in                     if(Xa <XB) the                     { theXC = Xd-abs (CD *cos (q)); AboutYC = yd + ABS (CD *sin (q)); the                     } the                     Else the                     { +XC = XD + ABS (CD *cos (q)); -YC = Yd-abs (CD *sin (q)); the                     }Bayi                 } the             } the              -printf ("(%.2f,%.2f) \ n", XC, YC); -         } the     } the      the     return 0; the}

Math A Rescue The Princess

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.