geometry

Determine the centroid of multiple points

Hello, I'm writing a mapping application that I am writing in python and I need to get the lat/lon centroid of N points. Say I have two locations a.lat = 101 a.lon = 230 b.lat = 146 b.lon = 200 Getting the center of two points is fairly easy using a euclidean formula. I would like to be able to do it for more then two points. Fund...

Align point clouds via 3 points correlation?

Let's say I have 3 point clouds: first that has 3 points {x1,y1,z1}, {x2,y2,z2}, {x3,y3,z3} and second point cloud that has same points as {xx1, yy1, zz1}, {xx2,yy2,zz2}, {xx3,yy3,zz3}... I assume to align second point cloud to first I have to multiply second one's points by T[3x3matrix]. 1) So how do I find this transform matrix(T) ? ...

Hole in a Polygon

I need to create a 3D model of a cube with a circular hole punched at the center of one face passing completely through the cube to the opposite side. I am able to generate the vertices for the faces and for the holes. Four of the faces (untouched by the hole) can be modeled as a single triangle strip. The inside of the hole can also be...

calculate distance between 2 gps coordinates

How do I calculate distance between two gps coordinates (lang,long) ...

Geometry column: STGeomFromText and SRID (what is an SRID?)

I'm playing with the new geography column in SQL Server 2008 and the STGeomFromText function. Here is my code (works with AdventureWorks2008) DECLARE @region geography; set @region = geography::STGeomFromText('POLYGON(( -80.0 50.0, -90.0 50.0, -90.0 25.0, -80.0 25.0, -80.0 50.0))', 4326); SELECT @region; My question is...

How can I form polygons from lines

I have a bunch of 2-dimensional lines, whose start and end points are known. The lines might occasionally cross each other, or one line might end in the middle of another line. I need to form polygons from this mesh of lines. If necessary, I can ensure that the left side of all lines are inside their polygons. ...

Lat/Lon + Distance + Heading --> Lat/Lon

Hello... So: I have the following function, adapted from a formula found online, which takes two lat/lon coordinates and finds the distance between them in miles (along a spherical Earth): public static double distance (double lat1, double lon1, double lat2, double lon2) { double theta = toRadians(lon1-lon2); lat1 = toRadians...

Intersection of two lines defined in (rho/theta ) parameterization

Have created a c++ implementation of the Hough transform for detecting lines in images. Found lines are represented using rho, theta, as described on wikipedia: "The parameter r represents the distance between the line and the origin, while θ is the angle of the vector from the origin to this closest point " How can i find the inte...

Boolean operations on rectangle polygons.

Avast there fellow programmers! I have the following problem: I have two rectangles overlapping like shown on the picture below. I want to figure out the polygon consisting of point ABCDEF. Alternate christmas description: The red cookie cutter is cutting away a bit of the black cookie. I want to calculate the black cookie. Each r...

Determining if a lat-long rect and a circle on a sphere overlap

Suppose I have the following: A region defined by minimum and maximum latitude and longitude (commonly a 'lat-long rect', though it's not actually rectangular except in certain projections). A circle, defined by a center lat/long and a radius How can I determine: Whether the two shapes overlap? Whether the circle is entirely contai...

Connected points with-in a grid

Given a collection of random points within a grid, how do you check efficiently that they are all lie within a fixed range of other points. ie: Pick any one random point you can then navigate to any other point in the grid. To clarify further: If you have a 1000 x 1000 grid and randomly placed 100 points in it how can you prove that any...

Circle-Rectangle collision detection (intersection)

How can I tell whether a circle and a rectangle intersect in 2D Euclidean space? (i.e. classic 2D geometry) ...

Polygon Triangulation with Holes

I am looking for an algorithm or library (better) to break down a polygon into triangles. I will be using these triangles in a Direct3D application. What are the best available options? Here is what I have found so far: Ben Discoe's notes FIST: Fast Industrial-Strength Triangulation of Polygons I know that CGAL provides triangulation ...

Finding clusters of mass in a matrix/bitmap

This is in continuation with the question posted here: http://stackoverflow.com/questions/408358/finding-the-center-of-mass-on-a-2d-bitmap which talked about finding the center of mass in a boolean matrix, as the example was given. Suppose now we expand the matrix to this form: 0 1 2 3 4 5 6 7 8 9 1 . X X . . . . . . 2 . X X X . . X . ...

Does the .NET framework provide any built in classes for performing geometric calculations?

What does the .NET framework provide, if anything, in the way of classes for performing geometric calculations? For example, calculating the distance between two points (represented as (x,y)) or solving a right triangle's unknown sides or internal angles? (I know that both of those are pretty easily solved; I'm just using those as exampl...

How best to perform corridor range search over a set of latitude / longitude coordinates

Hi, What would be the best approach to finding the set of coordinates, from say about 5,00, which lie within a path of points, given a specified width. eg an aircraft following several waypoints. Is there a good way to also sort them in the same order as the route. Calculation speed would be more important than accuracy, since I'm l...

Fast Method to Intersect two Integer Quadratic Beziers?

Given two Quadratic Beziers in 2D with integer coordinates, what is the best way to find their intersection point(s)? Also interesting is an early rejection if they do not intersect. If it makes it easier, they can both be assumed to be monotone in both x and y. Only intersections that are representable by subdivision to integers of the ...

How do I calculate the surface area of a 2d polygon?

Assuming a series of points in 2d space that do not self-intersect, what is an efficient method of determining the surface area of the resulting polygon? As a side note, this is not homework and I am not looking for code. I am looking for a description I can use to implement my own method. I have my ideas about pulling a sequence of t...

Which algorithm can efficiently find a set of points within a certain distance of a path?

Given a set of points s (a set of x,y coordinates) and a path that is made up of line segments joining a set of points l, describe an efficient algorithm that can be used to find a subset of points from s that are within the specified distance d of the path l. A practical application of this may be to find a list of restaurants within 1...

Best Tools for 2D Constructive Area Geometry

What are the best tools/libraries (in any language) for working with 2D constructive area geometry? That is, a library working with more or less arbitrary two dimensional shapes and supplying union, intersection, difference and XOR. My baseline is the java.awt.geom.Area class, and that's serviceable if slow. What's out there that's ...