geometry

How can I perform Collision Detection on rotated rectangles?

Okay, I'm trying to write a program that could tell me if any points in a 30x100 rectangle rotated to 140 degrees are inside another 30x100 rectangle rotated to 200 degrees. Honestly, I don't even know where to start. I thought about re-rotating them before doing normal calculations, but than they still wouldn't match up. How can I do...

Algorithm to merge adjacent rectangles into polygon

I guess that my problem is related to "convex hull", but no the same. All shapes in the drawing are rectangles with same width and height. Many are adjacent to each other. I want to combine those adjacent rectangles into polygons. Unlike "convex hull", the resuled polygons could be "hollow" inside. Is there any open source algorithm av...

Rotation based on end points.

I'm using pygame to draw a line between two arbitrary points. I also want to append arrows at the end of the lines that face outward in the directions the line is traveling. It's simple enough to stick an arrow image at the end, but I have no clue how the calculate the degrees of rotation to keep the arrows pointing in the right direct...

Error, Implementing Winding Number Algorithm, (OpenGL, C++)

Hi, I am trying to implement the Winding Number Algorithm to test if a point is within another polygon. Although the results from my algorithm are wrong and not consistent. I have been working on this for ages now and it has become a bit of a pain! I have basically converted pseudo code from notes and websites, such as, softsurfer.com...

Splitting an STL vector

Let's say I have a (convex) polygon with vertices 0..n-1. I want to split this polygon in half, say, between verticies i and j. Vertices i and j should appear in both polygons. As far as I can tell, there are only two cases. One where i < j, or when i > j. i is never equal to j (nor are they ever adjacent). I'm storing my vertices lik...

how to determine polygon rotation angle

I am writing a program (.net) to create a stadium style layout and need to determine the angle of rotation for each polygon compared to the horizontal. This is so i can construct the contents of the polygon and also rotate this correctly to fit inside. Given the below image as an example to simulate each variant of the facing direction...

How do I render thick 2D lines as polygons?

I have a path made up of a list of 2D points. I want to turn these into a strip of triangles in order to render a textured line with a specified thickness (and other such things). So essentially the list of 2D points need to become a list of vertices specifying the outline of a polygon that if rendered would render the line. The problem ...

AffineTransform: scaling a Shape from its center.

Hi all, I'm trying to scale a rectangle from its center using AffineTransform. I'm sure the solution is obvious but I cannot make it work ! Here is what I've tested so far... import java.awt.Color; import java.awt.Dimension; import java.awt.Graphics; import java.awt.Graphics2D; import java.awt.Rectangle; import java.awt.geom.AffineTrans...

How to determine whether V3 is between V1 and V2 when we go from V1 to V2 counterclockwise?

I have three vectors V1, V2, and V3. Their origin points are on the axes' origin. How could I determine whether V3 is between V1 and V2 when I move around counterclockwise from V1 to V2? It can't be done with obtaining their angles and evaluating these kind of conditions (pseudo-code): if angle(V3) > angle(V1) && angle(V3) < angle(V2...

How to determine a diagonal is in or out of a concave polygon?

The diagonal (a diagonal is a segment connecting nonadjacent vertices) of a concave (non-convex) polygon can be completely in or out of the polygon(or can intersect with the edges of polygon). How to determine whether it is completely in the polygon?(a method without point-in-polygon test). ...

Decomposition to Convex Polygons

This question is a little involved. I wrote an algorithm for breaking up a simple polygon into convex subpolygons, but now I'm having trouble proving that it's not optimal (i.e. minimal number of convex polygons using Steiner points (added vertices)). My prof is adamant that it can't be done with a greedy algorithm such as this one, but ...

Good books on cartography/GIS programming?

I'm looking for some recommendations on good books that cover cartography and GIS from a programming perspective. I'm not talking about books that concentrate on some concrete GIS technology or GIS product. Ideally the book should cover stuff like map projections coordinate systems image rectification and georeferencing (GeoTIFF, world...

Compute intersection of two edges

I have this big graph of edges and vertices in 2D space. The big graph is returned by a function computed in a C++ library. I am reading this graph and using it to compute all the intersections of its edges (the lines segements). I use sweep algorithm. For detecting the intersection of two edges I have though some problems. I have 4 diff...

Calculate 3d Vector perpendicular to plane described by a Point and True North Heading

I have a Point on the surface of the earth which I am converting to a Vector from Earth Center. I have a True North Heading in degrees describing the path the point will travel on the surface of the earth. I need to calculate a Vector which is perpendicular to the plane created by the path of this point along the earths surface. I hav...

Calculating volumes of hollow three dimensional geometric objects

We've gotten a homework assignment in Java, which relates to inheritance. I don't have a problem with the programming in itself, but I'm a bit unsure about some of the math, and would like confirmation/corrections from someone a bit more knowledgable. The assignment starts with a abstract class, GeometricObject, which is extended into t...

Sweep Algorithm

Who can recommend me a good sweep algorithm which would have good results for double data? Some documentation, methods, anything. This is a sweep algorithm for detecting the intersection points of a graph in the 2-dimensional space. The graph is always closed. ...

Optimal Layout Algorithm

I'm implementing a CSS Sprites setup in my ASP.NET application based on this article.. http://weblogs.asp.net/zowens/archive/2008/03/05/css-sprite-for-asp-net.aspx In the section "Get the SPRITE already!"... the author says... "The only real down side to this is that all your images are lined up vertically. I'm not quite sure that thi...

Line Segment container for fast Ray intersection? (2D)

I have a ray, I need to find the closest line segment that it hits. I think it's possible to do this in O(log n) time if I sort the line segments first, but I can't remember how to sort them... I think some sort of tree would work best, but how do I sort them by both start and end point? I would also like fast insertions into this data s...

Geometrical Arc to Bezier Curve

When drawing an Arc in 2D, using a Bezier Curve approximation, how does one calculate the two control points given that you have a center point of a circle, a start and end angle and a radius? ...

ordering edges for sweeping algorithm

I have the following data structures in my class: typedef vector< vector<int> > MxInt2d; typedef vector< vector<double> > MxDouble2d; class QSweep{ public: .... static MxDouble2d myPoints_; MxDouble2d myEdges_; } where: Each point has 3 components,thus being given by an index, an x, and a y coordinate; Each edge is given by its s...