geometry

How to calculate the Rect of a row of N boxes filling up a length L with S space between them

This problem must have been solved a million times, but Google has not been my friend. I need to programmatically space a set of boxes to fill a certain length and be separated by a certain distance. This is what I want: Here is what I'm getting: Since I'm working in Objective-C using Core Graphics, I need a series of Rects that...

How do I determine which cuboids a point is in without iterating over them all?

I have a number of cuboids whose positions and sizes are given with minimum and maximum x, y and z co-ordinates (so they are parallel to the main axes). e.g. I might have the following 3 cuboids: 10.5 <= x <= 39.4, 90.73 <= y <= 110.2, 90.23 <= z <= 95.87 20.1 <= x <= 30.05, 9.4 <= y <= 37.6, 0.1 <= z <= 91.2 10.2 <= x <= 10.3, ...

How to determine if a list of polygon points are in clockwise order?

Having a list of points, how do I find if they are in clockwise order? For example: point[0] = (5,0) point[1] = (6,4) point[2] = (4,5) point[3] = (1,5) point[4] = (1,0) would say that it is anti-clockwise (counter-clockwise for some people). ...

2D geometry: how to check if a point is inside an angle

hello, i have the following geometrical issue in 2D: i have a point from which i cast an infinite angle (2D-cone) which is given by a direction and an angle. (the point and the direction form a vector and to each side half of the angle forms the 2D-cone) now i want to check if another point in 2D is inside this cone or outside. how c...

Removing Geometry from Canvas

I want to remove geometry from canvas in Silverlight... I am able to remove it but removal is not immediately reflected. I mean when I perform GeometryGroup.Children.Remove(geometry) it is removing from tree but not from Canvas... Surprisingly removed geometry is still visible in the Canvas until I perform some mouse action. Can anyone ...

Converting from longitude\latitude to Cartesian coordinates

I have a earth coordinates given as longitude and latitude (WSG-84). How you i convert them to Cartesian coordinates (x,y,z) with the origin at the center of the earth? ...

Perpendicular line in lat/long

Hi! I am trying to implement the equations presented here regarding finding a point on a given perpendicular distance from a line. Unfortunately the lines I receive are not straight. Is this due to me mixing Lat/long with regular x/y coordinates or have I done something else wrong?! double distPoint = 0.02; doub...

How to find overlapped items?

Dear all, Is it possible to find out whether one drawing line (which is not in a horizontal or vertical position) overlapped (or touched) any other items (like line, rectangle, circle etc). Kindly advise me on the possibilities and solution with examples. Thanks for looking into this... ...

proportions of a perspective-deformed rectangle

Given a 2d picture of a rectangle distorted by perspective: I know that the shape was originally a rectangle, but I do not know its original size. If I know the pixel coordinates of the corners in this picture, how can I calculate the original proportions, i.e. the quotient ( width / height ) of the rectangle? (background: the goal ...

fast algorithm for drawing filled circles?

I am using Bresenham's circle algorithm for fast circle drawing. However, I also want to (at the request of the user) draw a filled circle. Is there a fast and efficient way of doing this? Something along the same lines of Bresenham? The language I am using is C. ...

How to calculate an angle from three points?

Lets say you have this: P1 = (x=2, y=50) P2 = (x=9, y=40) P3 = (x=5, y=20) Assume that P1 is the center point of a circle. It is always the same. I want the angle that is made up by P2 and P3, or in other words the angle that is next to P1. The inner angle to be precise. It will be always a sharp angle, so less than -90 degrees. I tho...

Check if a point is in a rotated rectangle (C#)

Hello. I have a program in C# (Windows Forms) which draws some rectangles on a picturebox. They can be drawn at an angle too (rotated). I know each of the rectangles' start point (upper-left corner), their size(width+height) and their angle. Because of the rotation, the start point is not necessarely the upper-left corner, but that does...

How do I calculate the normal vector of a line segment?

Suppose I have a line segment going from (x1,y1) to (x2,y2). How do I calculate the normal vector perpendicular to the line? I can find lots of stuff about doing this for planes in 3D, but no 2D stuff. Please go easy on the maths (links to worked examples, diagrams or algorithms are welcome), I'm a programmer more than I'm a mathematic...

Calculating Coords of a point Perpendicular to a Line, Calculating Coords of Third Point in Angle Given Two Points and Angle

I actually have two questions, I found the answer to the second and didn't update the diagram. I'm not actually sure if these are possible, they really stumped me. Question 1: Given point A and e, the angle of the line A is on relative to the x-axis where 0<=e<360 degrees, how do you calculate the coordinates of B? BA is perpendicular...

Simple calculations for working with lat/lon + km distance?

Is there a simple calculation I can do which will convert km into a value which I can add to a lat or lon float to calculate a bounding box for searches? It doesn't need to be completely accurate. For instance: if I were given a lat/lon for London, England (51.5001524, -0.1262362) and I wanted calculate what the lat would be 25km east/w...

Python standard module for emulating geometric points

Is there a standard class in Python to emulate a geometric point that includes coordinates and a value, including arithmetic operations between the coordinates? ...

blackberry - java - 2D geometry and collision package

My current problem is not so much a blackberry issue as it is a java package issue. In the application I have a rectangular region. This region is rotated by about 30%. I need to accomplish two things: when a user clicks, is he inside the region? when a user draws a straight line on the screen, does any part of tha...

IsPointInsideSegment(pt, line) in Python

Is there a nice way to determine if a point lies within a 3D line segment? I know there are algorithms that determine the distance between a point and line segment, but I'm wondering if there's something more compact or efficient. ...

GIS: line_locate_point() in Python

I'm pretty much a beginner when it comes to GIS, but I think I understand the basics - it doesn't seem to hard. But: All these acronyms and different libraries, GEOS, GDAL, PROJ, PCL, Shaply, OpenGEO, OGR, OGC, OWS and what not, each seemingly depending on any number of others, is slightly overwhelming me. Here's what I would like to do...

Calculate minimum area rectangle for a polygon

I have a need to calculate the minimum area rectangle (smallest possible rectangle) around the polygon. The only input i have is the number of points in polygon. soryy for the incomplete information . Yes i have the co-ordinates of the points also Thanks ...