Questions tagged [rectangles]

A rectangle is a geometric shape: any quadrilateral with four right angles

1373 questions
20
votes
2 answers

Check if two areas are in contact

Possible Duplicate: Finding the overlapping area of two rectangles (in C#) I have two areas identified by top left and bottom right corners (fig.1). In c#, how can I test if they are in contact (fig.2)?
A.Baudouin
  • 2,855
  • 3
  • 24
  • 28
19
votes
2 answers

What is the best way to convert from a RectF to a Rect in Android?

I would like to convert from a RectF to a Rect in Android. Currently I have: RectF rectF = new RectF(); rectF.set( ... some values ... ); ... Rect rect = new Rect((int)rectF.left, (int)rectF.top, …
superdave
  • 1,928
  • 1
  • 17
  • 35
17
votes
5 answers

How to divide a set of overlapping ranges into non-overlapping ranges?

Let's say you have a set of ranges: 0 - 100: 'a' 0 - 75: 'b' 95 - 150: 'c' 120 - 130: 'd' Obviously, these ranges overlap at certain points. How would you dissect these ranges to produce a list of non-overlapping ranges, while retaining…
Ron Eggbertson
  • 225
  • 2
  • 6
16
votes
2 answers

SVG Rectangle display HTML title on mouseover

I try to display a tooltip on mouse hover a rectangle. My attempt were using and set a title to it and set a title to the itself but does not produce any visible output (on Chrome). HTML
Anwar
  • 4,162
  • 4
  • 41
  • 62
15
votes
1 answer

how to add a transparent rectangle to a R boxplot (plot)?

I have a simple boxplot for my data using R .. boxplot (Error~Code, DataFrame1, xlim = c(0, 27), xlab="set Code",ylab="Error", boxwex=0.75, cex.axis=0.3) and I would like to draw a transparent rectangle all over the plot between 2 defined…
Leo...
  • 321
  • 2
  • 4
  • 14
15
votes
3 answers

What's a good, simple, 2D rectangles-only collision detection algorithm?

I'm designing a collision detection game tutorial for young adults, so I want this to be as simple as possible to make it easier to explain. The requirements are very simple. The world is 2D and contains only rectangles (of arbitrary sizes). BSP and…
Alvin Smith
  • 151
  • 1
  • 4
15
votes
4 answers

Algorithm for best fit rectangle

I'm looking for an algorithm to do a best fit of an arbitrary rectangle to an unordered set of points. Specifically, I'm looking for a rectangle where the sum of the distances of the points to any one of the rectangle edges is minimised. I've…
SmacL
  • 22,555
  • 12
  • 95
  • 149
14
votes
4 answers

Why there is a gap between div and rotated div (triangle)

I am trying to do this shape in HTML/CSS for my mobile app: https://embed.plnkr.co/9k8jbJyzUiSMSoSHlOti/ .boundary { width: 100.13723%; padding-bottom: 5.24078%; position: relative; overflow: hidden; background-color:…
sophie
  • 166
  • 3
14
votes
2 answers

How to draw a rectangle inside a rectangle using svg?

I am trying to draw a rectangle inside a rectangle using svg, but I am not seeing the inner rectangle. Could somebody help me what is the mistake I am doing ?? The code is as below.

My first SVG

sakthisundar
  • 3,278
  • 3
  • 16
  • 29
14
votes
2 answers

Convert Rect to RectF

Whats the best way to convert a Rect variable to a RectF one? I am unable to cast it. RectF rect = (RectF) currentRect; //produces an error
industrychanger
  • 563
  • 1
  • 9
  • 21
14
votes
4 answers

How to draw a rounded rectangle (rectangle with rounded corners) with OpenCV?

How can I draw a rectangle with rounded corners in OpenCV? I know that the functions ellipse() and line() can be simply put together to draw it. I just wonder if someone has done it before and has put it in a proper function so I can use it? Ideally…
Kenyakorn Ketsombut
  • 2,072
  • 2
  • 26
  • 43
14
votes
3 answers

Is there a circle class in Java like the Rectangle class

Hey I was writing a quick program and something came across where I need to use a circle for collision detection. But as far as I know, there is only the Rectangle class that has the .intersects(Point p) method. Is there anything like a circle that…
user1871085
  • 159
  • 1
  • 1
  • 9
13
votes
9 answers

Rotating a rectangle (not image) in pygame

In pygame I use pygame.draw.rect(screen, color, rectangle) for all the rectangles in my program. I want to be able to rotate these rectangles to any angle. I have seen the following code to rotate IMAGES but my question is with RECTANGLES.…
Keatinge
  • 4,330
  • 6
  • 25
  • 44
13
votes
2 answers

Finding the overlapping area of two rectangles (in C#)

Edit: Simple code I used to solve the problem in case anyone is interested (thanks to Fredrik): int windowOverlap(Rectangle rect1, Rectangle rect2) { if (rect1.IntersectsWith(rect2)) { Rectangle overlap =…
Evan
  • 4,450
  • 10
  • 40
  • 58
12
votes
3 answers

Optimum set of dirty rectangles

I'm looking for an algorithm here, independent of specific programming language. The problem: We have a 2-dimensional display area (think simple buffer of pixels). Periodically, some of the pixels are changed. We need to find a set of …
Clay Fowler
  • 2,059
  • 13
  • 15
1
2
3
91 92