Re: [Algorithms] How to get 3dvector largest coordinate index?
Brought to you by:
vexxed72
From: Matt J <mjo...@gm...> - 2009-03-01 17:20:13
|
I think you still need the absolute value 1. x = -10 and y = -5 2. x = 10 and y = 5 Both cases x is the largest component, but only in the first case is y > x What's about something like: > yx = SignBit(x-y)>>31 // 1 if y > x > yz = SignBit(z-y)>>31 > zx = SignBit(x-z)>>31 > zy = SignBit(y-z)>>31 > return (yx&yz) | ((zx&zy)<<1); > > 4 subs (int or float, doesn't matter), a few simple bit instructions, no > jump (untested, just got back from a diner)? > |