What is wrong with the Matrix3D.transformVector?

I admit that I am not an expert on Matrix3D computation, but is it really me or just a bug?

In my understanding an inverted matrix can neutralize an already applied transformation to a Vector3D. So having a Vector3D transformed by a matrix and afterward to the inverted one returns the original Vector coordinates, right?

Check out this simple test.

Can anyone explain this or should I log a bug?

Update: If I use transformVectors instead – the computed values are as expected.

17 thoughts on “What is wrong with the Matrix3D.transformVector?”

  1. well i have to see that a 3d matrix is nothing more than a matrix. So let me explain a moore simple rule.
    M is a Matrix composed of (nxm cells)
    Take an Identity I (I is a matrix that has 1 in each cell in the diagonal and 0 otherwhise )

    I = M x M^-1

    Now is to understand what is for flash a vector 3d.

    if a vector is a column you have not to multiply it by a matrix… you have to subtract another vector opposit to the first one.

    so V – V = W where W is a vector composed of all zeroes.

    I remember this math, now is up to you to dig and find what is a vector 3d for flash.

  2. Pixelero is right, it’s throwing a 1/20 around in the math somewhere. I’ve been chugging through by hand, trying to figure out exactly where.

    Notice if you trace v.w in your code, you’ll see 1/20. -95 is also 100/20 + -100 (instead of 100 + -100, which it should be). Is it setting w = 20 maybe, instead of w = 1? I’d be willing to be it’s screwing up the homogeneous divide when it projects back to 3d coordinates.

    It would be much better to have a Vector4D and Matrix4D class instead of trying to shoehorn 4D into the 3D classes, confusing everyone. :)

  3. ok i’m working with the Flex SDK and the Matrix3.append/prepend x20 bug seems to be fixed…

    but now there is another one and it looks like it’s located inside the Utils3D.projectVectors method. As a result, TriangleCulling is pretty messed up too… The bug is now x20 on the z-axis when projecting vectors.

  4. I’m using projectVectors() with a matrix obtained using root.transform.perspectiveProjection.toMatrix3D(); But the drawTriangles gets totally messed up with triangles all over the screen. http://yfrog.com/azscreen2jj

    When I add m.prependTranslation(0.0,0.0,10.0); to the matrix I’m able to see the 100 radius sphere I’m trying to render but it’s not in the same perspective as all my other display objects…

    Is this because of the x20 bug? Or am I using the projectVectors all wrong?

    Save me!

Comments are closed.