geometry

Maps: Does calculating distance between 2 points factor in altitude?

Does Postgres' Spatial plugin, or any Spatial package for that manner, factor in the altitude when calculating the distance between 2 points? I know the Spatial packages factor in the approximate curvature of the earth but if one location is at the top of a mountain and the other location is close to the sea - it seems like the calculat...

cp2tform for 3D point sets?

Hi everybody the matlab function cp2tform infers the transformation needed to match two point sets in a 2D space. Refering to my former question (Two sets of 3d points) does anyone know a similar function to infer the transformation for two points sets in 3(n) dimensional space????? Manually it would be an aproach like that http://www....

What lightweight python library for simple scientific visualization in 3D

I am writing a program in python to experiment an academic idea. Look at a resultant image the program generates: The thick skeleton lines in the middle of the leaf is what need to be visualized. Every segment of the skeleton lines has a value associated with it, in the above image (drawn by pycairo), different shades of gray are us...

Drawing irregular concentric circles using Google Maps

I have a bit of a problem. I am trying to do the following using Javascript & the Google Maps API v2: I can draw individual circles just fine using formulas found all over the Internet. The problem I am facing is that the circles must: A. Be concentric, and B. Must have different radius for each "quadrant", i.e., NE, NW, SE & SW I'...

How to get address of point (x, y) in a grid sized (w, h)

By address I mean the location if you were counting left to right, top to bottom, starting with 0 I know how to get the address given point (x, y) in a grid sized (w, h) address = (y * w) + x That is, in a grid 7 x 6 units, the point (2, 5) gives address 37 (see illustration above) How do I get point (x,y), given address 37 and ...

Vector math and rectangles

I know this is more high school math(wow been a long time since I was there) but I am trying to solve this programatically so I am reaching out to the collective knowledge of stackoverflow Given this layout: Midpoint is my reference point and in an array I have the vector points of all other points (P) I can get to this state with c...

How can I find the intersecting point of three planes?

I'm trying to build render the raw data from a Quake 3 .map file with Java. The .map format stores brush (shape) information as a series of planes, but I'd like to convert them to points of the form (x,y,z). The math involved is a bit beyond me at this point, so does anyone have any advice on how I can do this? I'm fine with using ext...

Playing with geometry?

Does anyone have some useful beginner tutorials and code snippets for playing with basic geometric shapes and geometric proofs in code? In particular something with the ability to easily create functions and recursively draw them on the screen. Additional requirements, but not absolute, support for Objective-C and basic window drawing r...

How to calculate the area of multiple overlapping right-angled polygons?

I am looking for a way to calculate the common areas covered by multiple overlapping polygons. The polygons are all right-angled, if that helps makes things easier. So for example: BBBBB BBBBB AAA---BB AAA---BB AAAAAA AA--AA AA--AA LL LL LLLLLL LLLLLL I would like to find the common area covered by A, B and L, which wo...

Expanding a n-vertices polygon with a new data set to a n-vertices polygon

There is a simple polygon P1 with n vertices, n is small, let say 8. This polygon shall represent a perimeter of some set of 2D points. Next, we have another polygon, lets call it P2, also with max number of vertices n. P2 is close to P1, so it makes sense to draw a new polygon, P3, which will describe the area of P1 and P2 together. I...

Covering an arbitrary area with circles of equal radius

How would an algorithm work that achieves this goal? EDIT: For clarification: The radius of the circle and the size and shape of the area are arbitrarily given. The area should be covered with as few circles as possible. The circles may overlap. ...

How do I distribute 5 points evenly onto an irregular shape?

Here is a problem I am trying to solve: I have an irregular shape. How would I go about evenly distributing 5 points on this shape so that the distance between each point is equal to each other? ...

Drawing dashed borders

Imagine you are drawing a map of county borders. You are given a set of polygons, one for each boundary, and you draw each polygon. In places where two counties share a border you just end up drawing the border twice. In the absence of partial transparency effects, and with a solid pen, this is no problem. But, on maps, borders of this...

C++ 2D tessellation library?

I've got some convex polygons stored as an stl vector of points (more or less). I want to tessellate them really quickly. The pieces don't have to be perfectly evenly sized, but they should still be bits and pieces... and preferably no slivers -- I'm just going to use it to explode some objects into little pieces. Does anyone know of a n...

"Persistence" in C#. How to store objects between procedures?

I have GUI that allows an user to create and modify a point object. I need to store a list of these points to insert at a specific drawing. Here's how I came up with it: In the form code, I opened a private property List<Points> and I manipulate it directly inside form code. Is this the correct way to handle? Something like: public p...

Cheap algorithm to find measure of angle between vectors

Finding the angle between two vectors is not hard using the cosine rule. However, because I am programming for a platform with very limited resources, I would like to avoid calculations such as sqrt and arccos. Even simple divide's should be limited as much as possible. Fortunately, I do not need the angle perse, but only need some valu...

Optimizing ActiveRecord Point-in-Polygon Search

Hello stackies. The following PiP search was built for a project that lets users find their NYC governmental districts by address or lat/lng (http://staging.placeanddisplaced.org). It works, but its kinda slow, especially when searching through districts that have complex polygons. Can anyone give me some pointers on optimizing this code...

ImageMagick & Pie Charts

What is the most direct way to draw a pie chart using ImageMagick in an existing image. For example, how would I draw a single slice given the following inputs? A center point (x,y) Radius Percent ...

Joining unordered line segments

My algorithm produces a list of (usually) several thousand line segments (all 2D) which I need to join up into large polylines. These resulting polylines might be closed or open, but they are never self-intersecting. The line segments are not directed, i.e. it might be needed to flip a line segment before it can be joined to its neighbou...

Initializing a polygon in boost::geometry

I am new to the generic geometry library that is proposed for inclusion with boost: http://geometrylibrary.geodan.nl/ I have two vectors vector<int> Xb, Yb that I am trying to create a polygon from. I am trying to get something along the lines of the following code snippet: polygon_2d P; vector<double>::const_iterator xi; vector<...