PDA

View Full Version : joining two points



fox
05-09-2001, 12:25 AM
Hi

I have a grid whereby I want to be able to select a point on that grid and then join it to another - what is the best way of tackling it - any code snippets/ ideas?

thanx

chennes
05-09-2001, 04:05 AM
Assuming that you know the coordinates of all of the grid points, the only way I can think of is to get the mouse-click location, transform it into your coordinate system, figure out which point they are nearest to, and start the line there. Etc.

Chris

fox
05-09-2001, 04:25 AM
any one have selection code for mouse hitting a pixel?

[This message has been edited by fox (edited 05-09-2001).]

billy
05-09-2001, 06:15 AM
Project your points from 3D space to 2D coordinates using gluproject. Then compute nearest point using a 2D distance.
di=sqr((xi^2+yi^2))

Select the point on the grid with smallest di to your mouse click.

fox
05-09-2001, 11:05 PM
Any code snippet?

cheers

Kilam Malik
05-10-2001, 04:55 AM
Originally posted by fox:
Any code snippet?

cheers

For the 2D-3D stuff (gluProject and gluUnproject) look at

http://www.opengl.org/discussion_boards/ubb/Forum2/HTML/002179.html

[This message has been edited by Kilam Malik (edited 05-10-2001).]