Page 1 of 4

Rotation (sort of)

PostPosted: May 20, 2005 @ 9:35am
by Phantom

PostPosted: May 20, 2005 @ 2:00pm
by Dan East

PostPosted: May 20, 2005 @ 2:06pm
by Dan East

Re: Rotation (sort of)

PostPosted: May 20, 2005 @ 3:55pm
by Kak

PostPosted: May 20, 2005 @ 4:04pm
by Phantom

PostPosted: May 20, 2005 @ 7:40pm
by Kak

PostPosted: May 20, 2005 @ 10:25pm
by refractor

PostPosted: May 21, 2005 @ 12:44am
by Andy

PostPosted: May 21, 2005 @ 1:04am
by Kzinti

PostPosted: May 21, 2005 @ 1:22am
by Andy

PostPosted: May 21, 2005 @ 3:49am
by Tala

Re: Rotation (sort of)

PostPosted: May 23, 2005 @ 1:03am
by fdave

PostPosted: May 23, 2005 @ 12:27pm
by Phantom
Dave,

Correct me if I'm wrong, but I think your formula is not correct. If I feed it x=30, y=2, I get:

((2-30+16)&31)-16 = (-12&31)-16, which equals -4.

For x=2, y=30 I get:

((30-2+16)&31)-16 = (44&31)-16, which equals -4 (should have been 4).

This could probably be corrected by xor'ing the sign bit of the (x+y+16) part. That's pretty much what refractor does. Great solution! Mind if I use it in a game? :) I'm glad my instincts where right: It's branchless...

Tala: Also correct me if I'm wrong, but if x=30 and y=2, your formula gives -28 (should have been 4).

- Jacco.

PostPosted: May 23, 2005 @ 4:22pm
by Digby
Hi Jacco,

I'm curious, how many times are you calling this function per frame? If you're going to the trouble to worry about branches, is this bit of code a currently a bottleneck in your game?

For sake of discussion, let's say this code executed in one cycle - how much faster would it allow your game to run compared to the original implementation posted at the beginning of this thread? Would the user even notice it?

PostPosted: May 23, 2005 @ 6:28pm
by refractor