27th June 2003, 18:03  #1 
Member
Join Date: Jun 2003
Posts: 93

new method of doing 3d rotation
As far as I know this hasn't been discovered before. I found a new way to do 3d rotation that runs a little faster than the usual method. I attatched two SSCs, one that uses old method and one that uses new method, and both are the same otherwise i think. n=10000. The new one runs 5 fps faster on my comp than the old one. This should work for DMs as well. This is how it works:
code: I know it's only a small performance boost, but 3d rotation is used in so many presets that I think it's worthwhile. There may be more ways to optimize this method, but I'm too happy about my neat new method to care right now. 
27th June 2003, 18:12  #2 
Forum King

afaik that's just a slightly compiled version of the normal rotation matrices w/calculations done in per frame  but i don't like it for two reasons: it's hard to read/understand by eyeballing it, and it's much harder to tweak than regular rotation matrices. good job with it tho, never thought of trying to compile rotation matrices
"guilt is the cause of more disauders than history's most obscene marorders" E. E. Cummings 
27th June 2003, 18:21  #3 
Member
Join Date: Jun 2003
Posts: 93

yeah, that's exactly what it is.
Look here to see the math. Why would you ever want to tweak rotation matrices? They do what they're supposed to do already. And also, most people couldn't "read/understand by eyeballing" the other way either, so there's no real difference. But I guess that nobody cares about my wonderful new method 
27th June 2003, 18:34  #4 
Forum King
Join Date: Dec 2002
Location: Manchester
Posts: 6,470

Just a slight optimisation
code: 
27th June 2003, 18:57  #5 
Member
Join Date: Jun 2003
Posts: 93

Yes, I thought of that, but isn't it too many variables for too little improvement? 6 variables used and just 23 sin() or cos() operations less per frame. But waaaiiit a minute...
code: Now there's the same number of variables as we began with. We make a great team raz. edit: one small mistake... 
27th June 2003, 19:05  #6 
Senior Member

Very interesting technique, especially after Raz's tweaks.

27th June 2003, 19:27  #7 
Forum King

Too bad we don't have the AVS source code. Then we could just replace the sin and cos functions with matrices that, although less accurate, would be much quicker. It wouldn't be difficult either. Just something like this:
float sin[360]; float cos[360]; for(int x=0;x<360;x++) { sin[x]=sin(x); cos[x]=cos(x); } and then when you say sin(1) it would actually multiply 1 by pi/180 to convert radians to degrees and then convert to an int an use that number as the matrix index. This would be much much quicker than the actual sin() and cos() are. Especially when there are 23 sin() and cos() calls per frame in an optimized version of that. 
27th June 2003, 19:44  #8 
Member
Join Date: Jun 2003
Posts: 93

lol... take a look at this... I do all that work programming the new method, and now I find that there's another, newer method that is slightly more optimized
Here it is: code: Unfortunately, it actually turned out a tiny bit slower than the method posted earlier, and it's a lot more complicated. But if anyone can find more ways to optimize though then it might end up being better. anubis: I think it would be better to keep the real sin and cos and then provide sin2 and cos2 that do what you say. Then people could pick and choose weather they want accuracy or speed. But this belongs in wishlist, not in this topic. And there aren't 26 sin and cos calls in the optimized version, there's 26 less than in the original... I didn't know that sin and cos were big hits on the performance. Last edited by 13373571; 27th June 2003 at 22:00. 
28th June 2003, 00:57  #9 
Forum King

sin and cos both take a lot of processing power to compute. I'm not sure exactly how much that optimization would work, but I know it does help a good bit as I've seen it done in many opensource video games.


Thread Tools  Search this Thread 
Display Modes  

