]]>WOW thanks! it is a big project!

]]>This reminds me of problem I had while developing one of my semestral projects in C# - 3D graphics modeller/ray tracer (you can place basic primitives or loaded meshes into scene and move/rotate/scale with them ... also if you wanna try it, don't forget to add light object - bind material with emissivity to object). First of all - http://www.otte.cz/Moderu.tar.gz - here is the C# project and code ... it's quite large for semestral project (and don't worry if you're not at university yet, you don't have to make this large projects, I just wanted to do so), and it's really slow ray tracer (I didn't have time to optimize it - it was created over 2 weekends, while also I had to do projects in Haskell).

But to the point - there is a code to calculate line-to-line distance - and also picking axis to move the body in editor. Basically the problem is same as yours, you want to find line-to-line distance between a ray from camera position in direction of "mouse position" on screen, and each edge of triangle in which you're going to select an edge (e.g. probably triangle under your cursor, but you might also need to search it's neighbors). All the math is actually in the code - and I think it's also a bit commented (so you can find the stuff easily) + it's in C# and thats very descriptive language (oh a strong effect of C++ can be seen on the code, as I name stuff like in C++ - don't blame me for this please).

]]>are u doing a line selector in a modellng program? i think ive even asked this question before, that was why.

Yes, I'm trying to do a pick line on a triangle.

]]>Thanks Vilem Otte, but basically, I'm trying to figure out how I can tell if a point is on the edge (or the lines forming the triangle). Because if we view that triangle on the screen from far, it is small, but the lines forming the triangle is still a pixel size, so internally, the line is much bigger than if we view that trianglr full screen!

]]>are u doing a line selector in a modellng program? i think ive even asked this question before, that was why.

]]>Yep, there is...

For precise mathematical definition see wiki - http://en.wikipedia.org/wiki/Barycentric\\\_coordinate\\\_system\\\_(mathematics)#Barycentric_coordinates_on_triangles

- in short, barycentric coordinates for triangle are defined as 3 coordinates (U, V, W) where U + V + W = 1, and each represents unit-distance between our defined point and each point forming triangle (e.g. where U = 1 and V, W = 0, we're sitting on point A; V = 1 and U, W = 0 we're on point B, etc.).
Basically these coordinates are very important for interpolating values (this is important for pixel shading, of course I'll give a word about these in article I'm working on), for example they're needed for computing per-pixel normals or depth on pixel in triangle (+ only multiply and addition operations are needed when using these).

Also they're wide used in ray-triangle tests - basically you test whether point projected on triangle's plane along ray has coordinates between 0 and 1, and U + V + W = 1 (if any of the cases is wrong, then you haven't hit the triangle, otherwise you hit) ... plus you can actually use these right after for texture coordinate computation and such things.

]]>If there a way to know how far a point is from the closest edge on a triangle? Perhaps in 0..1 range?