rectangles

Optimum set of dirty rectangles

被刻印的时光 ゝ 提交于 2019-12-05 01:41:14
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 rectangles that encapsulate all changed pixels. It would be trivial, but undesirable, to compute a single, potentially large, rectangle that encapsulates all changed pixels. We would rather have multiple, smaller, tight-fitting rectangles down to a specified minimum size (that is a variable which can be changed). For example, suppose that within the entire

resizable and movable rectangle

南笙酒味 提交于 2019-12-05 01:06:54
问题 With the following code (thanks to several posts here), I draw a rectangle, that I want to be resizable and movable. Two anchors (the upper left and lower right) do what I want, and the last one (lower middle) moves the rectangle, but the two first anchors do not follow the rectangle. When I make them move, the Listener of them, resizes the rectangle. package application; import javafx.application.Application; import javafx.beans.property.DoubleProperty; import javafx.beans.property

Partition a rectangle into near-squares of given areas

拟墨画扇 提交于 2019-12-04 21:33:47
问题 I have a set of N positive numbers, and a rectangle of dimensions X and Y that I need to partition into N smaller rectangles such that: the surface area of each smaller rectangle is proportional to its corresponding number in the given set all space of big rectangle is occupied and there is no leftover space between smaller rectangles each small rectangle should be shaped as close to square as feasible the execution time should be reasonably small I need directions on this. Do you know of

java.awt.Rectangle. intersection()

房东的猫 提交于 2019-12-04 18:50:29
I was developing an task when I decided to use java.awt.Rectangle to calculate the intersection between two rectangles. I realised that the output is different from what I expected. I'm not sure if I understood how this method works or not. For the values in the example here java.awt.Rectangle[x=0,y=10,width=5,height=8] java.awt.Rectangle[x=3,y=15,width=17,height=14] I expect the intersection to be java.awt.Rectangle[x=3,y=10,width=2,height=8] but the program prints java.awt.Rectangle[x=3,y=15,width=2,height=3] instead! here is my code: public void printIntersection(){ Rectangle r1 = new

Java Partition Surface into Little Squares

谁说我不能喝 提交于 2019-12-04 17:49:46
I would like to know if there is any algorithm that does something like this: Given a specific surface it divides it into smaller rectangles of the same size. Something like this example figure: The grey area is the surface, and the red squares is the partition itself. I am thinking if there is a optimized way to do this. A very bad approach would be a for loop in all the pixels and check if there is a rectangle for that specific spot, if not, would create a rectangle, and so on.. Maybe someone knows a algorithm already done? or a better solution? Thanks alot in advance ;) Paul Samsotha Here's

Calculating vertices of a rotated rectangle

寵の児 提交于 2019-12-04 13:45:47
问题 Hey guys, I am trying to calculate the vertices of a rotated rectangle (2D). It's easy enough if the rectangle has not been rotated, I figured that part out. If the rectangle has been rotated, I thought of two possible ways to calculate the vertices. 1) Figure out how to transform the vertices from local/object/model space (the ones I figured out below) to world space. I honestly have no clue, and if it is the best way then I feel like I would learn a lot from it if I could figure it out... 2

Finding the area of intersection of multiple overlapping rectangles in Python

泄露秘密 提交于 2019-12-04 11:59:22
I tried to using the algorithm shown here: https://discuss.leetcode.com/topic/15733/my-java-solution-sum-of-areas-overlapped-area However, that algorithm only deals with finding the areas of only TWO overlapped rectangles. How would I go on about finding the area of the intersection of say 3, or 4 or 5, etc number of overlapping rectangles, if I know the length, breadth of each rectangle? benten Shapely is a good library for stuff like this. from shapely.geometry import box # make some rectangles (for demonstration purposes and intersect with each other) rect1 = box(0,0,5,2) rect2 = box(0.5,0

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

左心房为你撑大大i 提交于 2019-12-04 10:19:56
问题 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: white; } .boundary:before { content: ''; position: absolute; top: 0; left: 0; width: 100%; height: 100%; transform-origin: top left; transform: rotate(3deg); background-color: green; } .inner { height: 100%; width: 100%; background-color: green; } <div class="boundary"></div>

Difference (XOR) between two rectangles, as rectangles?

主宰稳场 提交于 2019-12-04 05:25:34
I'm looking for a simple way to calculate the difference between two rectangles. I mean all points which belong to one of the rectangles, but not to both (so it's like XOR). The rectangles are axis-aligned in this case, so there will be only right angles. I believe the difference region can be expressed in 0-4 rectangles (0 if both rectangles are the same, 1 if just one edge is different, 4 in the general case), and I'd like to get the difference region as a list of rectangles. You can also think of it as the areas of the screen that have to be updated when a solid rectangle is moved/resized.

Tile (scalable) stacking algorithm

倾然丶 夕夏残阳落幕 提交于 2019-12-04 03:41:10
Here is the problem. I have rectangular canvas that have size of 1. So it have coordinate sistem of (0.0 ... 1.0 - x and 0.0 ... 1.0 - y). I also have some tiles. Tiles are also rectangles. They have diffrent size and amount of tiles is a variable. I want to stack tiles in rectangular canvas, from 0.0 to 1.0 ( from left to right, from top to bottom ): 1) tiles have to fit in canvas (but fill as much space as they could) 2) tiles have to be scaled (if they don't fit), each tile should be scaled by the same amount (they have to remain same proportions). 3) imagine that you have this 'tiles' in