geometry

2/3D Geometry: How to optimally align two lists of points

The problem I am trying to solve is as follows: Given two lists of equal length containing points, find a mapping that minimizes the sum of distances between pairs. The reason I'm trying to do this is to find the closest points in two polygons for a genetic algorithm I'm building, that would ideally line up two genes based on the output ...

triangulating gps coordinates

Say you have n GPS coordinates how could you work out the central gps point between them? ...

What is the equation to calculate the distance from the end of a line segment to the edge of a circle?

I have a circle with two points inside it that make up a line segment. How can I calculate the distance from one endpoint to the edge of the circle where the line would intersect it? ...

Looking for a radial coordinates description of gear teeth.

I don't need a physically accurate function, but something that hints at the involute curves, etc. I was just using r = 2 + sin^2, which gets the idea across, but it looks like - ahem. Googling around, you can find plenty of information on how to draft a 'correct' gear, but nothing in the way of a bare-bones approximation. EDIT: The ...

Curve Fitting 3D data set

The curve-fitting problem for 2D data is well known (LOWESS, etc.) but given a set of 3D data points, how do I fit a 3D curve (eg. a smoothing/regression spline) to this data? MORE: I'm trying to find a curve, fitting the data provided by vectors X,Y,Z which have no known relation. Essentially, I have a 3D point cloud, and need to find...

Finding the farthest point in one set from another set

My goal is a more efficient implementation of the algorithm posed in this question. Consider two sets of points (in N-space. 3-space for the example case of RGB colorspace, while a solution for 1-space 2-space differs only in the distance calculation). How do you find the point in the first set that is the farthest from its nearest ne...

Cutting holes in PathGeometry

I have a PathGeometry defining some path like this one: This is a simplified example. In reality it can have segments of any type (Line, Arc, Bezier). Now I need to cut a hole of some sort and size (square, circle, etc.) in segment joint points so the final result looks something like this: My initial idea was to combine the origi...

Find random point along a line

I'm writing a small program to help split passwords ( see below for explanation) I have code to convert text to a int ( text-ascii binary -> dec int) so in this case the word "test" would = 1952805748 Now the interesting part.(encoding the password) I would then take x1 = 1952805748 and y1 = 0 then i make up a random point where x2 ...

Drawing a rectangle on a flex canvas is there a better way than ...

Hello, To draw a "selection rectangle" from the mouse down , mouse move then remove it on mouse up i currently do the following: My board is a canvas, On mouse down i create a new UIcontainer i set his borders. I update his width and height related the the mouse move position, on mouse up i remove this child UIcontainer. Do i have to ...

Finding an axis-aligned rectangle inside a polygon

I am looking for a good algorithm to find an axis-aligned rectangle inside a (not necessarily convex) polygon. A maximal rectangle would be nice, but is not necessary - any algorithm that can find a "fairly good" rectangle would be fine. The polygon may also have holes, but any pointers to algorithms that only work for convex or simple ...

Flex/Actionscript: Dynamically adding text along an arc

I am trying to create an area in my Flex application where a user can type in text and it will appear along a curve or an arc. The curve/arc should be able to be adjusted by the user as well. Does anyone have any code examples or pointers on how I can achieve this in Flex 3/Actionscript 3? ...

Minimize Polygon Vertices

What is a good algorithm for reducing the number of vertices in a polygon without changing the way it looks very much? Input: A polygon, represented as a list of points, with way too many verticies: raw input from the mouse, for example. Output: A polygon with much fewer verticies that still looks a lot like the original: something usa...

Smooth 3D spline

REF: http://stackoverflow.com/questions/588438/curve-fitting-3d-data-set Does anyone know how to construct a smooth 3D spline with 3D control points? If you look at the reference provided above, the red points will serve as the control points for the spline (which is supposed to be a best-fit representation of the 3D point cloud). ...

Calculate Bounding box coordinates from a rotated rectangle, Picture inside.

Hello, I have the coordinates of the top left Point of a rectangle as well as its width, height and rotation from 0 to 180 and -0 to -180. I am trying to get the bounding coordinates of the actual box around the rectangle. What is a simple way of calculating the coordinates of the bounding box - min y, max y, min x, max x ? The A p...

Separating axis test, detecting if a rotated rectangle overlap an other flat rectangle

Hello, I read about intersection rectangles on: http://stackoverflow.com/questions/115426/algorithm-to-detect-intersection-of-two-rectangles But i have trouble to implement it. If R1 (A,B,C,D) is my rotated rectangle and R2(A',B',C',D') the other rectangle with no rotation. The formula extracted in from the link above is: edge = ...

Most elegant way to clip a line?

I have a Rectangle2D and a Line2D. I want to "clip" the line so that only the part of the line which is within the rectangle remains. If none of the line is within the rectangle I want the line to be set to (0,0,0,0). Basically something along the lines of a Rectangle2D.intersect(Line2D src, Line2D dest) or something similar. Is ther...

Calculating the shortest distance between two lines (line segments) in 3D

I have two line segments: X1,Y1,Z1 - X2,Y2,Z2 And X3,Y3,Z3 - X4,Y4,Z4 I am trying to find the shortest distance between the two segments. I have been looking for a solution for hours, but all of them seem to work with lines rather than line segments. Any ideas how to go about this, or any sources of furmulae? ...

How can I find the 3D coordinates of a projected rectangle?

Hello everybody. I have the following problem which is mainly algorithmic. Let ABCD be a rectangle with known dimensions d1, d2 lying somewhere in space. The rectangle ABCD is projected on a plane P (forming in the general case a trapezium KLMN). I know the projection matrix H. I can also find the 2D coordinates of the trapezium edge p...

Wavy underlines as a TextDecoration: what I am doing wrong?

I want to create wavy underlines using TextDecoration (in a control similar to RichTextBox). I did the following thing: private static Pen CreateErrorPen() { var geometry = new StreamGeometry(); using (var context = geometry.Open()) { context.BeginFigure(new Point(0.0, 0.0), false, false); context.PolyLineTo(new...

Converting indexed polygons to unindexed ones. Several problems have cropped up.

Yet again I have some questions regarding polygon algorithms. I'll try to explain my problem: I am using a subset of a third party library called Geometric Tools(GT) to perform boolean operations on my polygons. To accomplish this I have to convert my internal polygon format to the format GT uses. Our internal polygon format consists...