# Eric_Brown

Member

46

127 Neutral

• Rank
Member
1. ## Determine current angle of rotation around vector

Captain, Yes, o is the position of the camera relative to the center of the sphere. When I say sphere space, I mean that the center of the sphere is the origin of this space, and the offset vector o is given relative to this origin. I would like to try and verify that I know what it is you are trying to do: From what I can tell, you are storing p and c, and using them to calculate o. You want to represent the location of the camera on the sphere by using a set of angles. You then use these angles to rotate o. Then you want to recalculate p using the rotated o. Is this correct?
2. ## Determine current angle of rotation around vector

Hey Cap'n I would avoid using sphereical coordinates to represent the position of the camera on the surface of a sphere. Rather, store the center of the sphere, and the current sphere offset vector. If the magnitude of the offset vector is fixed, then the position of the camera is always on the sphere p is the vector representing the world space position of the camera, c is the vector representing the world space center of the sphere, and o is the vector representing the sphere space position of the camera. This representation is especially simple if you want to have a smooth blend from the current sphere space position of the camera o to a new desired location od. The blend is done in two steps. The first step is: Where b is between 0 and 1 and determines the blend rate. If b is 0 then there is no blend. If b is 1 there is an instantaneous blend. The second step is: Which constrains the blended position to lie on the surface of the sphere. This blend is non-linear, but it is smooth. Also, changing the destination point before the blend is complete does not cause problems. Store this blended value as the new offset vector, and recalculate the world space position of the camera. Then find the lookat vector and so forth. Eric Brown
3. ## How to find sin, cos, and tan without a calculator. Does this answer exist???

Quote:Original post by Zipster Quote:Original post by alvaro Hmmm... That doesn't seem to add anything to the formula, except complexity. If you plug in a negative x in the usual formula, you'll get the correct result. It could be that in Euler's time there was a stylistic reason to prefer a formula that incorporates exp(ix) and exp(-ix). Even if you get the same result in the end, perhaps it's to clarify that the sign of 'x' only influences the terms involved with calculating 'sin' and not 'cos'. Or to hint at the effect of complex conjugation.
4. ## uncombining transformation matrix

What I've found is that matrix decomposition is useful when you need to output a particular transform to a human, such as in a debugging tool, or a game design tool. For this reason alone, having a good decomposition procedure is handy. Other than interfacing with humans, keep the transform in a more compact form, such as a 4x4 matrix, or as {scale vec, rotation quat, translate vec} which simplifies a lot of blending operations. If you aren't going to be doing a lot of blending, you should really just use matrices.
5. ## Differentiation & Integration

marcus, I think I felt a similar confusion when I first started delving into the world of computational physics simulation. My confusion came from the fact that the process was called "integration", but the method of integration seemed more like taking a derivative. For instance, you give an example of a differentiation: Quote: Differentiation - (I understand)It gives rate of change, eg: ball is moving then to get new position at time 't' ( ds/dt = dv) we do like .. present_position = old_position + dv * dt; but the expression "present_position = old_position + dv * dt" would actually be termed integration. When you approximate calculus with finite differences, the operations of differentiantion and integration are encoded in the standard algebraic operations of addition, subtraction, multiplication and division. With this encoding, you can kind of think of a derivative as being associated with division, and an integral as being associated with multiplication. For example, the approximation of a derivative can be expressed like this Which incorporates a division. Integrating the previous equation amounts to multiplying both sides by Δt You can rearrange this expression to get the equation that you were referencing. So, in the end, even though they are basically the same relationship, if the equation is in this form it is a derivative. If the equation is in this form it is an integral. Once I came to grips with this, I overcame my confusion about terminology.

7. ## Camera with Angular Velocity or Angular Momentum

Bemba, did you get this working?
8. ## deterministic physics replay

One thing I've done before is construct a replay animation. It seems like it would take too much memory, but I've actually done this before using a little compression trick. For the animation you will need to be able to evaluate the position and orientation of several objects at every moment in time during the replay. Thus you will need to record these positions and orientations. You may also need to store the animation frame a particular character is on, or other stuff like that. You don't need to store a value for every frame, you just need to be able to determine a value at every frame. Only store data on particular frames, and linearly interpolate, or use cubic splines to get the frames in-between. That's a simple idea, but how do you decide which frames are keyframes, and which frames are not during the initial run of the simulation? Here is a simple trick. Always store the current state as a keyframe. After storing the current state as a keyframe, take a look at the last 3 keyframes. If you remove the second to last keyframe, how does the interpolated value compare to the real value? If it is below a pre-defined threshold, then you get rid of the second to last keyframe. It is possible to store your keyframes sequentially in an array, since when you are writing the array, you are only ever manipulating the last and second to last entries. This makes reading the keyframes much quicker. I can envision ways in which this scheme might fail, however, when I did it, I was able to get an excellent replay, with no visible error. My compression ratio was around %10, but in some cases it was much lower. I think I was replaying about 10-15 objects, some of them animated, some of them updated by physics. The keyframe structure stored the replay frame time, the position, the rotation quat, and the animation frame.
9. ## [C#] Platform game physics using integration. Is it possible?

One way to incorporate pre-canned motion into your dynamic simulation is to find the value of a that will move the character to the position where you know it should be. This is not what I recommend, however, since the character motion usually needs to be pretty deterministic. I've found that it is easier to just snap or blend the position of the character to the pre-canned location, then adjust the velocity to take into account the shift in position that you just introduced. When it is time to turn the pre-canned motion off, the dynamics will smoothly take over. The main disconnect between pre-canned animation and dynamic physics is that a pre-canned animation usually only updates the position. The dynamic physics needs the position AND the velocity to be updated.

11. ## Matrix interpolation method for Skeleton?

There are a few things that quaternions just do better than matrices - and interpolation is one of them. To the point, if inserting quaternions requires you to consider rewriting a lot of your animation code, you may want to consider the rewrite. As an alternative you may want to specify the keyframes using quaternions, and then once you have the interpolated result, immediately convert from a quaternion to a matrix. What is the initial form of the keyframe data? It surely isn't a matrix, is it? Most animation packages export animation curves as euler angles, or quaternions.
12. ## Camera with Angular Velocity or Angular Momentum

If all you are trying to get is a non-uniform blend from the start location to the finish location, try using a non-uniform blending parameter for your slerp. In effect, apply the acceleration to the blending parameter that you send into the slerp function. You can think of f(t) as a kind of blend velocity. If you want to start slow, and end fast, you can use a quadratic function If you want to start fast and end slow, you can use this function
13. ## 6 DOF Distance formula

Quote:Original post by alvaro On top of what Eric said: (1) Since q and -q represent the same orientation, you should take the absolute value of the dot product before you take the arccos. (2) You don't need to compute the expensive arccos at all if all you need to know is which of them is closest. The smallest angle will be the one with the highest cosine, so simply find the one that maximizes that. Agreed!
14. ## How to get an oblique projection matrix?

Quote:Original post by chiyuwang I want to project a 3D point x onto a plane (defined by a b c d) along a 3D direction v. It sounds to me like you might be trying to find the intersection of a ray with a plane. If this is the case, you don't want to search for stuff on projection matrices. Projection matrices are applicable to your problem, but it seems like the hard way to approach it. Instead, consider that you are sliding your point x in the direction of v. Eventually, you will hit the plane, and this is the point you are trying to find. Use the parameter t to represent the sliding point like this Now, you want to find the value of t so that the sliding point lies on the plane. The condition that the sliding coordinates are lying on the plane is given by inserting the definition of the sliding coordinates with respect to the parameter t gives Solving for t gives NOTE: if the denominator of t is zero, then the sliding point will never come into contact with the plane. Now, insert this value of t back into the equation of the sliding point to get the actual projected point.
15. ## 6 DOF Distance formula

Oh, I see. If all of the points are at the same position, then you only need to worry about the angular peice. Find the rotation matrix, or quaternion that represents the set of angles. I prefer quaternions. You construct the quaternion like this Here ψ is the yaw angle, θ is the pitch angle, and φ is the roll angle. Of course, these angles are given within their canonical ranges. If you have 2 quaternions that represent 2 different rotations, then you can always construct a single quaternion that will take you from one rotation to the other If you want to find the angle that this delta quaternion represents, you use the scalar part of Δq in the following formula. Note, that you don't have to perform a full blown quaternion multiply if you want to find the scalar part of Δ q. The scalar part of this product is just the 4D dot product of the two quaternions q1 and q2. It seems to me that what you are looking for is the set of coordinates that minimizes the angle α. I don't recommend using matrices to solve this problem, because it is more expensive all around. But if you were using matrices instead, you would find the delta matrix Then you would use the formula posted by Emergent [Edited by - Eric_Brown on April 1, 2010 11:38:44 AM]