# Kuroyume0161

Members

60

100 Neutral

• Rank
Member

2. ## This site sucks!! I'm tired of trying to modify a post for hours... gfy

See what I mean? Fix it or shut down.

5. ## Transform arbitrary quadrangle into unit square

Already found a solution. Homography transforms was the correct direction - then on to collineation matrices and warps. Yes, this is a 2D problem. And code exists everywhere - if you only know what the heck you're trying to find! It shows up a lot in scanner/projector/image correction and manipulation sources. This link code works absolutely perfectly (even on triangles!!! - if you treat it as a quad with two identical points - which is what I actually want to do). http://code.google.com/p/wiimotetuio/source/browse/trunk/WiimoteTUIO/Warper.cs The projective transform (or affine in limited cases) was only one part of the puzzle. To do this correctly every time, it needs to be a properly inverted matrix from unit-square to quad that then does quad to unit-square (through the inversion). And the matrix multiplication of the points was not a simple transform matrix operation (as this isn't a transform matrix and 'w' is not always (0,0,1)). Once I understood the process and stopped evaluating the crappy incorrect code out there, proper code was found.
6. ## Transform arbitrary quadrangle into unit square

Quote:Original post by Dave Eberly The perspective mapping between two *convex* quadrilaterals is described in this 1-page document: Perspective Mapping. How would this relate to matrix transformation? As I stated, this must go both ways with an inversion of the quad-to-unitsquare after some processing. Thanks!
7. ## Transform arbitrary quadrangle into unit square

Quote:Original post by Emergent Can't always be done. Not all quads can be transformed by an affine transformation to a unit square. In fact, only parallelograms can... Of course, here I'm assuming you want to map a 2d quad to a 2d square. Do you actually want to infer perspective or something? Then you have more degrees of freedom... You assume correctly. :) A 3D quadrangle polygon has been transformed to the world center and 'placed' on the X-Z plane so that its y-values are 0.0f (essentially a 2D quadrangle). Now I want to matrix transform it to a unit square (on the same plane) for operations on geometry being placed on its surface (the geometry would be inverse transformed to fit the original quadrangle after the operations). I expect the polygon to be planar and convex (from polygonization by the supporting application). Code from Qt (QTransform::quadToSquare) is the type of transformation I think that I'm seeking but I cannot make it work (for hours!). It is using a 2D transform whereas I am limited to 3D transform matrices with an assumed (0,0,0,1) homogeneous vector. Their projective transform looks to be setting the homogeneous vector to (g, h, 1). I'm in the process of testing a self-made 2D transform using this code but am still a bit wary of the results. Thanks!
8. ## Transform arbitrary quadrangle into unit square

Fo some reason I cannot find any maths for this. It could be a projective transform or a UV mapping type transform but I know that what is required here is a transformation matrix since the mapping must go both ways (inverse as well). For any arbitrary planar quadrangle, how do you map it into a unit square with a transformation matrix? Thanks!
9. ## Seeking Lip-sync API or code/algorithms

Already 'seriously Googled'. Started with '3D lipsync algorithm' and went from there. I've also already gathered all of those papers. :) I find that interesting on a game development site. Lip-sync is widely used in gaming (Half-Life 2 etc.), some gaming boxes have custom lip-sync parts to their APIs, MS SAPI is mentioned quite frequently (but mine will need to be Windows and MacOS so that's out), and it is used extensively in 3D CG movies/animations (when not using facial motion capture specifically). You are correct; it is complicated technology. Thus the reason to seek as much information as possible. But before I go about 'purchasing' every paper out there that is remotely related to this subject, it'd be better to narrow it down just a bit (having been an IEEE/ACM member, I know the numbers of papers on any given topic - they could number in the hundreds or thousands!). Thanks,
10. ## Seeking Lip-sync API or code/algorithms

I am doing research for implementing a high-quality lip-sync plugin in a 3D CG application for animation with audio (thus, not posting in the Game forums). So far, the APIs/SDKs encountered have been monetarily prohibitive for a single developer like myself and in these times (see Annosoft for \$9500/year as a prime example). If there is one that is less costly supporting Windows and Mac in C++ for much less, links would be appreciated (haven't found one yet). Foregoing that if I must, then it'll be time to implement one myself. My background isn't strictly as a CG programmer and have no formal schooling, so it wasn't something that came up in my past (which would have been long before it was normal course material). This will be a cold start in developing a 3D lip-sync system. I'm looking for beefy information on quality lip-sync algorithms - not 'Joe's quick and dirty method'. My IEEE and ACM memberships/subscriptions have lapsed (again, thanks to the ever optimistic financial situation of late) so those resources have been barred except individual purchase of papers where possible. One book that is being considered is "Graphics Programming Methods" by Jeff Lander (who has a tutorial on lip-sync here iirc). "Stop Staring" by Jason Osipa is also under consideration but I haven't been able to determine if this is a programmers book or a users book yet (leaning towards 'users'). Basically, as part of the research stage, I am trying to gather as much useful, quality information as possible in various forms (papers, books, code, websites, etc.). It is a very complex field and the term 'lip-sync' intersects with many other non-related fields (lip-sync on DVDs/TVs, in other media formats, cartooning, and so on). Please, could anyone with previous experience please provide golden nuggets of where to find the best information? Thanks
11. ## Rotate an object given axis-angle given two vectors...

Unfortunately, the Vector class and its operators aren't mine - they are part of an existing SDK. What I found is that swapping v1 and v2 in the cross product (i.e.: v2%v1) removed an anomaly with creating the normal (you can do the math quickly to see what happens if the orthonormal vector is first). Very odd that. Subsequently, they were swapped in the VectorAngle() call. The swaps fixed the problems. Maybe it is a difference in the method/operator coding that requires this (?). Yes, I had previously tried the length*axis approach for the atan2() angle calculation. It may work now that this anomaly has been circumvented. Thank you very much, Robert
12. ## Rotate an object given axis-angle given two vectors...

I'm having a ball trying to get this to work. Here are the givens: There is a bone object which points down the +Z AXIS and is at the origin. I have a vector which describes where the bone should be pointing (relative to the origin). The obvious way to rotate the bone is to get the angle between two vectors. The one vector would be (0,0,1) for the bone and the other vector as given. Then I need to get the axis through which to rotate by angle. This would be the normal to the plane in which the two vectors lie. The code, as best I can find, is: Vector v1 = Vector(0.0f,0.0f,1.0f); Vector v2 = !epBB; // '!' normalizes vector operator Vector axis = v1%v2; // '%' is cross product operator Real angle = VectorAngle(v1, v2); // Angle between two vectors // Signed 3D angle between two vectors: atan2(dot(normal,cross(v1,v2)), dot(v1,v2)) Matrix bm; if (Abs(angle) < 0.00001f) bm = MatrixScale(Vector(epBBlen)); else bm = RotAxisToMatrix(!axis, angle) * MatrixScale(Vector(epBBlen)); This is failing in both angle AND axis. First, the cross product with an orthonormal vector is the same vector as the other with the one axis (1.0f) zeroed. So, v1 x v2 = (v2.x, v2.y, 0). That is useless - it isn't perpendicular to the plane containing them. What the f...? Maybe someone could illuminate how to go about doing this correctly? Thanks, Robert
13. ## problem with affine transformation

No. A matrix encodes a series of transformation operations, mainly scaling, rotation, and translation - sometimes reflection, shear, and other transformations are included. Think of it this way. You have a camera 'object'. If it isn't parented to anything, before you apply any transformations, it should be assumed that the camera origin is the same as the world system's origin (0,0,0), that lack of rotation (0d,0d,0d), say, has the lens face down the +Z axis (or whichever you decide), and that is has no scaling (1,1,1). The matrix that retains this untransformed camera is an identity matrix: 1 0 0 0 0 1 0 0 0 0 1 0 0 0 0 1 Okay. Now you want to have it moved and rotated (but not necessarily in that order). First, the basic order of a singular set of transformations (left to right) is Scales*Rotations*Translations (S*R*T). This isn't strict but is a good guide. Note that scaling and rotation occur while the camera is still at the world system's origin - where the camera origin is (0,0,0). In other words, at some point the camera must have a coordinate system and before any transformations it is usually coincident with the world system. If parented to another object, then the parent's coordinate system would be the initial one as reference. Either way, one normally wants to scale and rotate an object about its own center. This is exactly why scaling and rotation happen BEFORE translation. Translation moves the object with respect to ITS referential coordinate system. If you move the object and then rotate it, it is still being rotated from the origin - of the coordinate system, not the object's center. As already mentioned several times, the translation vector in a matrix is not the same as its position. You really shouldn't be applying a transformation matrix as a rotation-scale matrix and a position vector. Concatenate your transform operations in order and multiply the camera object's points or vectors by the resulting matrix.
14. ## Yet Again: Matrix from right-handed to left-handed system

Solved! :) First, the rotation order is indeed YXZ (yes!). Second, the input matrix is in right-handed, row-major format (see "3D Computer Graphics" by Alan Watts (pp. 4 & 5)). Most other sources use a column-major format so the rotation extraction routines (Eberly) needed to consider the transposition of matrix elements. Third, instead of negating the z rotation, obviously :sarcasm: you have to negate the x and y rotations. Finally, the matrix determinant is then needed to negate these in the opposite direction (a positive determinant, multiply by -1, a negative determinant, multiply by 1). I'm going to take a nap now! ;) See. Sometimes a similarity matrix or simple reflection matrix will NOT suffice to convert a matrix in one handed system to the other. The similarity matrix may suffice if the determinant is also applied (hmm) but the matrix decomposition with the fiddly bits allows confirmable value comparisons and more direct control of the conversion. You guys need to get your heads out of OpenGL and DirectX more often. There is a world of maddeningly subtle pain that awaits you.
15. ## Yet Again: Matrix from right-handed to left-handed system

I multiplied the input matrix with the identity matrix (with the one value negated as shown) trying both pre- and post-multiplication. Not doing it. This is pretty much the last-try idea that I had - apply a matrix with a negative z-scale to flip the axes. I might try a negative x-scale to see the results - but am not holding breath. All of these methods work here and there - but don't work on every case. So there is definitely something missing in the equation. Transposing the input matrix and applying a similarity matrix covered more cases - but still not all. And I think that this is because it flips all of the rotations. This won't work here. The only rotation needing flipping is the z-axis rotation. Unfortunately, there is no possibility of rectifying these matrices before input into the target application. Thanks for you input so far, yosh64! As can be seen by the stampede of assistance otherwise, nope, no brave mathematicians around (yes, I'm prodding). If I said "OpenGL to DirectX" there'd be fifty links and definite methods. Sorry, this isn't what I'm working with. The source application has its ways (which cannot be changed) and the target application has its ways - and its SDK doesn't consider things like right-to-left handed matrix conversion. Definitely not as deep and wide of breadth as these more generic graphics interfaces.