Java-Gaming.org
 Featured games (81) games approved by the League of Dukes Games in Showcase (481) Games in Android Showcase (110) games submitted by our members Games in WIP (548) games currently in development
 News: Read the Java Gaming Resources, or peek at the official Java tutorials
Pages: [1]
 ignore  |  Print
 Basic Distance questions  (Read 1077 times) 0 Members and 1 Guest are viewing this topic.
Mojomonkey

Senior Member

ooh ooh eee eeee

 « Posted 2003-12-04 14:59:37 »

I am having trouble finding a couple equations.

The distance between a point and a triangle (defined by three points) and the distance between a ray and a triangle. I know, I know, I should know this, but I don't and I google is letting me down.

Don't send a man to do a monkey's work.
crystalsquid

Junior Member

... Boing ...

 « Reply #1 - Posted 2003-12-04 15:24:24 »

Distance between point (P) and tri is easy...

Take the face normal of the tri ( verts v1,v2,v3):

myVector n = (v2-v1).crossProduct( v3 - v1 );
n.normalize();

Then just take tha absolute dot product this with the vector from any tri point to the point in question:

float dist = fabs( n.dotProduct( P - v1 ) );

Distance from a line to a tri is much more complicated, I would google for effecient algorithms for it.

- Dom

Correction - On second thoughts, this won't do at all This just gives the distance from a plane. Sry... Ill look up the distance from a tri instead...

Ok... Its really not nice.
Heres a link to the theory:

http://www-compsci.swan.ac.uk/~csmark/PDFS/dist.pdf

Heres a link to some source that does it (not java):

http://xengine.sourceforge.net/docs/structXEngine_1_1Math_1_1DistanceAlgorithms_1_1DistancePointToTriangle.html

Hope this helps
Mojomonkey

Senior Member

ooh ooh eee eeee

 « Reply #2 - Posted 2003-12-04 18:49:06 »

God help me... thanks.

Don't send a man to do a monkey's work.
Pages: [1]
 ignore  |  Print

You cannot reply to this message, because it is very, very old.

 Add your game by posting it in the WIP section, or publish it in Showcase. The first screenshot will be displayed as a thumbnail.
 atombrot (26 views) 2014-08-19 09:29:53 Tekkerue (24 views) 2014-08-16 06:45:27 Tekkerue (23 views) 2014-08-16 06:22:17 Tekkerue (14 views) 2014-08-16 06:20:21 Tekkerue (22 views) 2014-08-16 06:12:11 Rayexar (60 views) 2014-08-11 02:49:23 BurntPizza (38 views) 2014-08-09 21:09:32 BurntPizza (30 views) 2014-08-08 02:01:56 Norakomi (37 views) 2014-08-06 19:49:38 BurntPizza (67 views) 2014-08-03 02:57:17
 Rayvolution 40x Riven 39x kevglass 35x BurntPizza 32x princec 23x Longor1996 17x SHC 16x Drenius 14x gouessej 12x Roquen 12x PandaMoniumHUN 11x ra4king 9x theagentd 7x HeroesGraveDev 7x trollwarrior1 6x thedanisaur 6x
 List of Learning Resources2014-08-16 10:40:00List of Learning Resources2014-08-05 19:33:27Resources for WIP games2014-08-01 16:20:17Resources for WIP games2014-08-01 16:19:50List of Learning Resources2014-07-31 16:29:50List of Learning Resources2014-07-31 16:26:06List of Learning Resources2014-07-31 11:54:12HotSpot Optionsby dleskov2014-07-08 01:59:08
 java-gaming.org is not responsible for the content posted by its members, including references to external websites, and other references that may or may not have a relation with our primarily gaming and game production oriented community. inquiries and complaints can be sent via email to the info‑account of the company managing the website of java‑gaming.org