Archived

This topic is now archived and is closed to further replies.

Different way to do 3d rotations?

This topic is 6547 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

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.

Share this post


Link to post
Share on other sites
Not sure if I really understand what it is that you''re doing, but it sound like you''re using quaternions. You can read about them in the resource section here at GameDev.net.

Share this post


Link to post
Share on other sites
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.

Share this post


Link to post
Share on other sites
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 <=

Share this post


Link to post
Share on other sites
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.

Share this post


Link to post
Share on other sites
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.

Share this post


Link to post
Share on other sites
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

Share this post


Link to post
Share on other sites
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.

Share this post


Link to post
Share on other sites
^_^ I''ll take your word SiCrane. I think I''m still going to play around with it till I get the DirectX docs figured though! heheh

Share this post


Link to post
Share on other sites
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.

Share this post


Link to post
Share on other sites
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.

Share this post


Link to post
Share on other sites
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.

Share this post


Link to post
Share on other sites