geometry

Get un-translated, un-rotated (x,y) coordinate of a point from a Javascript canvas

In Javascript we often render graphics by rotating and translating the coordinate plane before sending things ctx.save(); ctx.translate(someX, someY); ctx.rotate(someAngle * Math.PI / 180); ctx.beginPath(); ctx.moveTo(x1, y1); // What's the actual (x1,y1)? ctx.lineTo(x2, y2); // What's the actual (x2,y2)? ctx.stroke(); ctx.resto...

Lightweight OBJ mesh file loader for C/C++?

I'm looking for a simple lightweight Wavefront OBJ mesh file reader for C or C++. (ie. given a mesh in OBJ format, read it in from a file, and make it accessible, preferably as a list of vertices and triangles.) Recommendations? It doesn't need to support material properties or any other fancy data that might be present - just the geom...

Calculating the Bounding Rectangle at an Angle of a Polygon

I have the need to determine the bounding rectangle for a polygon at an arbitrary angle. This picture illustrates what I need to do: The pink rectangle is what I need to determine at various angles for simple 2d polygons. Any solutions are much appreciated! Edit: Thanks for the answers, I got it working once I got the center point...

Calculating slope in -ve, zero and +ve domains

Imagina a sine wave oscillating about a zero line. My task is to calculate the slope at several random points along the wave using a fairly coarse x axis scale. (yes this has a real application) When the wave is in +ve terrirtory (above the zero line) slope can be calculated from: Slope = (y(n) / y(n-1)) - 1 This yeilds +ve slope vla...

Arrange labels for objects in 2D space without overlap

I need to attach text labels to objects that are spread randomly across the screen and keep moving. The default and ideal position for a label is on the right side of the object it refers to. I need a way to dynamically rearrange (or possibly merge) the labels so that they never overlap each other or other objects. They should still be...

How can I tell if a point is nearby a certain line ?

Hi there, I asked "How can I tell if a point belongs to a certain line?" before and I found a suitable answer so thank you very much. Now, I would like to know how to tell if a certain point is close to my line. ...

Position of a point relative to a Bezier curve

I have a Bezier curve specified by 4 points. I need to know if a point is on the left side or right side of the Bezier curve. Can you suggest me an algorithm? Edit: I'm sure that the way I generate the Bezier curve would not form loops. Later edit I realized that my initial problem could be solved without using relative position. When ...

simple geometric shape recognition in C#

Hi I have a set of Strokes (from ink) and would like to find those strokes that participate in a geometric shape like line,square, circle, triangle... and identify them. Until now i have seen many algorithms that work on bitmaps. My problem is easier since i have already the good array of point. But still need to find the closest geo...

Geo Fencing - point inside/outside polygon

Hi, I would like to determine a poligon with geo points and implement an algorithm which would check if the point is inside or outside the polygon. Does anyone know if there is any example available of any similar algorithm? Thanks! ...

Equidistant points in a line segment

Let assume you have two points (a , b) in a two dimensional plane. Given the two points, what is the best way to find the maximum points on the line segment that are equidistant from each point closest to it with a minimal distant apart. Any help will be greatly appreciated. Thanks. I use c#, but examples in any language would be hel...

algorithm for finding out pixel coordinates on a circumference of a circle

how do i find out pixel value at certain degree on the circumference of a circle if I know the pixel co-ordinates of the center of the circle, radius of the circle ,and perpendicular angle. Basically, I am trying to draw the hands of a clock at various times ( 1 o clock , 2 o clock etc ) ...

Calculating the area(s) of a rectangle that aren't being overlapped

I've got two rectangles represented by structures that contain the x1, y1, x2, y2 coordinates. One rectangle can be considered the parent, another the child. I already know how to detect if the child rectangle is within the parent rectangle; what I'm trying to figure out now is the simplest, fastest way to determine the rectangular area...

check if a point exists in given area containing 4 vertices

refering to http://www.weather.gov/directives/sym/pd01008006curr.pdf, page 8, we are given an area with four vertices in geographic coordinate system(lat and long system). I want to check if a point with particular lat and long exists within that area. ...

Angle at corner of two lines

Hello, I search for the fastest or simplest method to compute the outer angle at any point of a convex polygon. That means, always the bigger angle, whereas the two angles in question add up to 360 degrees. Here is an illustration: Now I know that I may compute the angles between the two vectors A-B and C-B which involves the dot pr...

How to determine if a Delaunay triangle is internal or external?

I am writing a program that requires a implementation of Medial Axis extraction, of which Delaunay triangulation is a step. External medial axis is unwanted so the corresponding external triangles are intended to be removed. Luckily I came upon a page with a lot of diagrams, also a hint of a method to determine internal and external Dela...

2d outline algorithm for projected 3d mesh

Hi, Given: A 3d mesh defined with a set of vertices and triangles building up the mesh with these points. Problem: Find the 2d outline of the projected arbitrarily rotated mesh on an arbitrary plane. The projection is easy. The challenge lies in finding the "hull" of the projected triangle edges in the plane. I need some help with inp...

How to find a point in the Earth surface given an origin point, distance and direction (azimuth)

The previous question "Geoalgorithm for finding coordinates of point from a known location by distance and bearing" asks the same thing, but the solution found is a rough approximation. I want a more accurate solution. I am comparing the results with the Great Circle Distance formulas, which is one of the best Geographical Distance formu...

Rotate normal vector onto axis plane

I have a set of data points in 3D space which apparently all fall onto a specific plane. I use PCA to compute the plane parameters. The 3rd component of PCA gives me the normal vector of the plane (weakest component). What I want to do next is to transform all the points onto said plane and look at it in 2D. My idea was to do the foll...

Compare three-dimensional structures

I need to evaluate if two sets of 3d points are the same (ignoring translations and rotations) by finding and comparing a proper geometric hash. I did some paper research on geometric hashing techniques, and I found a couple of algorithms, that however tend to be complicated by "vision requirements" (eg. 2d to 3d, occlusions, shadows, et...

How do I break a moving objects speed up into its X and Y velocity given a fixed speed/angle?

Math escapes me today. How do I find the X speed and the Y speed of an object if it is going at a defined speed (say, 5 pixels/second) at a 45 degree angle? ...