public float4 normalize( float4 _value ) { float InvLength = 1.0f / length( _value ); return _value * InvLength; }
public float4 mul( float4x4 a, float4 b ) { return new float4( b.x * a.m[0,0] + b.y * a.m[0,1] + b.z * a.m[0,2] + b.w * a.m[0,3], b.x * a.m[1,0] + b.y * a.m[1,1] + b.z * a.m[1,2] + b.w * a.m[1,3], b.x * a.m[2,0] + b.y * a.m[2,1] + b.z * a.m[2,2] + b.w * a.m[2,3], b.x * a.m[3,0] + b.y * a.m[3,1] + b.z * a.m[3,2] + b.w * a.m[3,3] ); }
public float length( float4 _value ) { return (float) Math.Sqrt( dot( _value, _value ) ); }
public float4 mul( float4 a, float4x4 b ) { return new float4( a.x * b.m[0,0] + a.y * b.m[1,0] + a.z * b.m[2,0] + a.w * b.m[3,0], a.x * b.m[0,1] + a.y * b.m[1,1] + a.z * b.m[2,1] + a.w * b.m[3,1], a.x * b.m[0,2] + a.y * b.m[1,2] + a.z * b.m[2,2] + a.w * b.m[3,2], a.x * b.m[0,3] + a.y * b.m[1,3] + a.z * b.m[2,3] + a.w * b.m[3,3] ); }
public float dot( float4 a, float4 b ) { return a.x*b.x + a.y*b.y + a.z*b.z + a.w*b.w; }