Face normals: recalculate each time or rotate?

Started by
18 comments, last by sBibi 19 years, 3 months ago
Quote:Original post by benryves
I cannot "learn" maths. I have a real mental block when it comes to it. I can add, subtract, multiply and divide and push the required buttons on a calculator - but don't ask me to do anything more advanced!


Well, you're going to need to learn sometime if you want to get anywhere far in 3D graphics, I'm not saying you have to learn from a book but you'll need to acquire the knowledge somehow. If that somehow means asking lots of questions on the GDNet forums then so be it, there will be plenty of people here who can help.

To answer your original question, yes, you can just rotate the normal. This is typically the way most APIs do things as well - the worst case is that the normal will be un-normalised if you've scaled it (when you look up matrix maths you'll understand how this might be possible) but obviously it's solvable by renormalising the vector.

-Mezz
Advertisement
I understand the maths in things such as how to normalise a vector, but it took me about a week and a half of pestering someone over IRC to work out how you performed a cross product! I'm just exceptionally stupid when it comes to maths, unfortunately.

[Website] [+++ Divide By Cucumber Error. Please Reinstall Universe And Reboot +++]

Quote:Original post by GameCat
Quote:Original post by Emmanuel Deloget
MxV (9 muls) is faster than U^V (3 muls) ? I'm pretty sure it is not the case :)


If you're talking about the cross product when using ^ (which is what you use to recalculate normals) then that generally requires six multiplies and three subtractions, not three muls. It also requires normalisation, though you need that with the matrix multiply as well if you allow non uniform scaling.


You are right, my bad (/me feel ashamed). Do you forget my stupidity if I give you teh caek?

Quote:Original post by benryves
I'm just exceptionally stupid when it comes to maths, unfortunately.


O_o

You should stop believing that math are hard. Just right now. And to beleive there is only two things in math:
A) definitions (as in: what is a dot product)
B) logic (as in: why the hell 1+1=2?)
Nothing else. If you are able to program then you should understand the logic. The only thing you have to do is to consider definitions as definitions.

When it comes to higher level math, the separation becomes clearer. You don't have to think about why matrices look like this. They do. You don't have to prove that the product of the inverse matrix and the matrix itself is the identity matrix, because you define the inverse matrix like this.

Math is not complex (well, some numbers are, but that's only a pun, and I know I don't have any sense of humour).

HTH,
Quote:Original post by Emmanuel Deloget
You should stop believing that math are hard.


I will stop doing that when I lever my marks up a bit. I got a C in Pure 3 and a C in Statistics 2 (unfortunately these didn't bring my overall grade down, I still got an A [sad]).

In terms of breaking it down, I wish my lecturers and/or supervisors would do that. I'm doing a hell of a lot of extra work in maths and getting absolutely nowhere.

The worst for me is anything that involves calculus. Especially when they throw in logarithms or trig functions.

[Website] [+++ Divide By Cucumber Error. Please Reinstall Universe And Reboot +++]

Yes, maths is hard. I don't make any bones about this, and neither would most people - that's why they don't teach linear algebra to 5 year olds! It took me ages when I first started to get to grips with vectors, matrices and all the other shit that comes with 3D programming. I spent quite a bit of money and time reading books or papers on the internet, only to find that they didn't really explain things in a way which helped me understand them (I also have a problem learning new things from books... it's ok when I have some background in the field as I do now, but when I started it was impossible).

I also did fairly poorly in the advanced modules at A level maths too, although I got an A overall. You don't need to be a god of the pure maths side of things for 3D programming, it's actually more oriented on physics, mechanics and spatial transformation stuff. Don't expect to be integrating the inverse logarithm of the hyperbolic cosine of x much in this field.

That said, if you have a big issue learning from books or whatever, I don't know where I can direct you to learn this stuff, all I can say is that after many books, papers and internet sites I only found one which explained it in a way I understood, and it was infact Brian Hook who recommended it.

Computer Graphics: Mathematical First Steps ISBN: 0135995728

I hate sounding corny, but maybe it'll help you the way it helped me :)

-Mezz
Yeah, it is hard. I'm like you Benryves. I have real trouble with math. Just about passed it at school with a grade C, BUT, discovered at college that learning math (or any subject for that matter) is about the quality of the teacher. I had a math teacher at college (Mr Newton was his name believe it or not) that had the ability to make the subject realtively easy to understand. Many years later I now face the same issue again. I want to improve my 3D programming, but the math just numbs my brain. Got to find the right teacher again! Learning this stuff from books and online docs just doesnt work for me either - and that approach is the longer, more drawn out one also. Saying that though, I might still pick up the book Mezz mentioned though :-) Keep at it man. There's plenty of us out here in the same boat, and places like gamedev.net are excellent for receiving help and support when trying to get your head around something!
Mezz, that book sounds interesting. Can you tell us the Index for it, what it covers? (couldnt find that info on Amazon)

Benryves: A matrix is just a "pack of information" that has information on how to rotate and translate a vector on all 3 axis.

Once you multiply you vector by a matrix, the vector is rotated and translated by the information stored on the matrix...

Another property of matrices is that you can multiply them together.

Imagine you have a set of vectors in 3D space, and you need to rotate/translate them a certain way (A), and then rotate/translate them in a diferent way (B).

You probably have matrices A and B. Instead of doing two separate operations on the vertices, all you do is:
N = A*B

...and you create the N matrix. The N matrix will store in itself the rotation/translation information of A AND B, and, therefore, when you pass your vertices through the N matrix, the result will be the same as if they had just passed by A & B.

Please ask more questions, place your doubts, we're here to help out.
Note that you actually need to multiply the normals by the inverse transpose of the matrix used to transform the model vertexes though in practice if all your matrix does is rotations and translations taking the inverse transpose of it is a no-op so you can use the matrix directly.
hey, can i see your

point3D rotatePointAboutAxisX(point3D p, double a) { }point3D rotatePointAboutAxisY(point3D p, double a) { }point3D rotatePointAboutAxisZ(point3D p, double a) { }


functions?

for my camera id actually prefer to do that than construct a yaw pitch and roll matrix and then extract the forward and right vectors... because frankly, thats a lot of multiplies, and wasted trig functions

edit: eh, maybe not such a good idea, because i need to rotate around the camera's axis, not the x,y,z (well the first rotation would be, but after that)

thanks
-Dan

[Edited by - Ademan555 on January 8, 2005 4:53:24 AM]
When General Patton died after World War 2 he went to the gates of Heaven to talk to St. Peter. The first thing he asked is if there were any Marines in heaven. St. Peter told him no, Marines are too rowdy for heaven. He then asked why Patton wanted to know. Patton told him he was sick of the Marines overshadowing the Army because they did more with less and were all hard-core sons of bitches. St. Peter reassured him there were no Marines so Patton went into Heaven. As he was checking out his new home he rounded a corner and saw someone in Marine Dress Blues. He ran back to St. Peter and yelled "You lied to me! There are Marines in heaven!" St. Peter said "Who him? That's just God. He wishes he were a Marine."
Quote:Quote:Original post by Emmanuel Deloget
Quote:MxV (9 muls) is faster than U^V (3 muls) ? I'm pretty sure it is not the case :)


If you're talking about the cross product when using ^ (which is what you use to recalculate normals) then that generally requires six multiplies and three subtractions, not three muls. It also requires normalisation, though you need that with the matrix multiply as well if you allow non uniform scaling.


apart from the fact that it requires 6 muls (and not 3 like a dot product), this would only work for face normals, if you want vertex normals, you need much more work than that, like adding together the face normals of all the faces touching that vertex, with a final renormalization required per vertex (6 muls and one div)
matrices are definitely better, and the only place where re-computing the normals might have a slight advantage would be special cases anyway...

This topic is closed to new replies.

Advertisement