geometry

[WPF] What is the best way to draw text along with geometry?

In WPF, I'm starting to use classes such as LineGeometry, EllipseGeometry, GeometryGroup, Path... in order to draw 2D graphics. I chose these over shapes because I saw it could be faster thanks to the freezing feature. I need to draw text along with geometry, with specific fonts. The text needs to be positionnable with the same coordina...

Find the corners of a deformed rectangle

I am trying to make a program that automatically corrects the perspective of a rectangle. I have managed to get the silhouette of the rectangle, and have the code to correct the perspective, but I can't find the corners. The biggest problem is that, because it has been deformed, I can't use the following "code": c1 = min(x), min(y) ...

A reverse of Haversine formula for MySQL?

In my DB i store a center point, along with a radius (in meters). I'm looking to pass in a lat/lng, and then have the mysql values i've stored create a circle to tell me if my point i passed in is within that circle. Is there something that would allow me to do this, similar to the haversine forumla (which would assume that my point w...

How many integer points within the three points forming a triangle?

Actually this is a classic problem as SO user Victor put it (in another SO question regarding which tasks to ask during an interview). I couldn't do it in an hour (sigh) so what is the algorithm that calculates the number of integer points within a triangle? EDIT: Assume that the vertices are at integer coordinates. (otherwise it beco...

Find medial axis of a polygon using C#

I've been tasked to figure out how to find the centerline of a polygon. My google searches led me to believe that what I need is called the 'Medial Axis'. Like this: According to what I've read, what I need can be produced by using a 2D Voronoi diagram construction algorithm for segments. I've found a C# version of the Voronoi algo...

Drawing the slices of a 3D pie chart in the right order

I'm trying to fix up an old application: I have a function that takes a pair of angles and draws a 3d slice of an exploded pie chart. I also have functions that take a collection of numbers, generate the angles and call the slice drawing function repeatedly until the entire pie is drawn. Repeated calls to the slice drawing function draw...

Good geometry library in python?

I am looking for a good and well developed library for geometrical manipulations and evaluations in python, like: evaluate the intersection between two lines in 2D and 3D (if present) evaluate the point of intersection between a plane and a line, or the line of intersection between two planes evaluate the minimum distance between a lin...

What is the name of this problem?

You are given a list of distances between various points on a single line. For example: 100 between a and b 20 between c and b 90 between c and d 170 between a and d Return the sorted sequence of points as they appear on the line with distances between them: For example the above input yields: a<----80-----> c <----20------> b <-...

Horizontally flip an Area in Java

I have a concave polygon stored as an Area. How would I flip/invert/mirror the polygon about the y-axis? ...

Finding the coordinates of tiles that are covered by a rectangle with x,y,w,h pixel coordinates

Say I have a tile based system using 16x16 pixels. How would you find out what tiles are covered by a rectangle defined by floating point pixel units? for eg, rect(x=16.0,y=16.0, w=1.0, h=1.0) -> tile(x=1, y=1, w=1, h=1) rect(x=16.0,y=16.0, w=16.0, h=16.0) -> tile(x=1, y=1, w=1, h=1) (still within same tile) rect(x=24.0,y=24.0, w=8....

Taking altitude into account when calculating geodesic distance

hi there, i´m currently dealing with gps data combined with precise altitude measurement. I want to calculate the distance between two consecuting points. There is a lot of information out there about calculating distance between two points using the WGS84 ellipsoid and so on. however, i did not find any information that takes Altitud...

An algorithm for inflating/deflating (offsetting, buffering) polygons

UPDATE: the math term for what I'm looking for is actually inward/outward polygon offseting. +1 to balint for pointing this out. The alternative naming is polygon buffering. Before I start developing my own solution from scratch, does anyone know of any good source for an algorithm that can inflate a polygon, something similar to this: ...

Is there a simple "point in rect" algorithm for a wraparound map?

I'm trying to build a rectangular grid that can wrap around at the edges. Anyone who plays video games will probably be familiar with the concept: go far enough in one direction on the world map and you'll end up back where you started. This causes some difficulty in setting up the viewport, though, since the edges can scroll into nega...

Collision detection of triangles in 3D with some movement

I'm looking for a pretty easy algorithm for a collision detection with two three-dimensional triangles, which can move constantly (rather better if the could accelerate, too). I've found a method to solve this problem but that's a difficult one with movement of the two three-dimensional triangles. ...

How to tell if a line intersects a polygon in C#?

Hi! I have a question very similar to this: http://stackoverflow.com/questions/30080/how-to-know-if-a-line-intersects-a-plane-in-c-basic-2d-geometry I am searching for a method that tells if a line is intersecting an arbitrary polygon in C#. I think the algorithm from chris-marasti-georg was very helpful but missing the most important...

How to test if a point is inside of a convex polygon in 2D integer coordinates?

The polygon is given as a list of Vector2I objects (2 dimensional, integer coordinates). How can i test if a given point is inside? All implementations i found on the web fail for some trivial counter-example. It really seems to be hard to write a correct implementation. The language does not matter as i will port it myself. ...

Spatial geometry for augmented reality applications

Hi, Does anyone know any good book or web resource for geometric and mathematical fundamentals of augmented reality? Thanks! ...

How do I find the lat/long that is x km north of a given lat/long

I have some C# code that generates google maps. This codes looks at all the Points I need to plot on the map and then works out the Bounds of a rectangle to include those points. It then passes this bounds to the Google Maps API to set the zoom level appropriately to show all of the points on the map. This code is working fine however I...

How do I Convert a FormattedText String into a Geometry-Based Object?

How do I convert a FormattedText string into a geometry-based object? I don't think this question requires much explanation, and I can't think if very many other details I could give ... I just need to convert the FormattedText into something I can use mathematically (geometrically). Any advice is appreciated! ...

Smallest set of rectangles describing a set of integer points

Given a set of N-dimensional integer points how do I find the smallest set of N-dimensional cuboids (rectangles in the 2-d case), such that an integer point is in the set of integer points if and only if it's contained in one or more of the cuboids/rectangles. Integer point means a point with integer coordinates. e.g. given the points (...