bounding-box

Given a latitude and longitude, and distance, I want to find a bounding box

天涯浪子 提交于 2019-11-27 18:25:34
问题 Given a latitude and longitude, and distance, I want to find a bounding box where the distances are less than the given distance. This questions was asked here: How to calculate the bounding box for a given lat/lng location? I donot want this partcularly accurate, so I have modified and simplified it to def boundingBox(latitudeInDegrees, longitudeInDegrees, halfSideInKm): lat = math.radians(latitudeInDegrees) lon = math.radians(longitudeInDegrees) halfSide = 1000*halfSideInKm RADIUS_OF_EARTH

How to calculate the height of an NSAttributedString with given width in iOS 6 [duplicate]

∥☆過路亽.° 提交于 2019-11-27 18:05:30
Possible Duplicate: How to get height for NSAttributedString at a fixed width Now NSAttributedString is available in iOS 6. For layout purposes, I want to know how to calculate the required height of an NSAttributedString under fixed width. I'm looking for something that's equivalent to NSString's - (CGSize)sizeWithFont:(UIFont *)font constrainedToSize:(CGSize)size but for NSAttributedString. To calculate the drawing size of NSAttributedStrings, there are two methods available: - (CGSize)size can't be used because it does not take any width into consideration. I tried - (CGRect

Dirty Rectangles

天涯浪子 提交于 2019-11-27 14:52:50
问题 Where may one find references on implementing an algorithm for calculating a "dirty rectangle" for minimizing frame buffer updates? A display model that permits arbitrary edits and computes the minimal set of "bit blit" operations required to update the display. 回答1: To build the smallest rectangle that contains all the areas that need to be repainted: Start with a blank area (perhaps a rectangle set to 0,0,0,0 - something you can detect as 'no update required') For each dirty area added:

Calculate the bounding box's X, Y, Height and Width of a rotated element via JavaScript

浪子不回头ぞ 提交于 2019-11-27 13:57:18
Basically I'm asking this question for JavaScript: Calculate Bounding box coordinates from a rotated rectangle In this case: iX = Width of rotated (blue) HTML element iY = Height of rotated (blue) HTML element bx = Width of Bounding Box (red) by = Height of Bounding Box (red) x = X coord of Bounding Box (red) y = Y coord of Bounding Box (red) iAngle/t = Angle of rotation of HTML element (blue; not shown but used in code below), FYI: It's 37 degrees in this example (not that it matters for the example) How does one calculate the X, Y, Height and Width of a bounding box (all the red numbers)

matplotlib and PyQt: Dynamic figure runs slow after several loads or looks messy

*爱你&永不变心* 提交于 2019-11-27 09:37:00
EDIT: I decided to rewrite this to include a working example of my problem. Although this is pretty long, I hope that it proves to be useful for many in the future. import sys from matplotlib.backends.backend_qt4agg import FigureCanvasQTAgg as FigureCanvas from matplotlib.figure import Figure from PyQt4.QtGui import * from PyQt4.QtCore import * class MainWindow(QMainWindow): def __init__(self): super(MainWindow, self).__init__() self.setGeometry(100, 100, 640, 480) showButton = QPushButton('Show') toolbarShowButton = self.addToolBar('Show button toolbar') toolbarShowButton.addWidget(showButton

How much do two rectangles overlap?

旧街凉风 提交于 2019-11-27 09:36:15
问题 I have two rectangles a and b with their sides parallel to the axes of the coordinate system. I have their co-ordinates as x1,y1,x2,y2. I'm trying to determine, not only do they overlap, but HOW MUCH do they overlap? I'm trying to figure out if they're really the same rectangle give or take a bit of wiggle room. So is their area 95% the same? Any help in calculating the % of overlap? 回答1: Compute the area of the intersection, which is a rectangle too: SI = Max(0, Min(XA2, XB2) - Max(XA1, XB1)

Calculate rotated rectangle size from known bounding box coordinates

冷暖自知 提交于 2019-11-27 06:30:49
I read the Calculate Bounding box coordinates from a rotated rectangle to know how to calculate bounding box coordinates from a rotated rectangle. But in a special case as follow image: How to get the rotated rectangle size if had get the bounding box size, coordinates and rotate degree? I try write code in javascript //assume w=123,h=98,deg=35 and get calculate box size var deg = 35; var bw = 156.9661922099485; var bh = 150.82680201149986; //calculate w and h var xMax = bw / 2; var yMax = bh / 2; var radian = (deg / 180) * Math.PI; var cosine = Math.cos(radian); var sine = Math.sin(radian);

Get dimension of a path in SVG

坚强是说给别人听的谎言 提交于 2019-11-27 02:11:52
问题 I need to get the dimension on the screen of a <path> in a SVG from JavaScript. I do not have any "transformation" or "scaling" (transform, scale) on my SVG. The only thing changed is the viewBox, which will change the size of all the elements in the SVG. I have been using myPath.getBBox(), the width returned stays the same even though I change my viewBox. So I'm wondering what is the relation with this viewBox and size of a path. Maybe there is a function to compute the width? 回答1: You can

Extract all bounding boxes using OpenCV Python

孤者浪人 提交于 2019-11-27 00:49:43
问题 I have an image that contains more than one bounding box. I need to extract everything that has bounding boxes in them. So far, from this site I've gotten this answer: y = img[by:by+bh, bx:bx+bw] cv2.imwrite(string + '.png', y) It works, however, it only gets one. How should I modify the code? I tried putting it in the loop for contours but it still spews out one image instead of multiple ones. Thank you so much in advance. 回答1: there you go: import cv2 im = cv2.imread('c:/data/ph.jpg') gray

Detecting collision of two sprites that can rotate [duplicate]

时光怂恿深爱的人放手 提交于 2019-11-26 16:49:25
This question already has an answer here: How to check intersection between 2 rotated rectangles? 9 answers I have a problem with collision detection in a 2D Java game. Normally, what I would do is create a getBounds() method for an object that can collide with other objects. This method would return a new Rectangle(x,y,width,height) , where x and y are the coordinates for the top-left corner of the sprite, and width and height are the width and height of the sprite. But in the game I'm currently working on, there is a "tank" controlled by the user. The sprite of this tank rotates as long as