Results 1 to 4 of 4

Thread: C++

Hybrid View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Registered User
    Join Date: Jan:2009
    Location:
    Posts: 16

    C++

    ! C++. :

    Enter a circle and a segment line. Check whether the line lies into the circle.

    . , ?

    , , ...

    Code:
    #include "ccc_win.h"
    #include <cmath>
    int ccc_win_main()
    {
    
    double xc = cwin.get_double("Enter xc: ");
    double yc = cwin.get_double("Enter yc: ");
    double r = cwin.get_double("Enter r: ");
    
    Point p(xc,yc);
    
    cwin << p << Circle(p, r);
    double x1 = cwin.get_double("Enter x1: ");
    double y1 = cwin.get_double("Enter y2: ");
    double x2 = cwin.get_double("Enter x1: ");
    double y2 = cwin.get_double("Enter y2: ");
    Line o (Point(x1, y1), Point(x2,y2));
    cwin << o;
    
    double dist1 = (x1-xc)*(x1-xc) + (y1-yc)*(y1-yc);
    double dist2 = (x2-xc)*(x2-xc) + (y2-yc)*(y2-yc);
    
    if ((r > dist1) and (r > dist2))  
       cwin << Message (p, "Segment line into the circle");
    else
        cwin << Message (p, "Segment line outside the circle");
       
    return 0;
    }
    .

  2. #2
    Defender Kaspirtov's Avatar
    Join Date: Jun:2006
    Location: Sf
    Posts: 7,414
    double dist1 = (x1-xc)*(x1-xc) + (y1-yc)*(y1-yc);
    double dist2 = (x2-xc)*(x2-xc) + (y2-yc)*(y2-yc);
    SQRT, ..

    double dist1 = SQRT[(x1-xc)*(x1-xc) + (y1-yc)*(y1-yc)];
    double dist2 = SQRT[(x2-xc)*(x2-xc) + (y2-yc)*(y2-yc)];
    (=).

    if ((r >= dist1) and (r >= dist2))
    , / .
    " , , , , ."

  3. #3
    Registered User
    Join Date: Jan:2009
    Location:
    Posts: 16
    , , ! : )))

  4. #4
    Registered User
    Join Date: Oct:2003
    Location:
    Posts: 4,317
    , ,

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  

Copyright © 1999-2011 . .
iskamPC.com | mobility.BG | Bloody's Techblog | | 3D Vision Blog |