# Different way to do 3d rotations?

Started by Wrathnut, Feb 09 2000 11:54 PM

11 replies to this topic

###
#1
Members - Reputation: **466**

Posted 09 February 2000 - 11:54 PM

I''ve been fooling around trying to learn linear algebra so I can understand transformations that do the rotations of an object, now I actually didn''t learn much about it yet.. the book I have is my physics teacher''s, it''s way old. But I got to thinking about it and thought I might be able to solve my problem with spherical coordinates. Anyway to make a long story short I threw together a simple program in java that handle rotating and object by sending it angles then just doing some simple conversions. Courtesy of some very easy to understand calc 2 stuff. My program worked with only one logical error that I am working on fixing. As far as I can tell if optimized there might also be a speed increase in calculations(but only if you have many objects being manipulated). Anyway I was just wondering has anyone ever tried making a 3d engine that performs rotations this way? It''s very very easy to understand doing it this way than to do the complex matrix math I''ve seen used commonly for rotations.

###
#3
Moderators - Reputation: **11272**

Posted 10 February 2000 - 03:25 AM

It sounds like you haven''t implemented rotations around arbitrary axises yet. In that case rotating by Matrices in normal rectangular coordinates is far superior in terms of performance as well as mathematical clarity. Translations by fixed rectangular amounts are also vaguely painful in spherical coordinates in terms of computation time.

###
#4
Members - Reputation: **122**

Posted 11 February 2000 - 04:44 AM

Sounds like you''re using a modified Control Cubes method. I read about the method first on Gamedev.net so the file will be lurking around somewhere. Basically, it uses rectangular co-ordinates but does away with much of the matrix math.

=> Arfa <=

=> Arfa <=

###
#5
Members - Reputation: **466**

Posted 11 February 2000 - 05:44 AM

no I''m not using quaternions, as far as I know.

**SiCrane**: Yeah I haven''t tried it using an abritrary axis.. Do you happen to know by chance how much of a loss I will take by diong the shperical coordinate conversion?**Afra**: do you happen to konw where that article is? I''ve heard people mention something about it when I was going through the post for like the last year or so but I''m not sure what''s about.. The post I read said that it was on gamasutra.com but I scoured that site and couldn''t find it.###
#6
Moderators - Reputation: **11272**

Posted 11 February 2000 - 07:04 AM

Translations require at least two sins and arcsins per point translated. For a simple object, say a cube, that''s 8 arcsins in a single translation. For rotation around an arbitrary axis, you translate the object to be rotated so that the axis passes through the origin, rotate and then translate back. All in all very computationally expensive in spherical. In matrix transformations, you apply the same transformation matrix to each point. In your spherical transformation you''d have to calculate the translations, rotations and retranslations separately for each point.

###
#7
Members - Reputation: **466**

Posted 12 February 2000 - 01:47 PM

True, but using lookup tables for sin and cos, make it only 2 arcsin per cyc(but I'm working on a workaround for that).. the rest is just multiplication and divisions... Which is the same as doing it with matices.... infact I think it might be close to the same about of work on the cpu, I guess I'll really have to compare code to be certain though.. the pocedure I used was to draw object in cartesian, convert to spherical and and the degree of the angles you wish to rotate and then convert back..

Edited by - Wrathnut on 2/12/00 7:52:37 PM

Edited by - Wrathnut on 2/12/00 7:52:37 PM

###
#8
Moderators - Reputation: **11272**

Posted 12 February 2000 - 02:00 PM

In order to keep it on the same order of magnitude for computation time you''ll need look-up tables for both the sins and arcsins. You''ll have problems with granularity in your tables, especially as you move farther away from the origin. Bottom line is that lookup tables aren''t accurate enough for the general case.

###
#10
Moderators - Reputation: **11272**

Posted 13 February 2000 - 08:18 AM

You don''t have to take my word for it. Just think what happens when you try to translate an object 1000 units away from the origin by 1 unit. You''ll need an angle of 0.05729 in your arcsin lookup. Even if you only do multiples of 0.05 that 7200 entries in your lookup table. Then consider that you won''t hit 0.05729 exactly, you''ll be off by 0.00729. You can solve that by interpolating between lookup table values, but then you''ve increased the time complexity of calculation again. The alternative is to increase the granularity of your table until it can handle the 0.057, in which case you''ll probably need a lookup table size of 360,000 entries. If your use 32bit values for your tables then that 1,440,000 bytes in your lookup table. Then you start really having troubles with cache misses, page faults, etc. And you''re still not as accurate as rectangular coordinates with matrix transforms.

###
#11
Members - Reputation: **466**

Posted 13 February 2000 - 11:28 AM

I take it you aren''t the type of guy to try to do something new or different? I am not trying to make a fully formed 3d engine with all of the bells and whistles... Just trying to get it to work (displaying and rotating objects correctly), and also becuase I enjoy trying to figure things out and see if they can be done in a different way. The problems you bring up I can think of addressing in several different ways off the top of my head but I''m not trying to prove anything here I just was wondering if anyone had done it before. ^_^

War doesn''t determine who is right, war determines who is left.

War doesn''t determine who is right, war determines who is left.

###
#12
Moderators - Reputation: **11272**

Posted 13 February 2000 - 11:58 AM

Actually, I am the kind of guy to try something new and different. I just do enough reading to know that what you''re doing isn''t really new, and I''m just letting you know what pitfalls await you. Using spherical for rotations *has* been done before. It''s just no one has made a full-scale 3d engine out if it, because of the issues I''ve mentioned. I''m not trying to stifle you or anything, as I said, don''t take my word for it, think things through for yourself.