geometry

How to enable anti-aliasing for a polyline drawn with WPF StreamGeometry?

I need to draw a polyline into a DrawingVisual. I'm using StreamGeometry for performance reasons. The problem I have is that I can't figure out how to enable anti-aliasing. I can't find any method or property on StreamGeometry or on DrawingContext for anti-aliasing control. The code below is in IronPython, but it shouldn't matter: geom...

Simple C/C++ library for triangle-intersection acceleration structure

I'm raytracing and would like to speed it up via some acceleration structure (kd-tree, BVH, whatever). I don't want to code it up myself. What I've tried so far: Yanking the kd-tree out of pbrt. There are so many intra-dependencies that I couldn't succeed at this without pulling all of pbrt into my code. CGAL's AABB tree. Frustratingly...

computing the bounding rectangle of planar geometry in 3D space

As an input, I receive some planar, triangulated geometry. Now, I need to compute the four coordinates of the corners of the bounding rectangle. Any Ideas? ...

3d geometry: how to interpolate a matrix

hello, i store the position of an object in 3d space in a 4by4 transformation matrix. now in order to move the object from the position stored in matrix A to the position stored in matrix B, i would like to interpolate them. so do i just do this by interpolating each of the 16 values in the matrix, or do i have to take special care abo...

Dividing a plane of points into two equal halves

Given a 2 dimensional plane in which there are n points. I need to generate the equation of a line that divides the plane such that there are n/2 points on one side and n/2 points on the other. (by the way this not home work, I am just trying to solve the problem) ...

recursive creation of an unlimited 7-gon

hey, i wondered if there's an algorithm to create a polygon, composed of triangles, to look like this: http://homepages.wmich.edu/~drichter/images/mathieu/numberedvertices.jpg the numbering of the vertices is not important, just the method how to get the points. notice that every point is connected to exactly 7 others. ...

Minimum bounding rectangle of a circle on a sphere

What R packages are available to calculate the minimum bounding box for a great circle? For example: box <- polycirc( c( longitude, latitude ), distance=35 ) This would return the bounding box for the circle with a radius of 35 kilometres from the central point at the given coordinates (on Earth). Where: box.longitude_min = The l...

get closest point to a line

I'd like to have a straight forward C# function to get a closest point (from a point P) to a line-segment, AB. An abstract function may look like this. I've search through SO but not found a usable (by me) solution. public Point getClosestPointFromLine(Point A, Point B, Point P); ...

Using matlab to calculate the properties of a polygon defined as a list of points

Does MATLAB have a built-in function to find general properties like center of mass & moments of inertia for a polygon defined as a list of (non-integer valued) points? regionprops performs this task for integer valued points, on the assumption that these represent indices of pixels in an image. But the only functions I can find that...

Creating Non-stroked Region in C# StreamGeometry Xaml markup

I am looking for a way to create non-stroked regions for a StreamGeometry in xaml. In other words, I want to know if it is possible to recreate the following code (taken from msdn) with the StreamGeometry Xaml markup syntax. StreamGeometry geometry = new StreamGeometry(); geometry.FillRule = FillRule.EvenOdd; using (StreamGeometryCont...

Querying a collection of rectangles for the overlap of an input rectangle

In a multi-dimensional space, I have a collection of rectangles, all of which are aligned to the grid. (I am using the word "rectangles" loosely - in a three dimensional space, they would be rectangular prisms.) I want to query this collection for all rectangles that overlap an input rectangle. What is the best data structure for holdi...

matrix that forms an orthogonal basis with a given vector

A linear algebra question; Given a k-variate normed vector u (i.e. u : ||u||_2=1) how do you construct \Gamma_u, any arbitrary k*(k-1) matrix of unit vectors such that (u,\Gamma_u) forms an orthogonal basis ? I mean: from a computationnal stand point of view: what algorithm do you use to construct such matrices ? Thanks in advance,...

Determining the intersection of a triangle and a plane

I have a single triangle and a plane (in 3 dimensional space), How would I calculate the line segment where the two cross, if there is no crossing then I need to detect this case. The end result I'm looking for is two 3 dimensional vectors, which define the start and end points of the line segment. To help you out a little, I have alre...

Calculating 3d plane for two 3d vectors

If I have two vector coordinates representing positions on the surface of the earth where the center of the earth is (0,0,0) and the Up vector is (0,0,1); What is the best way to calculate a 3d plane that is running along the two vectors (the direction v2 - v1) but back by a set number of meters (just imagine a virtual clip plane that i...

Changing co-ordinate system

I need to switch from the XY co-ordinate system shown above to the X'Y' co-ordinate system using System::Drawing::Drawing2D (i.e. GDI+). This is what I have in mind: float rotation = // +90 below is because AB is the new vertical... Math::Atan2(pB.Y - pA.Y, pB.X - pA.X) * 180.0 / Math::PI + 90.0f; Matrix m; m.T...

Prove that the segments formed by two internal segments to a circle crossing each other when multiplied are equal.

This is a simple math question to which I had an answer a long time ago but that doesn't come to mind immediately right now. Using the picture attached, how would I prove that a*b = c*d ...

get angle of a line from horizon

I want to know how to get an angle of a line A-B from horizontal axis X. Other questions in SO do that only between two lines. I'm aware I can always draw second line A-C and calculate but I'm wondering if there's a faster method. EDIT: I'm very sure I'm not doing a premature optimization. ...

creating and intersecting hexahedrons with CGAL

Using the Python bindings for CGAL, I can't work out how create a hexahedron, nor how to calculate its intersection with another hexahedron. I have 8 input points, which are the corners of the hexahedron: My code does this: P = Polyhedron_3() bottom = P.make_tetrahedron(p[0],p[1],p[2],p[3]) top = P.make_tetrahedron(p[4],p[5],p[6],p[...

Reflecting a circle off another circle

Working with iPhone and Objective C. I am working on a game and I need to correctly reflect a ball off a circle object. I am trying to do it as a line and circle intersection. I have my ball position outside the circle and I have the new ball position that would be inside the circle at the next draw update. I know the intersect point of...

Proper Trigonometry For Rotating A Point Around The Origin

Do either of the below approaches use the correct mathematics for rotating a point? If so, which one is correct? POINT rotate_point(float cx,float cy,float angle,POINT p) { float s = sin(angle); float c = cos(angle); // translate point back to origin: p.x -= cx; p.y -= cy; // Which One Is Correct: // This? float xnew ...