ulvis.paste.net - pastebin

Paste Search Dynamic
Recent pastes
verticies
  1. <?
  2.  
  3. $verticies =
  4. [
  5.     [0, 0, 0],
  6.     [1, 0, 0],
  7.     [1, 1, 1],
  8.     [0, 1, 1],
  9. ];  
  10.    
  11.  
  12. for ($i = 0; $i < count($verticies); $i++)
  13. {
  14.     //current vertex
  15.     $pi = $verticies[$i];
  16.  
  17.     //next vertex
  18.     $pj = $verticies[($i+1) % count($verticies)];
  19.  
  20.     //0 = x, 1 = y, 2 = z
  21.     $nx += ((($pi[2]) + ($pj[2])) * (($pj[1]) - ($pi[1])));
  22.     $ny += ((($pi[0]) + ($pj[0])) * (($pj[2]) - ($pi[2])));
  23.     $nz += ((($pi[1]) + ($pj[1])) * (($pj[0]) - ($pi[0])));
  24. }
  25.  
  26. echo $nx.', '.$ny.', '.$nz;
  27.  
  28. ?>
Parsed in 0.011 seconds