geometry

Define a function for a circle caps the end of a line segment.

I need a function that returns points on a circle in three dimensions. The circle should "cap" a line segment defined by points A and B and it's radius. each cap is perpendicular to the line segment. and centered at one of the endpoints. Here is a shitty diagram ...

Checking to see if 3 points are on the same line

Hi, I want to know a piece of a code which can actually tell me if 3 points in a 2D space are on the same line or not. A pseudocode is also sufficient but Python is better. Thanks ...

Plotting linear inequalities in Mathematica

Update: Incorporating suggestions below, here's the version I ended up using to plot feasible region of a system of linear inequalities (* Plots feasible region of a linear program in 3 variables, \ specified as cons[[1]]>=0,cons[[2]]>=0,... Each element of cons must \ be an expression of variables x,y,z only *) plotFeasible3D[cons_] ...

Merge (Boolean Union) rectangular regions with integer accuracy

Given any number of intersection, disjoint and touching rectangles, how to find the (multiple) outline polylines? Rectangles are defined in pixel coordinates so they have integer accuracy, but they may be thousands of units large. I really need numeric coordinates for the outlines, merging GDI regions won't do. I know I can simplify t...

Check whether a point(lat/long) is within a circle(Centre lat/long known)

Hi..I am trying to see if a given pair of (lat,long) will fall within a circular region. The centre of the circle is known (lat,long values) as well as the radius. The approcah I have used is: Calculate the distance between the centre and the given lat/long using Haversines formula. Formula: a = ( sin(delta_lat/2) )^2 + cos (vp_Curr...

SQL Server 2008 Geometry not working?

Hi There. I'm having an issue with SQL Server 2008 and the geometry functions. I'm trying to create non-overlapping shapes using the STDifference function... but it does not seem to be working 100% of the time. Here is all the sample code to demonstrate the issue. Anybody have any idea to make these non-overlapping polygons? (except ...

Finding Whether A Point is Within a Right-Angle Triangle

I've always wondered the easiest way to figure out whether or not a point lies within a triangle, or in this instance, a rectangle cut into half diagonally. Let's say I have a rectangle that is 64x64 pixels. With this rectangle, I want to return a TRUE value if a passed point is within the upper-left corner of the rectangle, and FALSE ...

Overlaying a 'dot' on to an image on click

Hi All, I am trying to write a simple program that lets me overlay a dot on top of an image when the image is clicked. I can save the X and Y data back to my database but then I will want to be able to call that information back at a later date and overlay the dots again via code unlike the first time when the user had to click the ima...

How To Slice a Simple Polygon with a Line

I have a simple polygon (convex or concave, but no holes) that I need to slice into parts with a line segment. I'm not sure how to actually determine how many polygons result after the slice, or how to group the vertices. Basic convex cases the always results in 2 sub-polygons are easy, but how would I deal with a complicated concave sh...

how to get coordinates of a polygon in OpenLayers

I have been looking for how to determine coordinates of the points which consist a polygon(feature) in OpenLayers. Let's say I have created a polygon like the one in this example. I need to know the points which consist the polygon, so I can save them somewhere. I bet it is an easy one. I just couldn't find anything, probably I don't k...

Triangularizing an arbitrary 4-Vertex Polygon

Here's a riddle for you. You have a polygon composed of exactly 4 vertices, call them v1, v2, v3, v4. They are given in any random order. How would you split these vertices into two sets, each defining a triangle, such that both triangles make up the polygon without overlap. The result should look like this: Triangle 1: v1, v2, v3 Tri...

Calculating the shortest distance(perpendicular distance) between a point and a line

Possible Duplicate: Shortest distance between a point and a line segment Hi, I have a point A, and a Line with two endpoint B,C. I want to know how I can calculate the shortest distance between point A and the line formed within B and C. Pseudo-code is enough. Though, Python is preferred. Thanks ...

Position N circles of different radii inside a larger circle without overlapping.

Given n circles with radii r1 ... rn, position them in such a way that no circles are overlapping and the bounding circle is of "small" radius. The program takes a list [r1, r2, ... rn] as input and outputs the centers of the circles. I ask for "small" because "minimum" radius converts it into a much more difficult problem (minimum ve...

How to determine if a vertical line segment intersects a circle?

This is a programming homework assignment, of which I have no qualms about doing it myself however I'm quite stuck on the geometry of it. I need to be able to determine the exact point of intersection given the center and radius of a circle and two end points of a vertical line segment, and since geometry isn't my forte I was hoping for...

Collision Handling for moving rectangles

Hi folks, in my Silverlight 3 application, I display a tree. A self made user control is used for the treenodes, the LineArrow object for the connections. After initial displaying the tree, I want the nodes to move by the following "physical properties" there is a gravitational force, that pulls the node down there is a force vector t...

Algorithm for maximizing coverage of rectangular area with scaling tiles

I have N scalable square tiles (buttons) that need to be placed inside of fixed sized rectangular surface (toolbox). I would like to present the buttons all at the same size. How could I solve for the optimal size of the tiles that would provide the largest area of the rectangular surface being covered by tiles. ...

Volume of a B-rep?

I would like to know how to calculate the volume of a solid object that is represented by Boundary representation (B-Rep)? Any hints? Thanks in advance ...

Shape detection EMGU

Hi i need further assistance. I followed the tutorial on shape detection however when i execute the program, i get the above. For the detected cicrles i have no idea why it look like that may i know what is wrong over here? ...

WPF 3D - mapping gradient brush on complex geometry

Hello, I wanted to ask if anyone knows how to map gradient brush on complex objects in WPF 3D. The result should look similar to 3D images in matlab (3D function for example). Lets say you have some 3-dimensional data you wish to visualize and you want to diferentiate certain levels of values by color. ...

How do I rotate vectors using matrices in Processing ?

I am trying to rotate vectors using matrices, but got confused. I thought all I needed to do is create a rotation matrix and multiply it to a vector to get the rotated vector. Here you can see a simple test I've done using Processing: Use a to increment rotation, and x/y/z to changes the axis. And here is source: PVector[] clone,f...