• Content count

  • Joined

  • Last visited

Community Reputation

427 Neutral

About someusername

  • Rank
  1. possible alternative to quaternions?

    Quote:Original post by Daerax Quote:Original post by someusername There... found it... "Of the four elements (of a quaternion) the turning operation depends upon three; two angles to fix the plane of rotation, and one angle to fix the amound of rotation in that plane. The stretching operation depends only upon the remaining one, i.e., upon the ratio of the vector lengths. A.S. Hardy "Elements of Quaternions" page 34 You have the author wrong, that book 'Elements of Quaternions', was written by Hamilton. I know of no A.S Hardy but I do know of G H Hardy, he was a historian of mathematics no? I urge you to attempt to describe a rotation using only a triple or 'vector'. As well you will need an angle. A triple or axis on its own will not describe rotations in 3 space. A quaternion is a much richer object than a triple. Consider how the complex number represents space - to multiply a couple you simply need their lengths and included angle. Attempt to extend this concept to 3 Space and you fail. This is because as well as the included angle you as well need to know on which plane you are turning about. Put simply, a 3 dimensional rotation depends on the angle of rotation and as well an axis. Obviously, you missed the title page. The author of this specific "Elements of quaternions" *is* A.S. Hardy, a professor of the 19th century.. Quite a few mathematicians wrote books on quaternions (since it was taking Hamilton so long to finish his own infamous "Elements of quaternions" -which he never did btw) although none of them published them prior to the publication of Hamilton's work, from respect to Hamilton's wish. (P.G. Tait, "An elementary treatise on quaternions", preface) As for the rotation/triple, it *is* possible to encode a rotation in 3 real numbers. As I already wrote in this thread, you can use e.g. 2 numbers for the latitude and longitude angles of the plane normal, and the other for the angle. Or -in classical mechanics- if you solve "L = I*ω" for ω (L angular momentum, I inertia tensor, ω angular velocity) what you get is a 3d vector whose direction represents the axis, and its magnitude the angle. Isn't this a 3d rotation encoded in 3 real numbers? I'm under the impression that a lot of people assume, that the fact that quaternions comprise 4 values, means that you need at least 4 values to represent any 3d rotation. This is wrong. You need 4 values because quaternions are not just rotations! They're an entire non-commutative algebra. Only they subgroup with norm==1 is isomorphic to the SO(3). Thinking of quaternions as rotations only, is wrong! Some of the most fundamental theorems of geometry and stereometry were proved with quaternions before the advent of vectors and matrices as we know them today. They not all just rotations. Quote: Original post by Daerax Quote:Original post by someusername Although a quaternion comprises 4 independent real values, the fact that we actually normalize it to have norm==1 reduces them to 3 (in some way)... doesn't it? What you mean to say is that one may define an algebra over a real vector space that represents the quaternions, yes. However, a unit quaternion does not have a zero scalar value so I do not know your meaning. We may use quaternions to represent 3D rotations since the vector space R^3 is embedded in the quaternion algebra, in fact, the set of all pure quaternions (zero scalar value) form a space S^3, the common sphere known to us. I never said that a unit quaternion has zero scalar part. What I wrote is, that although quaternions envelope 4 *independent* values, the fact that we normalize them to have norm==1 reduces them to 3. (*independent* real values) If we demand that a quaternion has norm==1, (w^2+x^2+y^2+z^2==1), then any one of the w,x,y,z is reduced to an expression of the other 3 quantities, (like w = +/- sqrt(1-x^2-y^2-z^2)) and it cannot vary freely. Therefore the unit quaternion -a rotation- comprises 3 independent values.
  2. Quote:Original post by Kustaz Hi, I was just wondering, what is the fastest method for finding the inverse of a 4x4 Matrix, and also a 3x3 matrix? Thanks in advance. I would suggest the closed form solution, although I cannot definitely guarantee it's the fastest one. Consided the 3x3 matrix [ a b c ] A = [ d e f ] [ g h i ] The indices of the inverse are given by a11 = e i - f h a12 = c h - b i a13 = b f - c e a21 = f g - d i a22 = a i - c g a23 = c d - a f a31 = d h - e g a32 = b g - a h a33 = a e - b d You'll have to divide them all by the determinant of A, detA == -c e g + b f g + c d h - a f h - b d i + a e i For 4x4 matrices: [ a b c d ] [ e f g h ] A = [ i j k l ] [ m n o p ] a11 = -h k n + g l n + h j o - f l o - g j p + f k p a12 = d k n - c l n - d j o + b l o + c j p - b k p a13 = -d g n + c h n + d f o - b h o - c f p + b g p a14 = d g j - c h j - d f k + b h k + c f l - b g l a21 = h k m - g l m - h i o + e l o + g i p - e k p a22 = -d k m + c l m + d i o - a l o - c i p + a k p a23 = d g m - c h m - d e o + a h o + c e p - a g p a24 = -d g i + c h i + d e k - a h k - c e l + a g l a31 = -h j m + f l m + h i n - e l n - f i p + e j p a32 = d j m - b l m - d i n + a l n + b i p - a j p a33 = -d f m + b h m + d e n - a h n - b e p + a f p a34 = d f i - b h i - d e j + a h j + b e l - a f l a41 = g j m - f k m - g i n + e k n + f i o - e j o a42 = -c j m + b k m + c i n - a k n - b i o + a j o a43 = c f m - b g m - c e n + a g n + b e o - a f o a44 = -c f i + b g i + c e j - a g j - b e k + a f k You'll have to divide -again- each one of them by the determinant of the matrix. det(A) = d g j m - c h j m - d f k m + b h k m + c f l m - b g l m - d g i n + c h i n + d e k n - a h k n - c e l n + a g l n + d f i o - b h i o - d e j o + a h j o + b e l o - a f l o - c f i p + b g i p + c e j p - a g j p - b e k p + a f k p I hope didn't make any mistakes copy/pasting. This should be it. If performance is such a big issue, you'll want to precalculate the inverse of the determinant and multiply the aij instead of dividing. edit: It's obvious that the expressions for the determinants and the indices of the 4x4 inverse can be significantly factored, to save some multiplications.
  3. Projection Matrix

    Hi. Check this out.
  4. possible alternative to quaternions?

    There... found it... "Of the four elements (of a quaternion) the turning operation depends upon three; two angles to fix the plane of rotation, and one angle to fix the amound of rotation in that plane. The stretching operation depends only upon the remaining one, i.e., upon the ratio of the vector lengths. A.S. Hardy "Elements of Quaternions" page 34
  5. possible alternative to quaternions?

    Quote:Original post by Daerax For another, as Hamilton found out to his delight, to do 3D you not only need to encode the angle but as well the plane it is drawn on - its angle and the axis which tell you what direction to turn about. A simple triple simply does not hold enough information to encode this - you need a quadruple! The revelation led Hamilton to develop his quaternions. Actually, a simple triple is quite adequate in order to encode a 3d rotation. (longitude" & "latitude" of plane normal, and the actual angle) (edit: or the usual in physics: a 3d vector (x,y,z) giving the direction, and its magnitude the angle) The reason -however- why its not adequate for quaternions, is because they don't only rotate, they can also "stretch" space in order to make vectors of different length coincide. A "scaling" factor also has to be encoded. Their application in 3d gfx has to do with rotation mostly (unit quaternions), so this prospect is generally overlooked. Although a quaternion comprises 4 independent real values, the fact that we actually normalize it to have norm==1 reduces them to 3 (in some way)... doesn't it?
  6. Deep and high voices

    The formula you quoted for the calculation of amplitude seems to calculate pressure and not the actual amplitudes indicated by the fourier coefficients... (you can look up "SPL decibell" or "sound pressure level", as opposed to "sound intensity level") To me it looks like that it should be "((sinPart^2+cosPart^2)/(number of samples))/(2x10^-5)" in the logarithm, (which is the amplitude of the coefficient squared (the pressure) divided by the standard reference pressure level) I could be missing something though, so it's probably me who's mistaken. Afterall you saw it in a tutorial, it's highly unlikely that it's wrong. As for SuperNerd's suggestion, it's a really good idea actually if you want something not too complicated... A zero crossing is a position in the sample stream, where the sample values change sign; (from +ive they become -ive, or vice versa) The number of zero crossings in a given time interval, is a measure of how fast the waveform oscillates, thus a measure of how high the frequency of the sound is... This is a very simplistic model that will not work for complicated waveforms, but it may prove sufficient enough when dealing with voice only... I think it can focus on the fundamental frequency of simple sounds quite easily... Good idea, indeed...
  7. possible alternative to quaternions?

    I just wanted rrrr to see that you cannot let some values be imaginary units, and then give them extra properties. The whole idea behind the square of such a quantity being -1, is exactly what relates that quantity with rotation, since -consider a vector v on a plane through the origin-, -v = v*i^2, which is v rotated by π rad on the plane normal to i. Of course this lies in the fact that multiplication with i is known to rotate by π/2. The whole thing behind Hamilton's basic rule of transformation of i,j,k (i^2 = j^2 = k^2 = -1, ij = k, ji = -k etc...) merely displays how multiplication with these quantities should affect a vector which is expressed via these quantities (like a set of basis vectors). E.g., if you rotate i around j by π/2 you get k, which is concisely expressed as ij=k, or the other way around, ji=-k. This is no different than rotating the regular x,y,z axes of a cartesian system around themselves. Quaternions arose naturally (I believe) by the study of the properties of vectors expressed with the i,j,k orthogonal unit vectors. Try to multiply two vectors, of the form xi+yj+zk and you'll be left with a quaternion in no more than a couple of lines (considering the usual properties of course). Divide them (you'll need inverse vectors), and you'll get a quotient quaternion, which when applied to the divisor vector, rotates and stretches it (for arbitrary non unit quaternions) into the dividend! It's amazing what you can come up with if you start writing these things down. If you lose one basis vector (k in your example) you're no longer assuming 3d space... or if you alter the fundamental property of i^2=-1, (like with y^2=z and z^2=-y) it's not a complex quantity anymore, and most likely it will not exhibit properties such as rotating vectors.
  8. Deep and high voices

    Hi. Your graphs seem to plot signed numbers, which doesn't make sense since you say that you're plotting magnitudes, which are strictly positive. I suppose you plot "absolute value of fi / (square root of number of samples)", so that the same algo can be used for the inverse transform. If the plot range is only positive though, it seems to me that you're plotting all the coefficients (a total of "number of samples / 2") instead of the first 300 ones, as you claim. Human voice of both males and females is usually no more than 2KHz. (at least this is what I've read) Interestingly, your graphs only exhibit major difference within no more than 20% of their length, which is the same proportion of 2KHz w.r.t. 11KHz (the nyquist frequency == the maximum frequency you can pick up and reproduce == your sampling frequency/2) I guess there's no better way than cross-checking the results we get with our FFTs. Post a sample list of 2, 4, 8, 16, 32... complex values (a power of 2 anyway), and I'll let you know what I get with my implementation
  9. possible alternative to quaternions?

    Oops, of course not. I replied in a rush and forgot the other 2 roots. Yes, it could also be -(-1)^(1/3) and (-1)^(2/3) I just wanted to point out that numbers with that properties are not imaginary units.
  10. possible alternative to quaternions?

    z^2 = -y <=> z^3 = -yz <=> z^3 = 1 <=> z = 1 <=> y = -1 Therefore "A + By + Cz" simply diminishes to "A - B + C" and there's nothing complex about them. Coming up with a quantity that can be used to represent 3d rotations is not a trivial task.
  11. Screen Space to World Space

    There are some things that I don't quite get with what you're doing. For instance, you project the centers of some objects into screen-space, then compute their screen-space center, then project back to world space. Why? Why not computing their world-space center and project that center into screen-space? Furthermore, there is no "1-1" mapping of all points of a plane to all points of space. (lol, if this was true, we would -essentially- be able to see behind objects... think about it) It's impossible to unproject a 2D (u,v) point back to world space, and expect to be left with a unique 3d point (x,y,z) (the original source point of the projection) All the 3d points on their line, would project to the same point on the plane as well. You can't reverse the procedure. What you present, is essentially a "mouse picking" problem, where you start with a point on the viewport, and you're usually left with a vector -pointing to the direction of the desired 3d point- that assumably starts at your current origin (the world space position of the camera usually) Also... You seem to speak of "x,y,z screen position", or "screen W". There's no such things. The screen space is two dimensional and every point is assigned a (u,v) pair of coordinates. Points that are meant to map onto the viewport, satisfy -1 <= u,v <= 1. Also, the W component is not a concept of screen space. It's a homogeneous coordinate, only used to map point into screen space. An actual physical point should have a W==1, this is why you always to normalize w.r.t W in order for the result to have a meaning. Can you explain in further detail what *exactly* you're trying to do? I think you'll get more help that way.
  12. Car damage model

    Well, I believe you can find all you'll ever need on FEA in the respective wikipedia page. There seems to be plenty of reference to open source projects and other methods as well. I must tell you, though, that I doubt whether something like this is actually feasible in realtime (from the experience I have with a couple of FE analysis programmes) You'll definitely need a decent proxy mesh to work with, and in the end you'll just have to "cheat" in order to replicate the damage on your actual model. (I mean that, if you're going to cheat anyway, you may as well lose the FEA) Furthermore, even if you manage to get a decent FEA in realtime, don't forget that -since you seem to want all the realism you can get- you'll also have to deal with problems such as calculation of new deformed volume, calculation of the new distribution of mass (density changes), calculation of new inertial tensor, calculation of new center of weight... Of course, all these won't be on a "per frame" basis, but it goes to show that you may need to take into account more factors than what you planned. It sure sounds interesting though... Good luck.
  13. Need advice with compression issue

    Quote:Original post by Zahlman Well, what kind of data *is* it then? The data I want to encode is a lossy custom representation of decimal numbers very close to zero. I've managed to reduce the size of each structure down to twelve bits (prior to any compression) while preserving an average accuracy of ~ 3*10-4 for numbers in the range {-1,1}. It suits my needs well because it also allows numbers in wider ranges to be represented, without any changes in the code, but with a reasonable tradeoff in accuracy. This is acceptable because it should be very rare. The data comes from mathematical transformations and the bit patterns seem to be distributed with uniform probabilities (both when represented as regular floats or using my custom data structure). This is why I've come to believe that Huffman was a bad choice to start with... After a little reading, I'm planning on implementing the MTF and Burrows-Wheeler transformations, but the final step seems to be Huffman again, not RLE as I originally thought... (this is what most of the stuff I've read, suggests) I really hope they pay off.
  14. Need advice with compression issue

    Well, I think I have to give up Huffman for good... Although I knew from the start that it relies on frequencies of appearence, I didn't realize that it's totally unsuitable for my needs... the kind of data I'm dealing with, seems to have an inherent "equiprobability" when viewed as bit patterns... I'm not sure if a probability based algorithm would be the right choice here... Anyway, the MFT and Burrows/Wheeler transformations seem quite interesting... I hadn't even heard of them before. They look like they can really boost the performance of RLE. I think I'll give it a try. The rest of the algorithms I saw in wikipedia, seem to rely mostly on probabilities... I believe there's no reason to consider them... Thanks again, you've all been very helpful.
  15. Need advice with compression issue

    Thank you all for your input. Actually I was planning on implementing the compression myself, this is why I was considering Huffman from the start (it seemed to me that I could get it going relatively easily) It seems I've got a little bit of reading to do on your suggestions there... Thanks again, I'll get back if necessary