|
Author
|
Topic: Oh, great programming gurus...
|
Kugelfang Pilot
|
posted 10-27- 03:55 PM
Can anyone provide me with an algorithm for determining the normal of a face? Preferably one that uses a variable number of vertices to define the face. Please? Pretty please?IP: Logged |
Bryan Russell Pilot
|
posted 10-28- 08:37 AM
You need to take the cross product of two vectors that are defined by two co-located edges. What you do is take one vector as vert 0 to vert 1, and the other as vert 0 to the last vert. they need to be vectors so 'move' the verts so that vert 0 is at 0,0,0.In case you need a cross product algo: code:
vec.v[x] = a.v[y]*b.v[z] - a.v[z]*b.v[y]; vec.v[y] = a.v[z]*b.v[x] - a.v[x]*b.v[z]; vec.v[z]= a.v[x]*b.v[y] - a.v[y]*b.v[x];
You will have to normalise the resulting vector, as the magnitude of the resulting cross product represents the area of a imaginary parrelellagram like shape, and is not nessaserily of normal length. I hope that helps, let me know if you want anything else. -bryan [This message has been edited by Bryan Russell (edited 10-28-2000).] IP: Logged |
Kugelfang Pilot
|
posted 10-28- 10:08 AM
Ouch! That makes my head hurt! But I'll study it and maybe eventually understand it enough to ask a question. Thanks.IP: Logged |
FarmerJoe Pilot
|
posted 10-29- 11:55 PM
Hey Bryan, long time no see, I was reading about some game engine programming. I got kinda stumped on recursive parsing. I understand that you want to get your "action" parsing in several passes. Is that still the case with these new processors? I mean back in the day I could understand using that method, but do programmers still use that method now? IP: Logged |
Mighty General
|
posted 10-30- 05:41 PM
Recursive vs iterative really has nothing to do with the processor. It's a high-level programming technique that can be used to reduce some problems to a very simple algorithm.The main drawback for a recursive algorithm is that it requires function calls, which tend to be slow on pretty much every mainstream processor. So if anything, newer processor make a recursive algorithm more appealing, since the processor may be fast enough to make up for the inherent inefficiencies. Any recursive algorithm can be rewritten as an iterative algorithm. Depending on what you can pre-compute, the iterative version will usually be faster, albeit maybe not as simple and elegant. I once wrote a program to decode fax images. The recursive version took four minutes for a page-sized image. The iterative version took 20 seconds. [This message has been edited by Mighty (edited 10-31-2000).] IP: Logged |
FarmerJoe Pilot
|
posted 10-30- 11:19 PM
Thank You Mighty! I need to find out more about algorithms do you have any references? "books not sites" =)------------------ So many things so little time FarmerJoe IP: Logged |
Mighty General
|
posted 10-31- 02:53 PM
Sorry, nothing jumps to mind. It's been forever since I took classes on that sort of thing. And I don't remember any of my early programming fundamentals textbooks being all that helpful, anyway. I learned the majority of my early programming skills from magazines and by reading the programming forums on Compuserve. Those were some very helpful people. There are helpful people in the newsgroups, but it takes awhile to learn who they are, amongst all the pompous idiots.IP: Logged |
FarmerJoe Pilot
|
posted 10-31- 07:25 PM
Thanks Mighty...Where would I start looking or should I say what should I do to start from the bottom and "learn" my way up on algorithms? Thanks!------------------ So many things so little time FarmerJoe IP: Logged |
DanW Pilot
|
posted 10-31- 07:52 PM
They are hammering recursion into our heads at school...using LISP. It's very CPU expensive like Mighty says. For instance, if you try to do Fibonacci numbers with recursion your order of computation grows exponentially, while with iteration its done in a few seconds.To me, understanding recursion is more difficult that using iteration. But LISP as a language (from what I have seen) is very well suited for using recursion. If anyone wants to translate this, then go ahead. It tells you if you what variables you have in a list using the syntax (+ 2 3) is the same as 2 + 3. It omits operators and allows or unary "-" as well. (define (vars f) (if (pair? f) (if (pair? (cddr f)) (union (vars (lhs f)) (vars (rhs f))) (vars (lhs f))) (if (symbol? f) (cons f '()) '())))
IP: Logged |
Mighty General
|
posted 11-01- 03:31 PM
FJ, I'm afraid I don't have any really good advice. I haven't been asked for that advice in quite awhile, so I haven't been keeping up with what's recommended for beginners.I do know that Learn Game Programming in 21 Days was recommended a lot a few years ago. Not all of the 21 Days books were very good, but I heard good things about that one. If you look around the comp.* newsgroups, say with Deja.com, I'll bet you can find lots of recommendations. Your question comes up every week or so. There's often someone there who has looked at the current books and gives their opinion. IP: Logged |
FarmerJoe Pilot
|
posted 11-02- 03:19 AM
Thanks Mighty!!!------------------ So many things so little time FarmerJoe IP: Logged |