geometry

How do I arbitrarily distort a textured polygon?

I'd like to write a program that lets me arbitrarily distort a textured polygon by dragging its vertices. I want the texture to distort fluidly and without overlap, assuming the new polygon doesn't intersect itself. I should also be able to repeat the process with the new shape, and with a minimum amount of loss. Are there any algorithm...

3d geometry: how to align an object to a vector

hello, i have an object in 3d space that i want to align according to a vector. i already got the Y-rotation out by doing an atan2 on the x and z component of the vector. but i would also like to have an X-rotation to make the object look downwards or upwards. imagine a plane that does it's pitch yaw roll, just without the roll. i am...

find if 4 points on a plane form a rectangle?

Can somebody please show me in C-style pseudocode how to write a function (represent the points however you like) that returns true if 4-points (args to the function) form a rectangle, and false otherwise? I came up with a solution that first tries to find 2 distinct pairs of points with equal x-value, then does this for the y-axis. Bu...

Find the biggest rectangular area consisting only of 2 types of letter in a given MxN board.

Possible duplicate: http://stackoverflow.com/questions/2301733 I need help with a problem. Given a MxN board represented with M letters (a-z) in each of the N lines, i have to find the biggest area in which there are only 2 types of letters in it. The area must have rectangular shape. Here's an example : 4x4: AAAA ABBC BBCA DCAA ...

Determine if a point resides inside a particular geometric region

Picture a circle. Now divide the circle vertically and horizontally into four regions. Take the top left region. If you drew a box around it, you'd have a box with a rounded corner heading east. Given an X and Y coordinate in that box of that single top left region, how can I tell whether a point is to the left of the circle's line, or ...

Find start and end XY coords of perpendicular line calculated from start and end XY coords of baseline

Using the following start and end point coordinate values of a baseline: X1 = 5296823.36 Y1 = 2542131.23 X2 = 5311334.21 Y2 = 2548768.66 I would like to calculate the start and end coordinates of a pendicular line that intersects the baseline at the mid-point. This intersecting, perpendicular line should extend at a given distance ei...

How do I extract surface normals (facade) at each pixel from google maps street view api?

In this google lat-long blog post ( http://google-latlong.blogspot.com/2009/06/introducing-smart-navigation-in-street.html ) they describe how they estimate the surface normal or facade orientation using 3D point clouds. Is there a way to extract/retrieve the surface normal at each pixel using the google street view api? ...

Draw curved path between two objects on a <Canvas/> in Silverlight

I am playing around with some stuff in Silverlight, and I am trying to dynamically draw a curved line between two other objects on a <Canvas/>. I tried doing something like this: public partial class MainNodeConnection : UserControl { private MainNode _sourceNode; public MainNode SourceNode { get...

GLSL check if fragment is on geometry

I am currently writing the positions of my geometry to the RGB channels of gl_FragColor and I would like to write 1.0 to the alpha channel if the fragment is part of geometry, and 0.0 if its empty. Is there a simple way to tell if a fragment is geometry or not? Maybe through gl_FragCoord.z? thanks ...

camera translation vector - relation to rotation matrix

I am working with some code which outputs a 3x3 rotation matrix and a translation vector representing a cameras orientation and location. However, the documentation states that to get the location of the camera one must multiply the transposed and inverted rotation matrix by the translation vector. Does that mean that the original vect...

Find unique vertices from a 'triangle-soup'

I am building a CAD-file converter on top of two libraries (Opencascade and DWF Toolkit). However, my question is plattform agnostic: Given: I have generated a mesh as a list of triangular faces form a model constructed through my application. Each Triangle is defined through three vertexes, which consist of three floats (x, y & z co...

Is there an easy way to detect line segment intersections?

This is a lot more complicated than it might seem at first. What I have is a giant array which consists of more arrays which contain points [in the form of an array "x,y"] like so: Array ( [0] => Array ( [0] => "0,9", [1] => "0,0", [2] => "9,0", [3] => "9,9", [4] => "0,9" ) [1] => ...

Writing .x files

Hi, I have a bunch of polygons that are generated by my program (i.e. I manually calculate the position vectors for the vertices). I want to dump these to a .x file (or .fbx or any format I could reload later with XNA). Is there any C# or XNA API for doing this? 10x! Yoyo ...

Creating a cylinder with axis centered differently

I know Matlab has a function called cylinder to create the points for a cylinder when number of points along the circumference, and the radius length. What if I don't want a unit cylinder, and also don't want it to center at the default axis (for example along z-axis)? What would be the easiest approach to create such a cylinder? Thanks ...

Is there any algorithm for calculating area of a shape given co-ordinates that define the shape ?

So I have some function that receives N random 2D points. Is there any algorithm to calculate area of the shape defined by the input points? ...

Distance from a point to a polyhedron or to a polygon

I have a surface which is a polyhedron and I want to find the minimal distance between it and a given point P. Since the polyhedron is defined by many polygons in a 3d space, one way that occurs to me is to compare the distance to each polygon and choose the shortest distance. Still I am not sure about it. ...

WPF, convert Path.DataProperty to Segment objects

I was wondering if there was a tool to convert a path data like "M 0 0 l 10 10" to it's equivalent line/curve segment code. Currently I'm using: string pathXaml = "<Path xmlns=\"http://schemas.microsoft.com/winfx/2006/xaml/presentation\" xmlns:x=\"http://schemas.microsoft.com/winfx/2006/xaml\" Data=\"M 0 0 l 10 10\"/>"; Path path = (Pa...

The Maths for 2D Collision Detection between an OBB and a Circle

I'm creating a 2D game and want to test for collision between an OBB (Oriented Bounding Box) and a Circle. I'm unsure of the maths and code to do this. I'm creating the game in c++ and opengl. ...

3D line plane intersection, with simple plane

hello, i have two points in 3D space which have X-coordinates with different signum. so one of them lies definitely on one side of the X-plane and one on the other. now i want to find the intersection of this plane and the line made up by the two points in the most simple and optimized way. i know how to do general line plane intersect...

Algorithm for 2D Interpolation

I have two shapes which are cross sections of a channel. I want to calculate the cross section of an intermediate point between the two defined points. What's the simplest (relatively simple?) algorithm to use in this situation? P.S.: I came across several algorithms like natural neighbor and poisson, which seemed complex. I'm looking f...