geometry

Given 3 pts, how do I calculate the normal vector?

Given three 3D points (A,B, & C) how do I calculate the normal vector? The three points define a plane and I want the vector perpendicular to this plane. Can I get sample C# code that demonstrates this? ...

Finding the 4th point of quadrangle. (After perspective transform)

There is an image of square, and to that image the perspective transform is applied. So the perspective image of a square will be not a square but a quadrangle. The question: If I know three corner points of the perspective image (quadrangle) then what will be the fourth corner point of the quadrangle? The problem also arises bec...

Project Euler 126: could someone explain?

Project Euler 126 says: "If we then add a second layer to this solid it would require forty-six cubes to cover every visible face." How come? I thought lay another 3x2x1 over a 3x2x1 makes it 3x2x2, and you need 6 to cover the top, 6 to cover the bottom, 3+2+3+2 to cover each layer, so the total is 32, every white color face is covered,...

point in a self-intersecting / complex polygon

I've read http://stackoverflow.com/questions/217578/point-in-polygon-aka-hit-test but I'm not sure if the solution would apply to a polygon that is divided down the middle by an interior segment. Think of a squared-off figure 8 or simply two squares stacked on one another. A point inside either square would surely be "inside" the polygon...

How to set up quadratic equation for a ray/sphere intersection?

I'm researching the math for a ray tracer, but I'm not following a transition that is made in just about every article I've read on the subject. This is what I have: Formula for a sphere: (X - Cx)^2 + (Y - Cy)^2 + (Z - Cz)^2 - R^2 = 0 Where R is the radius, C is the center, and X, Y, Z are all the points in the sphere. Formula for a ...

Matlab book on geometry and image processing

Hi everyone, Does anyone know an easy to understand geometry and image processing book that has source code in matlab? Thanks alot! ...

Transforming co-ordinates from a rectangle to a parallelogram

Hi all, I am stuck on a simple yet vexing problem with basic geometry. Too bad I don;t remember my high-school co-ordinate geometry and looking for some help. My problem is illustrated in this diagram: I am struggling with transforming a co-ordinate from the rectangle to a resized parallelogram. Any tips, pointers and/or code-examples...

Cross product function in matlab

Hi all, Can someone explain to me how to use the cross product function in matlab? An example, I have the following image with 6 fixed points on the cube, how to find the two other points of the cube? ...

radians translating radians to degrees

I notice that translating radians to degrees and vice versa is like translating a percentage to a whole number and vice versa. for example , to get 60 percent of 345 you do the following 60 * 345/100 to get 60 degrees in radians you do 60 * 3.14/180 There is a pattern there BUT. we use 100 to compare percentages to a numbe. so why ...

Boundary representation data structure

I've been reading about using the winged-edge data structure for storing a boundary representation. However, the linked site says that this is one of the oldest data structres for storing b-reps, are there newer better ones? Secondly, is there an implementation of this in C#? ...

Constructive solid geometry mesh

If I construct a shape using constructive solid geometry techniques, how can I construct a wireframe mesh for rendering? I'm aware of algorithms for directly rendering CSG shapes, but I want to convert it into a wireframe mesh just once so that I can render it "normally" To add a little more detail. Given a description of a shape such a...

How do I convert the 2 control points of a cubic curve to the single control point of a quadratic curve?

Having searched the web, I see various people in various forums alluding to approximating a cubic curve with a quadratic one. But I can't find the formula. What I want is this: input: startX, startY, control1X, control1Y, control2X, control2Y, endX, endY output: startX, startY, controlX, controlY, endX, endY Actually, since the starti...

Ask for resource about fast ray-tracing algorithm

Hi, All, First, I am sorry for this rough question, but I don't want to introduce too much details, so I just ask for related resource like articles, libraries or tips. My program need to do intensive computation of ray-triangle intersection (there are millions of rays and triangles), and my goal is to make it as fast as I can. What I...

points of an irregular shape flash

I have a grid that is dynamically drawn with the Graphics class. I have bricks that collectively make up pieces that need to snap into the grid. These pieces can be rotated by 90 degrees. Each time a piece is rotated I need to find the new points for the piece (an irregular shape) so I can calculate whether it is over an open square(s...

MATLAB: How to find the image of the line at infinity corresponding to a plane?

There is an image of two separated papers on the floor. How to find the image of the line at infinity corresponding to the plane of the floor? See the image at: (larger) Anyone has some idea on how to start with MATLAB? Thank you, ...

WPF 3D - rotate a model around it's own axes

Suppose I have a simple WPF 3D scene set up with a single rectangle rotated -45 degrees around the X axis like so: <Viewport3D> <Viewport3D.Camera> <PerspectiveCamera Position="0,0,4"/> </Viewport3D.Camera> <ModelVisual3D> <ModelVisual3D.Content> <DirectionalLight Color="White" Direction="-1,-1,-3...

Direction between 2 Latitude/Longitude points in C#

I have 2 coordinates in Lat Long format. How do I determine from Point A (eg New York 37.149472,-95.509544 ) the direction in degrees to point B (eg Toronto 40.714269,-74.005973) I'm looking for a value like "340 Degrees" In C# ...

Minimum area quadrilateral algorithm

There are a few algorithms around for finding the minimal bounding rectangle containing a given (convex) polygon. Does anybody know about an algorithm for finding the minimal-area bounding quadrilateral (any quadrilateral, not just rectangles)? I've searched the internet for several hours now, but while I found a few theoretical papers...

How to determine a point in a triangle?

Hi all Is there an easy way to determine if a point inside a triangle? It's 2D not 3D. Best Regards, ...

Determining whether a coordinate exists inside of a polygon

Hi all, I'm working on an open source tracking and geofence software application and am having a bit of difficulty figuring out the math for the geofencing. I need to determine whether or not a coordinate exists inside of a polygon. However, the tricky part is that the polygon has no set number of sides. I need to be able to calculate ...