Path: chuka.playstation.co.uk!news From: "Craig Graham" Newsgroups: scee.yaroze.programming.3d_graphics Subject: Re: Rotation, ApplyMatrix Query (fairly long) Date: 25 Mar 1998 09:15:46 GMT Organization: PlayStation Net Yaroze (SCEE) Lines: 44 Message-ID: <01bd57cf$3c521120$72d449c2@Angela1.intelligent-group.com> References: <34F3EFA2.4CD2@127.0.0.1> <350F949B.93337AA2@immd9.informatik.uni-erlangen.de> <351131B3.FC7030EB@intelligent-group.com> <35125A99.CB324946@immd9.informatik.uni-erlangen.de> <35165600.B98FF682@intelligent-group.com> NNTP-Posting-Host: l114.mistral.co.uk X-Newsreader: Microsoft Internet News 4.70.1155 Been waffling about manhattan distance approximation (approximate length of a 3D vector), here's the code for it: short manhatan_distance(short a, short b, short c) { register short t; a=ABS(a); b=ABS(b); c=ABS(c); if(a b { t=a; a=b; b=t; } if(b c { t=b; b=c; c=t; } if(a b { t=a; a=b; b=t; } #ifdef FAST_BUT_LESS_ACCURATE t=a + (b>>2) + (c>>2); // faster (shift only, no multiply) #else t=a + ((11*b)>>5) + (c>>2); // more accurate but has an extra multiply #endif return t; } Craig