Computer Science Canada Programming C, C++, Java, PHP, Ruby, Turing, VB   Username:   Password: Wiki   Blog   Search   Turing   Chat Room  Members
Need help writing a program!!!!!
Author Message
silvervulcan

Posted: Sat Sep 27, 2003 4:46 pm   Post subject: Need help writing a program!!!!!

Hey, can anyone help me out with this question:

Assume 2 circles located in an x-y coordinate space. Te first circle is centered at (x1,y1) and has diameter D1. THe second circle is centered at (x2,y2) and has diameter D2. There are 4 possible arrangements. Either

1. the circles do not touch each other at all OR
2.the circles touch but do not overlap OR
3. one of the circles completly overlaps the other OR
4. the circles partially overlap but neither completly overlaps the other

Write a program that read in the dic info (x1,y1,D1,x2,y2,D2) and outputs a message indicating which of the four cases applies. The program should also loop.

If entered diameters are zero,zero... program should end
but if the diameter is less than or equal to zero, an error message should come up.

Someone plzzzzz help me, I dont know where to start

AsianSensation

Posted: Sat Sep 27, 2003 5:17 pm   Post subject: (No subject)

check distance between centers.

if distance is > r1 + r2, then they don't touch

if distance is = r1 + r2, then they are tangent

if distance is < r1 + r2, then they overlap partially

if distance is < the larger of the radius, or distance = 0, then they overlap completely.

what grade do you go to? have you learned circles and their graph yet?
silvervulcan

Posted: Sat Sep 27, 2003 10:08 pm   Post subject: (No subject)

how do I find the distance between there centres?
Catalyst

Posted: Sat Sep 27, 2003 10:38 pm   Post subject: (No subject)

distance=sqrt ( (x2-x1)*(x2-x1)+(y2-y1)*(y2-y1))
silvervulcan

Posted: Sat Sep 27, 2003 10:54 pm   Post subject: (No subject)

okay say i have a line with conditions on it, but if none of those conditions are satisfied, I want it to go to the next set of conditons, test those, and if any of those are true then output a message

// Check for accepted values
if ((x1,y1 != x2,y2) && (d1 == d2) ) {

cout << " The circles do not touch at all \n"

if ((x1=x2) && (y1,y2 >0) && (y1,y2 != x1,x2) && (d1=d2))

cout << " The circles touch, but do not overlap \n";

if (( x1=x2) && (y1=y2) && (d1,d2 > 0))

cout << " One of the circles completly overlap the other \n";

if (((x1,y1 != x2,y2) && (d1,d2 > 0)) || (( x1,y1 < 0) && (x2, y2 > 0) && (d1,d2 >0 )))

cout << " There is a partial overlap between the circles \n";

}
naoki

Posted: Mon Sep 29, 2003 4:52 pm   Post subject: (No subject)

haha, this is the best place to ask that question, since nearly everyone posting in this portion of the forum spent half of last year debating collision detection.

circle > square detection
Catalyst

Posted: Mon Sep 29, 2003 5:02 pm   Post subject: (No subject)

if ur in c++ and 2d per-pixel is the best option
gigaman

Posted: Thu Dec 11, 2003 6:23 pm   Post subject: (No subject)

I'm learnin MBs and an error message is if easy

if _______=true

MessageBox(NULL,"Fill in message here","Error",MB_OK")
Tony

Posted: Thu Dec 11, 2003 8:26 pm   Post subject: (No subject)

thats cuz in if statments, you use ==
Tony's programming blog. DWITE - a programming contest.
 Display posts from previous: All Posts1 Day7 Days2 Weeks1 Month3 Months6 Months1 Year Oldest FirstNewest First

Page 1 of 1  [ 9 Posts ]
 Jump to:  Select a forum  CompSci.ca ------------ - Network News - General Discussion     General Forums   -----------------   - Hello World   - Featured Poll   - Contests     Contest Forums   -----------------   - DWITE   - [FP] Contest 2006/2008   - [FP] 2005/2006 Archive   - [FP] 2004/2005 Archive   - Off Topic     Lounges   ---------   - User Lounge   - VIP Lounge     Programming -------------- - General Programming     General Programming Forums   --------------------------------   - Functional Programming   - Logical Programming   - C     C   --   - C Help   - C Tutorials   - C Submissions   - C++     C++   ----   - C++ Help   - C++ Tutorials   - C++ Submissions   - Java     Java   -----   - Java Help   - Java Tutorials   - Java Submissions   - Ruby     Ruby   -----   - Ruby Help   - Ruby Tutorials   - Ruby Submissions   - Turing     Turing   --------   - Turing Help   - Turing Tutorials   - Turing Submissions   - PHP     PHP   ----   - PHP Help   - PHP Tutorials   - PHP Submissions   - Python     Python   --------   - Python Help   - Python Tutorials   - Python Submissions   - Visual Basic and Other Basics     VB   ---   - Visual Basic Help   - Visual Basic Tutorials   - Visual Basic Submissions     Education ----------- - Student Life   Graphics and Design ----------------------- - Web Design     Web Design Forums   ---------------------   - (X)HTML Help   - (X)HTML Tutorials   - Flash MX Help   - Flash MX Tutorials   - Graphics     Graphics Forums   ------------------   - Photoshop Tutorials   - The Showroom   - 2D Graphics   - 3D Graphics     Teams ------ - dTeam Public

 Style: Appalachia blueSilver eMJay subAppalachia subBlue subCanvas subEmjay subGrey subSilver subVereor Search: