geometry

Diagonals of quadrilateral

Hi, is there any way to find out diagonals of quadrilateral if I only know the four sides - no angles? I understand I could calculate it with the law of cosines: p = sqrt( a^2 + b^2 - 2*a*b*cos(α) ) q = sqrt( b^2 + c^2 - 2*b*c*cos(β) ) // or whatever you name these angles but I don't know the angles! So I'm kind of stuck here. Th...

What's the most efficient way to detect triangle-triangle intersections ?

How can I tell whether two triangles intersect in 2D Euclidean space? (i.e. classic 2D geometry) given the (X,Y) coordinates of each vertex in each triangle. ...

How to find the intersection point between a line and a rectangle?

I have a line that goes from points A to B; I have (x,y) of both points. I also have a rectangle that's centered at B and the width and height of the rectangle. I need to find the point in the line that intersects the rectangle. Is there a formula that gives me the (x,y) of that point? PS: I'm working with C# but a solution in a simila...

Calculate 3D vector perpendicular to a plane generated by two vectors

I am new to dealing with 3D, and even simple stuff makes my head spin around. Sorry for the newbie question. Lets say I have 2 vectors: a(2,5,1) b(1,-1,3) These vectors "generate" a plane. How can I get a third vector perpendicular to both a and b? I can do this in 2D using a vector c(A,B) and turning it into c'(-B,A). Thanks for t...

Modifying a convex hull to exclude unwanted points

Hi folks, In my C#-Silverlight 3 program, I have a set of points. Those points can be of a different color, green, red or blue. Then I create a convex hull for the different points: A hull for green, a hull for red and a hull for blue. Now it can happen, that within the hull of each color are points from another color, like red points w...

Combine multiple Ellipses

Hi I need a way to combine multiple EllipseGeometry to make a union between them, but CombineGeometry class only can combine 2 Geometries. The ideal way is to have a class similar CombineGeometry that accepts more than Geometry1 and Geometry2 shapes. Anyone knows an object that makes such a behaviour?? Thanks in advanced ...

How to map a point onto a warped grid

Say you have a collection of points with coordinates on a Cartesian coordinate system. You want to plot another point, and you know its coordinates in the same Cartesian coordinate system. However, the plot you're drawing on is distorted from the original. Imagine taking the original plane, printing it on a rubber sheet, and stretch...

Given a set of points, how do I find the two points that are farthest from each other?

I could compute the distance between each point and take the largest but that doesn't sound like a very efficient way to do it when there are a large (> 1000) number of points. Note: This is for iPhone so I don't have a ton of processing power. ...

Rotation matrix that minimizes distance

Let's say I have two points in 3D space (a and b) and a fixed axis/unit vector called n. I want to create a rotation matrix that minimizes the euclidan distance between point a (unrotated) and the rotated point b. E.g: Q := matrix_from_axis_and_angle (n, alpha); find the unknown alpha that minimizes sqrt(|a - b*Q|) Btw - If a s...

How to find largest triangle in convex hull aside from brute force search

Given a convex polygon, how do I find the 3 points that define a triangle with the greatest area. Related: Is it true that the circumcircle of that triangle would also define the minimum bounding circle of the polygon? ...

(all the) directions perpendicular to hyperplane through p data points

Hi people, I have a simple question: given p points (non-collinear) in R^p i find the hyperplane passing by these points (to help clarify i type everything in R): p<-2 x<-matrix(rnorm(p^2),p,p) b<-solve(crossprod(cbind(1,x[,-2])))%*%crossprod(cbind(1,x[,-2]),x[,2]) then, given a p+1^th points not collinear with first p points, i fin...

Calculate lat/lng of corners of ground overlay from kml-file

I need to find the corners in lat/lng of a ground overlay given in a kml-file either in php or javascript. I.e. for a specific example I need to get from: <LatLonBox> <north>60.406505416667</north> <south>60.400570555556</south> <east>5.3351572222222</east> <west>5.3190577777778</west> <rotation>3.7088732260919</r...

Ellipse geometry bound points

Hi Is there a automatic way to get all the points of an ellipse stroke, without the filling points. Thanks in advanced ...

Good starting book to learn fractal programming

what is a good book to learn fractal programming? I am a programmer, I am looking at a book that will be more algorithmic than mathematical (at least not in the beginning chapters). Should teach me the basics of fractals and different ways to generate them. ...

How to make sure if a polynomial curve is monotonic under interval [a,b]?

Hi, guys, If I got a polynomial curve, and I want to find all monotonic curve segments and corresponding intervals by programming. What's the best way to do this... I want to avoid solving equation like f'(x) = 0; Using some nice numerical ways to do this,like bi-section, is preferred. f'(x) expression is available. Thanks. Add addit...

Combined area of overlapping circles

I recently came across a problem where I had four circles (midpoints and radius) and had to calculate the area of the union of these circles. Example image: For two circles it's quite easy, I can just calculate the fraction of the each circles area that is not within the triangles and then calculate the area of the triangles. But...

Triangulated Irregular Networks from qhull

Hi, I wanted to create TINs from 3D points (about 7 million in every file) using qhull. can anyone suggest a place where i could probably see how to do this? thanks! ...

Find a point between two point

I two concentric circles on the screen and I want the circle on the inside to move around while the user drags their finger around the outside of the larger circle. This means that I have two point, center of the larger circle and the point at which the user touched. How do I calculate where the center of the smaller circle should be? ...

Insert a point into a finite 2D region with maximum distance to existing points.

I have a set of 2D points inside a finite 2D region of space (let's say a world-aligned rectangle to keep things simple for now). What would be an exceedingly efficient way to insert a new point into the set that has a relatively large distance to its new closest neighbour? I could slowly build a Delaunay triangulation and limit my sear...

How to calculate the 3D line segment of two rectangles?

I am looking for a fast way to calculate the line segment of two given rectangles in 3D. For instance, each 3D rectangle is defined by its four vertices. A solution in any reasonable programming language will do. ...