geometry

fast geometric proximity predicate

I have 3 points (A, B and X) and a distance (d). I need to make a function that tests if point X is closer than distance d to any point on the line segment AB. The question is firstly, is my solution correct and then to come up with a better (faster) solution. My first pass is as follows AX = X-A BX = X-B AB = A-B // closer than...

How to divide an area composed of small squares into bigger rectangles?

Where would i go to look for algorithms that take a 2d grid of values that are either 0 or 1 as input and then identifies all possible non-overlapping rectangles in it? In a more practical explanation: I am drawing a grid that is represented by a number of squares, and i wish to find a way to combine as many adjacent squares into rectan...

Help with trigonometry and circle geometry with JavaFX game

Im trying to get into some basic JavaFX game development and I'm getting confused with some circle maths. I have a circle at (x:250, y:250) with a radius of 50. My objective is to make a smaller circle to be placed on the circumference of the above circle based on the position of the mouse. Where Im getting confused is with the coordi...

how to build a free software to help students demonstrate in geometry with flow chart.

I studied computer engineering 10 years ago and i know all the basics of object programming. I didn't write any code for 5 years but actually I'm thinking to go back to this business for a specific need : Now I'm a mathematic teacher in a secondary school and i want to develop a little free software that help students to organize their ...

Applying Transforms to 3D models - Normals pb.

Hello, I'm trying to apply a transform to a 3D object in a STL File (without creating a structured mesh object). Here is how I proceed: I read the normals and faces information one by one in the STL file, apply my transform to each vertex and to the face normal and write back the new computed values in another STL file. The vertex are OK...

Recommended Books on Math for Game Development

It's been a few years since my computational geometry class in college, and I unfortunately sold my textbook (Computational Geometry in C), so now that I am writing a 2D video game, I am looking for books to give me a hand. What books are recommended that cover the geometry, math, and physics of 2D video game development? ...

How can I convert Geometry data into a Geography data in MS SQL Server 2008?

How can I convert some Geometry data into Geography data in MS SQL Server 2008? ...

Direct3D Geometry: Rotation Matrix from Two Vectors

Given two 3D vectors A and B, I need to derive a rotation matrix which rotates from A to B. This is what I came up with: Derive cosine from acos(A . B) Derive sine from asin(|A x B| / (|A| * |B|)) Use A x B as axis of rotation Use matrix given near the bottom of this page (axis angle) This works fine except for rotations of 0 (which...

Calculating a boundary around several linked rectangles.

Hi,I am working on a project where I need to create a boundary around a group of rectangles. Let's use this picture as an example of what I want to accomplish. EDIT: Couldn't get the image tag to work properly, so here is the full link: http://www.flickr.com/photos/21093416@N04/3029621742/ We have rectangles A and C who are linked by...

Finding the minimal coverage of an interval with subintervals

Suppose I have an interval (a,b), and a number of subintervals {(ai,bi)}i whose union is all of (a,b). Is there an efficient way to choose a minimal-cardinality subset of these subintervals which still covers (a,b)? ...

Best way to find a point on a circle closest to a given point

Hi, Given a point (pX, pY) and a circle with a known center (cX,cY) and radius (r), what is the shortest amount of code you can come up with to find the point on the circle closest to (pX, pY) ? I've got some code kind of working but it involves converting the circle to an equation of the form (x - cX)^2 + (y - cY)^2 = r^2 (where r is ...

Determine if two rectangles overlap each other?

Hi folks, I am trying to write a C++ program that takes the following inputs from the user to construct rectangles (between 2 and 5): height, width, x-pos, y-pos. All of these rectangles will exist parallel to the x and the y axis, that is all of their edges will have slopes of 0 or infinity. I've tried to implement what is mentioned i...

Simple way to interpolate between points in 3D space to form a smooth surface

I'm trying to come up with a simple and efficient way to create a smooth surface which intersects a number of given "sample" points. For any X,Y point on the surface, I identify up to 4 sample points in each of the 4 directions (the next higher and lower points on the X, and then the Y axes). Given this point, I want a way to compute a...

Greatest linear dimension 2d set of points

Given an ordered set of 2D pixel locations (adjacent or adjacent-diagonal) that form a complete path with no repeats, how do I determine the Greatest Linear Dimension of the polygon whose perimeter is that set of pixels? (where the GLD is the greatest linear distance of any pair of points in the set) For my purposes, the obvious O(n^2) ...

Microsoft.DirectX.Vector3.Normalize() inconsistency

Two ways to normalize a Vector3 object; by calling Vector3.Normalize() and the other by normalizing from scratch: class Tester { static Vector3 NormalizeVector(Vector3 v) { float l = v.Length(); return new Vector3(v.X / l, v.Y / l, v.Z / l); } public static void Main(string[] args) { Vector3 ...

How can you determine a point is between two other points on a line segment?

Let's say you have a two dimensional plane with 2 points (called a and b) on it represented by an x integer and a y integer for each point. How can you determine if another point c is on the line segment defined by a and b? I use python most, but examples in any language would be helpful. ...

Programming coordinates-based game, like dots or checkers

I'm looking to learn some fundamentals on cartesian geometry or coordinates based game programming. Platform is irrelevant, although I'm most proficient in JavaScript, C, Objective-C. Ultimately being able to create something such as dots or checkers would be ideal. The idea is for me to learn how sprites work and how pathing works progr...

How do you calculate the angle between two normals in glsl?

How do you calculate the angle between two normals in glsl? I am trying to add the fresnel effect to the outer edges of an object (combining that effect with phong shading), and I think that the angle is the only thing I am missing. Fragment Shader: varying vec3 N; varying vec3 v; void main(void) { v = vec3(gl_ModelViewMatrix * gl_V...

Stacking rectangles to into the most square-like arrangement possible

My Situation I have a N rectangles The rectangles all have the same shape (for example 2 inches wide x 1 inch tall) - Let's refer to this size as Sw and Sh for the width and height I want to position these rectangles in a grid such that the rects completely on top and next to each other - like what you would see in a spreadsheet What ...

What happened to the python bindings for CGAL?

I found the Computational Geometry Algorithms Library in my search for an algorithm to decompose a concave polygon into the minimum number of convex components. Links off the site and numerous google results indicate there are python bindings for it, which would be really handy, but all the links are dead! What happened to it? Where c...