
Untitled
By: a guest on
Mar 6th, 2012 | syntax:
C | size: 0.49 KB | hits: 16 | expires: Never
//using float4, but really, it does this in 3f space. the last float is 1 (or 0).
float4 findPlaneNormal3f(float4 pt1, float4 pt2, float4 pt3)
{
float4 vec1 = pt2 - pt1;
float4 vec2 = pt3 - pt1;
float4 normal = cross(vec1, vec2);
return normalize(normal);
}
__kernel void test(
const __global float4* pt0,
const __global float4* pt1,
const __global float4* pt2,
__global float4* out
){
int i = get_global_id(0);
out[i] = findPlaneNormal3f(pt0[i], pt1[i], pt2[i]);
}