Wrox Programmer Forums
Go Back   Wrox Programmer Forums > C# and C > C++ and Visual C++ > C++ Programming
|
C++ Programming General discussions for the C++ language. For questions specific to Microsoft's Visual C++ variant, see the Visual C++ forum instead.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the C++ Programming section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
  #1 (permalink)  
Old August 20th, 2004, 02:30 AM
Authorized User
 
Join Date: Aug 2004
Posts: 13
Thanks: 0
Thanked 0 Times in 0 Posts
Default how to compare if two rectangle redundant

hello:
  Is there anyone can help me that problem:
    I have two rectangles in the same plane with coodinate x,y(no 3 coodinate concerned),both rects have their posx,y(in reference to original point of coodinate x,y),length, width, and angle(smaller than 360 degree) between the border of length and coodinate X or its parallel line
  like this:
     bool IsTwoRectRedundant(float x1,
                             float y1,
                             float length1,
                             float width1,
                             float angle1,
                             float x2,
                             float y2,
                             float length2,
                             float width2,
                             float angle2)
anybody can help me solve that problem or offer me useful and well notated links


Reply With Quote
  #2 (permalink)  
Old August 20th, 2004, 09:24 AM
Authorized User
 
Join Date: Feb 2004
Posts: 76
Thanks: 0
Thanked 0 Times in 0 Posts
Default

This is a programming forum, and you have furnished a function header for a function to perform a specific task.

Before you write the program, you must understand the task. If you didn't have access to a computer, how would you solve the problem?

Can you state the problem a little more completely: what do you mean by "redundant"? Do you mean that the rectangles have exactly the same size and shape? Do you mean that the rectangles have the same size and shape and position?

Now, how would you solve the problem on pencil and paper? Maybe you can calculate the coordinates of the four corners of each rectangle and compare. Maybe something else.

Now, try some code (for example compare x1 with y1 and x2 with y2). There are lots of ways to approach the problem. I personally don't think that the first thing is to start writing code.

If you have an approach to the problem and have trouble understanding how to program it in C or C++, or can't understand compiler error messages, or if you run the program and see unexpected results, give us some more information; maybe someone can help.

Good Luck!

Dave
Reply With Quote
  #3 (permalink)  
Old August 20th, 2004, 10:30 AM
Authorized User
 
Join Date: Aug 2004
Posts: 13
Thanks: 0
Thanked 0 Times in 0 Posts
Default

redundance here means the two rectangle have a fraction of plain(not a point, or a line)
the starting point, length and width and angle between the width line and the horizontal coordinate can be flexible,
in other word: any rectangle or any size at any point in any angle

thank you

Reply With Quote
  #4 (permalink)  
Old August 20th, 2004, 12:33 PM
Authorized User
 
Join Date: Feb 2004
Posts: 76
Thanks: 0
Thanked 0 Times in 0 Posts
Default

I'm still not sure what you mean. If they can have different starting points, different lengths, widths and angles, the only thing to check is to see if they have the same area. Is that what you mean?

So test to see if (length1 * width1 == length2 * width2). If that's not what you mean, give me a clue!

Tell me (in words, not with a program) how you are going to perform the test. Then tell me if you need help starting a program. I assume that you have written programs previously.

Dave
Reply With Quote
  #5 (permalink)  
Old August 20th, 2004, 07:36 PM
Authorized User
 
Join Date: Aug 2004
Posts: 13
Thanks: 0
Thanked 0 Times in 0 Posts
Default

all right,
 I mean to see if they intersect each other(the intersection of only a point or a borderline are the exceptions)

Reply With Quote
  #6 (permalink)  
Old August 21st, 2004, 09:00 AM
Authorized User
 
Join Date: Feb 2004
Posts: 76
Thanks: 0
Thanked 0 Times in 0 Posts
Default

I hate to repeat myself, but:


Tell me (in words, not with a program) how you are going to perform the test.


If you have specific requests for programming assistance, I will try to help.

Dave
Reply With Quote
  #7 (permalink)  
Old August 21st, 2004, 12:20 PM
Authorized User
 
Join Date: Feb 2004
Posts: 76
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Well, your title for the thread is how to compare if two rectangle redundant.

My understanding of the term is that "a rectangle is redundant if it is completely enclosed in another rectangle".

The condition that you have described is intersection, not redundancy.

I suggest you use a search engine (google or something) for terms "redundant rectangles" or "intersecting rectangles" and see if you get any information. These topics are typically covered in University courses with titles something like "Descriptive Geometry" or "Computational Geometry".

I really believe that doing your own web search is likely to be more productive for you than requesting help on a forum like this and waiting for a helpful response.

Good Luck,

Dave
Reply With Quote
  #8 (permalink)  
Old August 22nd, 2004, 12:43 AM
Friend of Wrox
 
Join Date: Jul 2004
Posts: 623
Thanks: 0
Thanked 1 Time in 1 Post
Default

David
i.e you can work with their area,I maen
if rectangle(1+2)<<rectangle1+rectangle2 thath means there is redundant rectangles
rectangle(1+2) is the shape that forms because of redundant rectangles
now I dont know how you could implement it,I think you can work with colors
also there could be other ways but this I told could be the simplest one.
Hth.

--------------------------------------------
Mehdi.:)
Reply With Quote
  #9 (permalink)  
Old August 22nd, 2004, 12:54 AM
Friend of Wrox
 
Join Date: Jul 2004
Posts: 623
Thanks: 0
Thanked 1 Time in 1 Post
Default

in the above method you can also get the intersection area easily...


--------------------------------------------
Mehdi.:)
Reply With Quote
  #10 (permalink)  
Old August 22nd, 2004, 12:55 AM
Friend of Wrox
 
Join Date: Jul 2004
Posts: 623
Thanks: 0
Thanked 1 Time in 1 Post
Default

way 2,
you know tow rectangles can intersect each other if and only if there is two borderlines thath intersect each other so you should check 4*4=16 times it that means you should check every borderline in rectangle one with all the borderlines in rectangle 2 for intersections,I think you can write a simple function that take two lines and determine if they intersect each other then use this function 16 times in your program for implementing this I told you.
Hth.

--------------------------------------------
Mehdi.:)
Reply With Quote





Similar Threads
Thread Thread Starter Forum Replies Last Post
Entirely redundant function? RoryBecker BOOK: Professional ASP.NET 3.5 : in C# and VB ISBN: 978-0-470-18757-9 0 May 30th, 2008 05:16 AM
redundant SQL logic fkish SQL Language 3 November 12th, 2007 01:28 PM
compare these date fields and compare and get the susanring Oracle 1 July 24th, 2006 04:58 PM
Eliminating Redundant Records spraveens MySQL 1 May 12th, 2004 04:21 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.