geometry

3d to 2d Projection Matrix

I have 3 points in 3d space. I know the exact locations of them. Suppose they are (x0,y0,z0) (x1,y1,z1) (x2,y2,z2) Also i have a camera that are looking at these 3 points and i know the 2d locations of those three points on camera view plane. So for example (x0,y0,z0) will be (x0',y0') and (x1,y1,z1) will be (x1',y1') and (x2,y2,z2) wil...

How do you find a point a given perpendicular distance from a line?

I have a line that I draw in a window and I let the user drag it around. So, my line is defined by two points: (x1,y1) and (x2,y2). But now I would like to draw "caps" at the end of my line, that is, short perpendicular lines at each of my end points. The caps should be N pixels in length. Thus, to draw my "cap" line at end point (x1,y1...

How can a transform a polynomial to another coordinate system?

Using assorted matrix math, I've solved a system of equations resulting in coefficients for a polynomial of degree 'n' Ax^(n-1) + Bx^(n-2) + ... + Z I then evaulate the polynomial over a given x range, essentially I'm rendering the polynomial curve. Now here's the catch. I've done this work in one coordinate system we'll call "data sp...

Circle coordinates to array in Javascript

What's the best way to add the coordinates of a circle to an array in JavaScript? So far I've only been able to do a half circle, but I need a formula that returns the whole circle to two different arrays: xValues and yValues. (I'm trying to get the coordinates so I can animate an object along a path.) Here's what I have so far: circle...

Close point of approch detection

I have a large set of 3rd order polynomials in 3D. in matrix form [Pn](t) = [1,t,t^2,t^4]*[An] // [Pn] and [An] are matrices each function has a weight Wn. I want to, for some n, m, T and t0 find the first t where t>t0 such that Wn*Wm / |[Pn](t)-[Pm](t)|^2 > T aside from a the O(n^2) "try everything" approach I'm not even sure w...

C++ library for rotating a point over a given axis?

Does anyone know of a graphing library for simple transformation of a point from one coordinate system to another coordinate system which is rotated by a angle and some point transformation and just for 2d? And any graphing tool for plotting and verifying the same visually? ...

determining points from set of pairwise distances

given a matrix of distances between points is there an algorithm for determining a set of n-dimensional points that has these distances? (or at least minimises the error) sort of like a n-dimensional version of the turnpike problem. The best I can come up with is using multidimensional scaling. ...

How to calculate center of an ellipse by two points and radius sizes

While working on SVG implementation for Internet Explorer to be based on its own VML format I came to a problem of translation of an SVG elliptical arc to an VML elliptical arc. In VML an arc is given by: two angles for two points on ellipse and lengths of radiuses, In SVG an arc is given by: two pairs of coordinates for two points on e...

Algorithm for unique find edges from polygon mesh

I'm looking for a good algorithm that can give me the unique edges from a set of polygon data. In this case, the polygons are defined by two arrays. One array is the number of points per polygon, and the other array is a list of vertex indices. I have a version that is working, but performance gets slow when reaching over 500,000 polys....

How do I extract a 2D slice from 3D geometry from plane intersection?

Hello world. Recently our team was facing the task to build the 2D slice between a plane and some set of 3D geometry (set of triangles). Google hasn't been as helpful as we have wanted it to be, so we turn our attention here to see if anyone has encountered this problem with a possible solution. Links are also wanted. Finding the inter...

Spatial Data Structures for moving objects?

I was wondering what is the best data structure to deal with a lot of moving objects(spheres, triangles, boxes, points, etc)? I'm trying to answer two questions, Nearest Neighbor and Collsion detection. I do realize that traditionally, data structures like R trees are used for nearest neighbor queries and Oct/Kd/BSP are used for collis...

How to determine path from noisy X, Y data

I have an unsorted list of noisy X, Y points. They do, however, form a path through the world. I would like an algorithm to draw an approximation of this data using line segments. This is similar to how you would use a line -fitting algorithm to pick an approximation of linear data. My problem is only harder because the path bends and w...

Random points inside a Polygon

I have a 4 side convex Polygon defined by 4 points in 2D, and I want to be able to generate random points inside it. If it really simplifies the problem, I can limit the polygon to a parallelogram, but a more general answer is prefered. Generating random points until one is inside the polygon wouldn't work because it's really unpredict...

Sort Four Points in Clockwise Order

Four 2D points in an array. I need to sort them in clockwise order. I think it can be done with just one swap operation but I have not been able to put this down formally. Edit: The four points are a convex polygon in my case. Edit: The four points are the vertices of a convex polygon. They need not be in order. ...

How to create a WPF Shape Editor ?

I'm trying to create a WPF Shape (PolyLine) editor, which is a control that I want to use to, edit shapes in a canvas. What the editor needs to do is to be able to display the points and lines of the shape and to move those around. Can anyone provide me with a idea of how I can accomplish this, or a starting point? I haven't found anyt...

What is an Efficient algorithm to find Area of Overlapping Rectangles

My situation Input: a set of rectangles each rect is comprised of 4 doubles like this: (x0,y0,x1,y1) they are not "rotated" at any angle, all they are "normal" rectangles that go "up/down" and "left/right" with respect to the screen they are randomly placed - they may be touching at the edges, overlapping , or not have any contact I w...

Comparing Polygons for Similarity

What are the usual methods to compare two polygons for similarity? Vertices are in 2D. ...

WPF: How to apply a GeneralTransform to a Geometry data and return the new geometry?

Having some Geometry data and a Transform how can the transform be applied to the Geometry to get a new Geometry with it's data transformed ? Ex: I Have a Path object that has it's Path.Data set to a PathGeometry object, I want to tranform the points of the PathGeometry object in place using a transform, and not apply a transform to the...

Defining Up in the Direct3D View Matrix when Camera Is Constantly Moving

In my Direct3D application, the camera can be moved using the mouse or arrow keys. But if I hard code (0,1,0) as the up direction vector in LookAtLH, the frame goes blank at some orientations of the camera. I just learned the hard way that when looking along the Y-axis, (0,1,0) no longer works as the Up direction (seems obvious?). I am ...

3D Geometry: Transform One Pair of Points to be Aligned Parallel to Another

I have a line (actually a cube) going from (x1,y1,z1) to (x2,y2,z2). I would like to rotate it so that it is aligned along another line going from (x3,y3,z3) to (x4,y4,z4). Presently I am using Math::Atan2 along with Matrix::RotateYawPitchRoll. Any better ways to do this? Edit: I think I've worded this post very badly. What I am actuall...