JohnBolton

Members

5240

1372 Excellent

• Rank
Contributor
1. Game programmer Interview question

I hope everyone realizes (especially the OP) that people at the company that gives this test read these forums. I don't srikanthpv is likely to get this job.
2. Subtracting? Quaternion rotations

Quote:Original post by nuvem Another way to put it, is I'm trying to figure out how with unit quaternions, to take a rotation, lets call it R, and a set of composed rotations, C3*C2*C1, derive the rotation R1 such that R = C3*C2*C1*R1. Now that I look at it that way, it should be easy: R1 = R * C3-1 * C2-1 * C1-1 Thanks, looks like I just needed to explain the problem to someone else to see the solution :) Not quite. If R = C3*C2*C1*R1, then R1 = C1-1 * C2-1 * C3-1 * R. Order is important. Also, just to simplify things: if C = C3*C2*C1, then R = C*R1 and R1 = C-1*R and C-1 = C1-1 * C2-1 * C3-1
3. Euler's method for quaternions

That will work; however, the rotation speed that is representable by a quaternion is limited to +/-π (or +/-2π, I can't remember). You can't represent 10 radian/s with a quaternion, for example (unless you switch to different time units).
4. Subtracting? Quaternion rotations

It seems simple enough: qf = q3 * q2 * q1 nqf = q3 * q2 * nq1 nqf = q3 * q2 * q1 * q1-1 * nq1 nqf = qf * q1-1 * nq1 But it sounds like you already tried that, so I don't know. [Edited by - JohnBolton on March 11, 2008 7:47:53 PM]
5. What is the default orientation?

Codewise, the default orientation is usually "unrotated" (not the answer you are looking for). It is up to you to decide which way is "front" and which way is "up". I like to use the X axis as the direction for front and the Z axis for the direction of up. It works out better mathematically. Many projects just use whatever their modeling program uses as default. (front is the axis pointing out of the screen, and up is the axis pointing toward the top of the screen). Of course, different modeling programs have different default coordinate systems. Some projects use Z or -Z as front and Y as up, because then it matches the camera. As you can see there are many choices. Pick the one you like best.
6. [C++] Finding characters in a string

You can treat a string as an array of characters (well, it depends on the language), so just look at each character in the string one-at-a-time and see if it matches the input character. Yeah, like what Arjan B did.
7. game movement

The solution is to hide the windows cursor and draw your own. When the mouse coordinates go past the edge of the window, just keep drawing the cursor at the edge.

Whenever posting questions about errors, always post the exact text of the error. Otherwise, we can only guess at what might be wrong. Also, while posting relevant source code is also important, it would really help if you pointed out the location of the error. My guess is that drawDisk and drawCircle are the problem. Is it possible that they are in a namespace?
9. When moving object around it moves smoothly but with jaggies and refresh artifiacts

What you are experiencing is called "tearing". It is unavoidable if you are not synching with vertical retrace. I'm not sure why everything slows down when you turn on vsync. Are you moving things a fixed distance per frame or a fixed distance per second? When you turn on vsync, you may be slowing down the frame rate (to match the refresh rate) and if you are moving a fixed amount per frame that will also slow down movement. In that case, your movement should be based on time instead.
10. Downcasting problem - C++

Quote:Original post by Palidorflame ...Oh, the reason i'm using this instead of fstream is because at Full Sail, we are learning code optimization, and including fstream would add a lot of overhead stuff that wouldn't be needed or wanted in a large scale game. And we're building code that we'll use in projects to come, so i wanted to make the most speed-based menu system i could. Apparently, you haven't learned very much about optimization yet. Rule 1: Profile first. Rule 2: Optimize the algorithm before the code. My two favorite optimization (mis)quotes: "Premature optimization is the root of all evil." -- Donald Knuth "Optimization without measurement is a waste of time." -- David Joiner
11. Dealing with normals

Quote:Original post by FoxHunter2 I understand what you need inverse matrices for (reversing the transformations), but why is the transposed matrix necessary? Shouldn't my float3x3 work as well for this particular case where no rotation and shearing is applied? The reference that S1CA suggests explains everything, but here is the bottom line: the reason you need to compute the inverse transpose is that your transformation includes shearing. If a transform contains only rotation and translation then the inverse transpose is the same as the original (as far as normals are concerned), so you you don't have to do anything. If it contains uniform scaling, then you could remove the scaling and use the resulting matrix, or you could use the original and then normalize.
12. why use homogeneous coordinates?

Quote:Original post by staticVoid2 in the last matrix diagram - would the result vector not be: xA yB zC + wE zD ? In his example, [x y z w] is a row on the left. In your examples, the vector is a column on the right.
13. Do mathematicians understand Physics?

I am relieved. As I was reading the original post by Socratus, I was thinking to myself, If RSC_x were to respond to this post, surely the universe would explode! I can't imagine how the universe could survive postings by both of them in the same thread. Well, RSC_x responded (twice) and we are all still here, so I guess I was wrong.
14. C++ pass-by-reference and factory functions

Quote:Original post by leidegren I was thinking of something along the linevoid create_something( CSomething& something ) { something = *new CSomething(); something.x = 1; } int WINAPI WinMain( HINSTANCE, HINSTANCE, LPSTR, int ) { CSomething& something; create_something(something); return 0; } The big problem is that you can't assign a reference as if it is a pointer. This works better (but I would simply have the function return a pointer instead, or use a smart pointer as ToohrVyk wrote): void create_something( CSomething*& something ) { something = new CSomething(); something->x = 1; } int WINAPI WinMain( HINSTANCE, HINSTANCE, LPSTR, int ) { CSomething* something; create_something(something); delete something; return 0; }
15. Game engine or OpenGL

It is hard to say without any details, but I suggest you use Irrlicht at least once. Then you can decide if you think it is worth the effort.