⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 outcode4.c

📁 [Game.Programming].Academic - Graphics Gems (6 books source code)
💻 C
字号:
/* Direct calculation of 4D outcodes, C code fragment *//* number of bits in a word */#define NUMBITS	   sizeof(long)*8/* get the integral form of a floating point number */#define v(x)	   *(long *) &(x)/* get the sign bit of an integer as a value 0 or 1 */#define s(x)	   (((unsigned long)(x)) >> (NUMBITS-1))/* get the absolute value of a floating point number in integral form */#define a(x)	   ((x) & ~(1 << (NUMBITS-1)))	iw = v(w);	abs_w = a(iw);	outcode = s(iw);	  /* 0 or 1 per w's sign */	ix = v(x);	diff = s(abs_w - a(ix));	t = s(ix) + 1;	outcode |= diff << t;	  /* 0, 2, or 4 or'd with outcode */	iy = v(y);	diff = s(abs_w - a(iy));	t = s(iy) + 3;	outcode |= diff << t;	  /* 0, 8, or 16 or'd with outcode */	iz = v(z);	diff = s(abs_w - a(iz));	t = s(iz) + 5;	outcode |= diff << t;	  /* 0, 32, or 64 or'd with outcode */

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -