geometry

How do I effectively calculate zoom scale?

I have a draggeable image contained within a box. You can zoom in and zoom out on the image in the box which will make the image larger or smaller but the box size remains the same. The box's height and width will vary as the browser is resized. The top and left values for the image will change as it is dragged around. I'm trying to kee...

Line and Line Segment intersection

How can I detect whether a line (direction d and -d from point p) and a line segment (between points p1 and p2) intersects in 2D? If they do, how can I get their intersection point. There are lots of example how to detect whether two line segments intersects but this should be even simpler case. I found this but I do not understand wha...

OpenGL GL_SELECT or manual collision detection?

Greetings all, As seen in the image I draw set of contours (polygons) as GL_LINE_STRIP. Now I want to select curve(polygon) under the mouse to delete,move..etc in 3D . I am wondering which method to use: 1.use OpenGL picking and selection. ( glRenderMode(GL_SELECT) ) 2.use manual collision detection , by using a pick-ray and che...

CGAL Newbie Question: Which segments intersect?

Hi, i'm having a set of segments (each defined with two points; 2D) and want to know for every segment x, how many other segments y1,..., yn are intersecting x. How would you do that efficiently in CGAL? I don't have any experience with the CGAL library and Computer Geometry at all. I just need an algorithm for doing the stuff mentione...

How to equidistant resample a line (or curve)?

I have a line l_1 given with a point series p_1,...,p_n. I now want a new line l_2 having k points: q_1,...,q_k. But for all i \in {1,...,k-1}: abs( q_i - q_i+1 ) = const, meaning the segments of l_2 are equidistant or uniform. k >= 2 and p_1 and p_n should be in l_2. abs( p_i - p_i+1 ) not const One solution is to approximate a line...

Finding points on a rectangle at a given angle

I'm trying to draw a gradient in a rectangle object, with a given angle (Theta), where the ends of the gradient are touching the perimeter of the rectangle. I thought that using tangent would work, but I'm having trouble getting the kinks out. Is there an easy algorithm that I am just missing? End Result So, this is going to be a fu...

Geometry shader - Point to triangle strip not maintaining world position

I am just messing around with some geometry shaders taking a list of GL_POINTS and outputting a box with triangle strips. i have it basically working but when i zoom in/out or pan around the triangle strips go all over the place and do not maintain their posistion in the world but are still correctly drawing the box. for example if i g...

Retrieve set of rectangles containing a specified point

I can't figure out how to implement this in a performing way, so I decided to ask you guys. I have a list of rectangles - actually atm only squares, but I might have to migrate to rectangles later, so let's stick to them and keep it a bit more general - in a 2 dimensional space. Each rectangle is specified by two points, rectangles can ...

Java 1.5 Issue with drawing shape using lines and angles

Hey, I'm trying to write a method that takes a starting Cartesian coordinate(x,y) an angle (in degrees), a length and a number of sides and draws a shape to an applet. So far this is what I have but, I cant figure out what I'm doing wrong. I plan on using line transformations for the actual angle change and that's not written in yet but ...