How do I use rectint to find the area of two intersecting rectangles?
Show older comments
I am trying to find the area of two intersecting rectangles. The rectint function in the help file does not help demonstrate proper usage of the command.
I don't know the correct way to define the rectangles or use the command. I am also rotating one rectangle relative to the other, and the area is going to change. Both rectangles have the same center. I know the area should be at a max when the rectangles overlap and be at a min when the rectangles are at a right angles to each other. I can rotate the rectangles, but the area is not what I expect. What are the sins I have commited,and how to I atone for them? Some examples would be helpful.
A second challenge is to plot the the rectangles and the resulting area, but one problem at a time.
3 Comments
John D'Errico
on 9 Feb 2011
How can we possibly know what you have done wrong, if we cannot see what you have done? Yes, we could do your homework completely for you, but how will that really help you?
Brian
on 11 Feb 2011
Brian
on 11 Feb 2011
Answers (4)
Rafael
on 9 Feb 2011
0 votes
maybe you get a first idea by looking at this:
http://csc.fsksm.utm.my/syed/projects/image-processing.html
Walter Roberson
on 9 Feb 2011
0 votes
The documentation you referred to does say clearly that a position vector is [x y w h] where x and y are the starting coordinates and w and h are the width and height.
Therefore for the purpose of this command, the rectangles must align with the x/y axes.
Bruno Luong
on 10 Feb 2011
0 votes
There is a set of polygon boolean operators in Mapping Toolbox. I can't find the official doc but the below link you an idea what you can do.
If you don't own the toolbox, there is a tool on FEX (haven't tried my self)
I have codded a Matlab based, if the above won't work, I probably could try to provide you part of my code.
Evan
on 12 Jan 2012
0 votes
Surprisingly, the help file is rather terse. Testing it out on a simple example, the x and y corner coordinates of the position vector need to be the lower right corner of the rectangle.
1 Comment
Walter Roberson
on 12 Jan 2012
The help file for which routine, Evan?
Categories
Find more on MATLAB in Help Center and File Exchange
Products
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!