zoukankan      html  css  js  c++  java
  • H

     1 #include <cstdio>
     2 #include <cstdlib>
     3 #include <cstring>
     4 #include <cmath>
     5 #include <iostream>
     6 using namespace std;
     7 
     8 #define eps 1e-8
     9 #define pie 3.14159265
    10 
    11 struct point
    12 {
    13     double x, y;
    14 }p, s, O;
    15 double vp, vs, r, dis, alpha;
    16 
    17 double square( double x ) {
    18     return x * x;
    19 }
    20 
    21 double Dist( point p1, point p2 ) {
    22     return sqrt( square( p1.x - p2.x ) + square( p1.y - p2.y ) );
    23 }
    24 
    25 point rotate( double T ) {
    26     double theta = T * vp / dis;
    27     theta += alpha;
    28     point newp;
    29     newp.x = cos( theta ) * dis;
    30     newp.y = sin( theta ) * dis;
    31     return newp;
    32 }
    33 
    34 int main()
    35 {
    36 //
    37 //    freopen("haha.txt", "r", stdin);
    38 //    freopen("out.txt", "w", stdout);
    39 
    40     double L, R, mid, d1, d2, cxc, T, theta1, theta2, theta3, dc, ans;
    41 
    42     while(scanf("%lf%lf%lf", &s.x, &s.y, &vs) == 3) {
    43         
    44         scanf("%lf%lf%lf%lf", &p.x, &p.y, &vp, &r);
    45 
    46 
    47         O.x = 0.0; O.y = 0.0;
    48         dis = Dist( O, p );
    49         alpha = atan2( p.y, p.x );
    50 
    51         L = 0.0; R = 100000.0; ans = R;
    52         while( ( R - L ) > eps ) {
    53             mid = ( L + R ) / 2;
    54             point newp = rotate( mid );
    55 
    56             d1 = Dist( s, O );
    57             theta1 = acos( r / d1 );
    58 
    59             d2 = Dist( newp, O );
    60             theta2 = acos( r / d2 );
    61 
    62             dc = newp.x * s.x + newp.y * s.y;
    63             theta3 = acos( dc / ( d1 * d2 ) );
    64 
    65             if( theta1 + theta2 > theta3 ) {
    66                 d1 = Dist( s, newp );
    67                 T = d1 / vs;
    68             }
    69             else {
    70                 T = 0.0;
    71                 cxc = sqrt( d1 * d1 - r * r );
    72                 T += cxc / vs;
    73                 cxc = sqrt( d2 * d2 - r * r );
    74                 T += cxc / vs;
    75                 theta3 = theta3 - theta1 - theta2;
    76                 T += r * theta3 / vs;
    77             }
    78 
    79             if( ( mid - T ) >= eps ) {
    80                 R = mid - eps;
    81                 ans = min( ans, mid );
    82             }
    83             else L = mid + eps;
    84         }
    85         printf("%.2lf ", ans );
    86 
    87     }
    88     return 0;
    89 }
    View Code
  • 相关阅读:
    【转】【Linux】linux awk命令详解
    【转】【Linux】Linux 命令行快捷键
    【转】【Linux】sed命令详解
    【转】【Linux】Linux 下zip包的压缩与解压
    【转】【Linux】grep命令详解
    【转】crontab命令 脚本定时运行
    【转】BAT 批处理脚本 教程
    【MySql】脚本备份数据库
    php的json校验json-schema
    phan—php语法静态检查在windows下的配置
  • 原文地址:https://www.cnblogs.com/acvc/p/4419859.html
Copyright © 2011-2022 走看看