Posted to tcl by hypnotoad at Wed Jun 25 17:19:29 GMT 2014view pretty
odiemath_vectorxyz_lengthInvSqr f /Users/seandeelywoods/odie/sandbox/odielib/cmodules/math/generic/vectorxyz.c 0x7fa993447d20 153 0 65 101 136 { comment {/* * A - the vector to be tranformed * B - the affine tranformation matrix * R - a place to dump the result * * A and R MUST BE DIFFERENT */} definition {CTHULHU_INLINE double odiemath_vectorxyz_lengthInvSqr(VECTOR A); } body {{ double r=A[0]+A[1]+A[2]; if(abs(r)<__FLT_EPSILON__) { return NAN; } return (1.0/(A[0]*A[0]+A[1]*A[1]+A[2]*A[2])); }} } vectorxyz_method_length_inv_sqr fl /Users/seandeelywoods/odie/sandbox/odielib/cmodules/math/generic/vectorxyz.c 0x7fa993447d20 153 0 106 101 331 { comment {/* * A - the vector to be tranformed * B - the affine tranformation matrix * R - a place to dump the result * * A and R MUST BE DIFFERENT */} definition {static int vectorxyz_method_length_inv_sqr(void *pArg,Tcl_Interp *interp,int objc,Tcl_Obj *CONST objv[]); } body {{ MATOBJ *A; double result; if(objc != 2) { Tcl_WrongNumArgs( interp, 1, objv, "A" ); } A=Odie_GetMatrixFromTclObj(interp,objv[1],MATFORM_vectorxyz); if(!A) return TCL_ERROR; result=odiemath_vectorxyz_lengthInvSqr(A->matrix); Tcl_SetObjResult(interp,Tcl_NewDoubleObj(result)); return TCL_OK; }} } odiemath_vectorxyz_normalize f /Users/seandeelywoods/odie/sandbox/odielib/cmodules/math/generic/vectorxyz.c 0x7fa993447d20 153 0 63 101 214 { comment {/* * A - the vector to be tranformed * B - the affine tranformation matrix * R - a place to dump the result * * A and R MUST BE DIFFERENT */} definition {CTHULHU_INLINE void odiemath_vectorxyz_normalize(VectorXYZ A); } body {{ double d; double r=odiemath_vectorxyz_length(A); if(abs(r) < __FLT_EPSILON__) { A[0]=0.0; A[1]=0.0; A[3]=0.0; } else { d=1.0 / r; A[0]*=d; A[1]*=d; A[2]*=d; } }} }