The distance between 2 triangles?
the distance between which parts of the triangles? each infinetesimally small part of each triangle is a different distance away from each infinetesimally small part of the other triangle.
if you mean just the center, it''s a simple distance formula:
distance = sqrt( (x2-x1)^2 + (y2-y1)^2 + (z2-z1)^2 );
if you mean the how far apart the triangles are at their closest point, i guess you''d have to do distance from a point to a plane equation which involves some linear algebra (look up "3d math tutorial" in google for a brief introduction and some equations).
dunno if that helps. can you be more specific?
-me
if you mean just the center, it''s a simple distance formula:
distance = sqrt( (x2-x1)^2 + (y2-y1)^2 + (z2-z1)^2 );
if you mean the how far apart the triangles are at their closest point, i guess you''d have to do distance from a point to a plane equation which involves some linear algebra (look up "3d math tutorial" in google for a brief introduction and some equations).
dunno if that helps. can you be more specific?
-me
I wrote an algorithm that does what you want -- it''s used in my triangle-triangle collision program. The function is triangle::Distance() in the file DataTypes.h. You can read a little about it at the top of Main.cpp.
The function is complicated, but it works -- I haven''t noticed any bugs yet.
~CGameProgrammer( );
-- Post screenshots of your projects. 100+ posts already in the archives.
The function is complicated, but it works -- I haven''t noticed any bugs yet.
~CGameProgrammer( );
-- Post screenshots of your projects. 100+ posts already in the archives.
this may be of use:
http://astronomy.swin.edu.au/~pbourke/geometry/linefacet/
if your ultimate goal is to determine if two triangles intersect.
http://astronomy.swin.edu.au/~pbourke/geometry/linefacet/
if your ultimate goal is to determine if two triangles intersect.
Yes, that''s what mine does -- return the minimum distance between the two triangles. It doesn''t return the points themselves but it returns the distance.
~CGameProgrammer( );
-- Post screenshots of your projects. 100+ posts already in the archives.
~CGameProgrammer( );
-- Post screenshots of your projects. 100+ posts already in the archives.
thank you, CGP
but what "Direction" means in
UINT Distance ( Type* Distance, plane* Plane, triangle Other, vector Direction )
?
i just want to know how to calculate the minimum distance between *stationary* triangles.
but what "Direction" means in
UINT Distance ( Type* Distance, plane* Plane, triangle Other, vector Direction )
?
i just want to know how to calculate the minimum distance between *stationary* triangles.
quote:Original post by gotton
thank you, CGP
but what "Direction" means in
UINT Distance ( Type* Distance, plane* Plane, triangle Other, vector Direction )
?
i just want to know how to calculate the minimum distance between *stationary* triangles.
Oh yeah, I forgot. Sorry. Then my code isn''t what you want.
~CGameProgrammer( );
-- Post screenshots of your projects. 100+ posts already in the archives.
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement