Programming C, C++, Java, PHP, Ruby, Turing, VB
Computer Science Canada 
Programming C, C++, Java, PHP, Ruby, Turing, VB  

Username:   Password: 
 RegisterRegister   
 Need help writing a program!!!!!
Index -> Programming, C++ -> C++ Help
View previous topic Printable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic
Author Message
silvervulcan




PostPosted: 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 Crying or Very sad
Sponsor
Sponsor
Sponsor
sponsor
AsianSensation




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

check distance between centers.
btw, work with radius instead of diameter

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




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

how do I find the distance between there centres?
Catalyst




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

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




PostPosted: 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




PostPosted: 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




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

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




PostPosted: 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




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

thats cuz in if statments, you use ==
Latest from compsci.ca/blog: Tony's programming blog. DWITE - a programming contest.
Display posts from previous:   
   Index -> Programming, C++ -> C++ Help
View previous topic Tell A FriendPrintable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic

Page 1 of 1  [ 9 Posts ]
Jump to:   


Style:  
Search: