3D Collision Detection
  In the last project, Condenado, the people ask me about the collision detection. Now Sorgo I.D. makes a universal function   to all programming language. In this document I explaining to your.
 All 3D objects are made by triangles, in this easy function your need input the triangles vertex and the vector origin                  and direction, the function returns the collision coordinates.
 Firs your need define on the function head the parameters that not are define in the body function, the parameters are:
 To input
  VO.x, VO.y, VO.z -Origin Vector Coordinates.
  VD.x, VD.y, VD.z  -Direction Vector Coordinates.

  VE1.x, VE1.y, VE1.z  -Triangle vertex coordinate.
  VE2.x, VE2.y, VE2.z  -Triangle vertex coordinate.               
  VE3.x, VE3.y, VE3.z  -Triangle vertex coordinate.           

 To output
  ve11.x, ve11.y, ve11.z  -To returns point collision values.

Collision Simple
. .
Collision multiple
The vector is only a infinite line section, is possible that the vector orientation across 2 or more triangles if your have multiple objects .The function only return the last coordinate intersection.

Remember ,to have a vector only needs a star position and a vector direction, the use possibilities are infinites.

. .
  The body function:

       R1,R2,R3,L1,L2,L3,LR,NL,TL // Define this variables to type FLOAT, for better  Precision.

       R1=((VE2.y - VE1.y)*(VE3.z - VE1.z)) ((VE2.z - VE1.z)*(VE3.y VE1.y))
       R2=((VE2.x - VE1.x)*(VE3.z - VE1.z)) ((VE2.z - VE1.z)*(VE3.x VE1.x))
       R3=((VE2.x - VE1.x)*(VE3.y - VE1.y)) ((VE2.y - VE1.y)*(VE3.x VE1.x))

       L1=(VD.x VO.x)
       L3=(VD.y VO.y)
       L3=(VD.z VO.z)

       LR=(R1*L1) (R2*L2) + (R3*L3)
       NL=(R1*(VO.x - VE1.x)) (R2*(VO.y VE1.y)) + (R3*(VO.z VE1.z))


       ve11.x=VO.x + TL*(L1)
       ve11.y=VO.y + TL*(L2)
       ve11.z=VO.z + TL*(L3)

  I hope you like this function .

by Necro