homeGeek CultureWebstoreeCards!Forums!Joy of Tech!AY2K!webcam

Forum Home Post A Reply

my profile | directory login | | search | faq | forum home

» The Geek Culture Forums! » Techno-Talking » Math-a-holics and Code Junkies » Software 3D projection (or yay I actually get maths for once) » Post A Reply

Post A Reply
Login Name:
Password (max 13 characters):
Message Icon: Icon 1     Icon 2     Icon 3     Icon 4     Icon 5     Icon 6     Icon 7    
Icon 8     Icon 9     Icon 10     Icon 11     Icon 12     Icon 13     Icon 14    

HTML is not enabled.
UBB Code™ is enabled.


Instant Graemlins Instant UBB Code™
Smile   Frown   Embarrassed   Big Grin   Wink   Razz  
Cool   Roll Eyes   Mad   Eek!   Confused   Happytears  
blush   Beard of Peter Gabriel!   crazy   tired   ohwell   evil  
shake head   cry baby   hearts   weep   devil wand   thumbsup  
thumbsdown   Geek   Applause   Angel   Envy    
Insert URL Hyperlink - UBB Code™   Insert Email Address - UBB Code™
Bold - UBB Code™   Italics - UBB Code™
Quote - UBB Code™   Code Tag - UBB Code™
List Start - UBB Code™   List Item - UBB Code™
List End - UBB Code™   Image - UBB Code™

What is UBB Code™?

Disable Graemlins in this post.


T O P I C     R E V I E W
Member # 4481
 - posted November 05, 2005 17:03
I've been learning about how 3D graphics works. I was really surprised when I found out what the basic projection equation was x' = x / z y' = y / z with some scaling in there depending on your co-ordinate system.

I always thought it was really really complicated. Has anyone else notice how cirtain feilds of computer programming are some how mystified and made to seem much more difficult than they really are?

So now i'm trying to do some basic wireframe 3D graphics in software.

I was getting some very strange results and then i realised I was casting floats to int. Something tells me this will not work in C++.
I get really nutty co-ordinate values like
-41890284323, etc.

After all ages of being forced to program in java has made me forget how to do basic things like rounding in C++.

But it's nice to actually understand some maths for once. I failed maths all through school, so I always feel really good when i actually get something mathematical.
The Famous Druid
Member # 1769
 - posted November 05, 2005 20:28
You've missed something, first you have to transform the x,y,z co-ordinates for the observers point-of-view. This involves applying some matrix calculations with sin() and cos() scattered seemingly at random, if memory serves (haven't done any of this in a very long time).

[edit] us usual, wikipedia has some useful info.
Member # 4481
 - posted November 06, 2005 02:07
I did all that.. and yes wikipedia has lots of useful info about geometry and matrix algebra for those of us who can never remeber our maths.

it was only the final step that i was never able to figure out.. I was looking for something too complicated as usual.

I'm only drawing cubes at the moment as testing.
But I end up having to scale my points by the size i want (i start off with a vector of points for a cube 1.0f across) by multiplying by a scaling matrix, then rotate by an angle for the way they should face (i increment this in a wrap around fashion so it looks like they're spinning around), then scale by the distance away the viewpoint is supposed to be (another matrix multiply), then finally rotate all the points by another rotation matrix (this time x,y and z axies) from the camera angle. I can see why games take so much CPU now. I know this isn't actually the way it works, but at least i'm learning what it's all about.
The Famous Druid
Member # 1769
 - posted November 06, 2005 11:43
Originally posted by serishema:
it was only the final step that i was never able to figure out.. I was looking for something too complicated as usual.

True story:

That last step could be expressed in English as "twice as far away looks half as big" and I once spent half an afternoon trying unsuccessfully to convince a workmate that it's the right way to scale for distance. Drew little diagrams, talked about 'similar triangles', the works, he still preferred his far more complicated method. These days, of course, I'd just point to the wikipedia page, but this was pre-internet (or at least pre widely available internet).
Member # 4481
 - posted November 06, 2005 23:52
I think us geeks always go for complicated in preference to simple. It's a fault we all have.

I once spent ages looking for a problem on my home network, trying everything i could possibly think of until finally noticing all the lights on the switch front panel were on, even the ones for ports that weren't being used.

Then it dawned on me, the switch had failed.
Member # 2814
 - posted November 07, 2005 06:11
sprintf() would be good for rounding, btw.
Member # 4481
 - posted November 11, 2005 19:33
I don't see how, I want to round a floating point value to an integer value

Contact Us | Geek Culture Home Page

© 2018 Geek Culture

Powered by Infopop Corporation
UBB.classicTM 6.4.0

homeGeek CultureWebstoreeCards!Forums!Joy of Tech!AY2K!webcam