Don't like ads? PRO users don't see any ads ;-)
Guest

Untitled

By: a guest on Mar 6th, 2012  |  syntax: C  |  size: 0.49 KB  |  hits: 16  |  expires: Never
download  |  raw  |  embed  |  report abuse  |  print
Text below is selected. Please press Ctrl+C to copy to your clipboard. (⌘+C on Mac)
  1.  
  2. //using float4, but really, it does this in 3f space. the last float is 1 (or 0).
  3. float4 findPlaneNormal3f(float4 pt1, float4 pt2, float4 pt3)
  4. {
  5.         float4 vec1 = pt2 - pt1;
  6.         float4 vec2 = pt3 - pt1;
  7.         float4 normal = cross(vec1, vec2);
  8.         return normalize(normal);
  9. }
  10.  
  11.  
  12. __kernel void test(
  13.         const __global float4* pt0,
  14.         const __global float4* pt1,
  15.         const __global float4* pt2,
  16.         __global float4* out
  17. ){
  18.         int i = get_global_id(0);
  19.        
  20.         out[i] = findPlaneNormal3f(pt0[i], pt1[i], pt2[i]);
  21. }