geometry

comparing original and simplified TINs

Hi, I have two TINs (triangulated irregular network) of a terrain. First one (TIN1) is the original one, let's say with X number of points. And the other (TIN2) is simplified (the number of points were reduced by some decimation algorithm) one where let's say it was build from Y points, where X>Y. Now, how could I do the following compar...

clockwise angle between two line

I want to calculate a clockwise angle between two line segment A and B. So the resulting angle must be between 0 to 360-1 degrees. I've seen all other answers in SO but they gave me negative angles. Thanks. ...

Finding the apex of a bezier curve

I'm working in flex, although I reckon this is a language independent problem. I'm trying to draw a curve using 3 points, using curveTo (a quadratic bezier function, I don't believe Flex has any other, if it does, please correct me!) Points 1 and 3 are "nodes", with point 2 being a drag handle. What I want is not for the line to curve ...

{R grid}: how to create a polygon half filled with color ?

(This question might be too difficult, and maybe not worth the hassle to solve - however, if there is an easy solution - I would be curious to know) Let's say I create an image (using the grid package) which looks like this: require(grid) grid.newpage() grid.polygon(x=c((0:4)/10, rep(.5, 5), (10:6)/10, rep(.5, 5)), y=c(rep...

How to split a PathGeometry Polygon by an intersecting line segment

I've got a PathGeometry that I've built from a bunch of LineSegments, and I want to split it into two PathGeometries divided by a line intersecting down the middle of the geometry. Here's what I mean by this picture: http://i30.tinypic.com/2noyvm.png I can go through the LineSegments and create an array of simple line objects (simple ...

How to find the centre of a grid of lines on google maps

Hi, I'm struggling with a problem with some GIS information that I am trying to put into a KML file to be used by google maps and google Earth. I have SQL database containing a number of surveys, which are stored in lines. When all the lines are drawn on the map, they create a grid. What I am trying to do is work out the centre of th...

Whats an easy way to fill a Concave PathGeometry to be Convex (finding the concave vertices & removing them)?

I've got a PathGeometry (polygon) built up of LineSegments on one PathFigure and I'd like to ensure that it's Convex. I have a method using the CrossProduct to determine whether the geometry is Convex, I was assuming that I could just return back a list of points that make it concave when it's false and remove those points to fill the p...

2D game algorithm to calculate a bullet's needed speed to hit target?

I have a rather simple bird's-view 2D game where tower sprites defend against incoming moving sprites by shooting a bullet at them. My question: How do I calculate the needed bullet speed for the bullet to reach its moving target, provided that the bullet will always have the same defined speed? I'm using JavaScript and have these sprit...

rotating a 2d square into another

Hi, I have two squares, S1 = (x1,y1,x2,y2) and S2 = (a1,b1,a2,b2) I'm looking for the A transformation matrix with which A * S1 = S2 As far as I see, A is an affine 3x3 matrix, so I have 9 unknown values. How can I calculate these values? thanks and best, Viktor ...

10 LISP primitives analogous to 5 axioms of Euclidean geometry?

LISP can be built from ten primitives: The primitives are: atom, quote, eq, car, cdr, cons, cond, lambda, label, apply. Apparently these are equivalent to the 5 axioms of Euclidean geometry. http://hyperpolyglot.wikidot.com/lisp Can anyone explain how they are equivalent? ...

Snap to Road with direction in concern.

I'm trying to add a snap-to-road function in my all custom made GPS software. There's a few thousand of roads with hundreds of thousands of nodes (lat-lon points). I have read all those snap to road question in SO with "closest point on a line" as a good solution. However, what I am doing is to snap to a nearest road with the same direct...

Creating a Skew AngleY from a Skew Factor for a Rhomboid in XAML

I'm not sure if this is possible, but basically I have two degrees that will change the width/size and skew of an image. In a tranformation matrix (<Matrix3DProjection/>), it works like this: M11:cos(x) M12:sin(y)*sin(x) M11:0 M21:0 M22:cos(y) M23:0 M31:0 M32:0 M33:1 So if I have X = 30° and ...

Computational geometry, tetrahedron signed volume

I'm not sure if this is the right place to ask, but here goes... Short version: I'm trying to compute the orientation of a triangle on a plane, formed by the intersection of 3 edges, without explicitly computing the intersection points. Long version: I need to triangulate a PSLG on a triangle in 3D. The vertices of the PSLG are defined...

How to get size of a rotated rectangle

Possible Duplicate: Calculate Bounding box coordinates from a rotated rectangle, Picture inside. I have a rotated rectangle, So how do i calculate the size of axis-aligned bounding box for the rotated rectangle in 2D Coordinates? Attach Image http://img88.imageshack.us/img88/503/rotp.png i know x, y, o (angle) but how do i ...

Bezier's offset clipping

Hi! I'm trying to make a plug-in for Inkscape for cnc machining. And I need to make Bezier offset function. Inkscape operates with cubic Beziers. So here's what I've done. Offset of a single segment. Join of a two offseted segments. Splitting by intersection points of the offsetted curve. And I've stopped at clipping. My pl...

Elegant/Clean (special case) Straight-line Grid Traversal Algorithm?

I'm dusting off an old project of mine. One of the things it had to do was -- given a Cartesian grid system, and two squares on the grid, find a list of all squares that a line joining the center of those two squares would pass through. The special case here is that all start and end points are confined to the exact center of squares/c...

Help me identify the plot in this image

Hi - I'm not very math savvy, but this Mathematica plot caught my eye and I was hoping you could help me identify it. Have a look at the image (sorry about the quality, it's a screen capture of a video) I've searched the various functions and keywords found in the pictured code, but none of the results suggested anything specific to me...

Image scaling geometry

This is very programming related but a somewhat non-programming question. I am performing image scaling in a web based application and I need to maintain my image relative to a fixed location even though it scales anchored by its top, left corner. Hope the graphic make this possible. The idea is that C is a fixed location that I want t...

Circle and Line Segment Intersection Detection (LatLon Point, Meter Radius and LatLon Line)

Hi, I have a circle which is actually a latlon position with a radius measured in meters. And I also have a road A-B defined as two lat-lon positions. How do I find whether that road cross inside the circle or not. Is it possible without projection latlon positions into xy positions? If possible please tell me how to do it. I'm actually...

how to simulate a rectangle union starting with a rectangle intersection

Given rectangle_A intersecting rectangle_B, Which has a union defined such that it is the rectangle containing both rectangles: I want to determine the coordinates of the (not overlapping) rectangles required to add to rectangle_A to create the union of rectangle_A and rectangle_B: (note: this is just one configuration of the so...