What is wrong with the Matrix3D.transformVector?

October 12th, 2008

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.

Filed under: actionscript

17 Responses to “What is wrong with the Matrix3D.transformVector?”

  1. Ya??z Gürgül Says:
    October 12th, 2008 at 9:14 pm

    Same problem here. You are saying right but Flash doing wrong.

    Waiting for solutions

  2. Nicola Marini Says:
    October 12th, 2008 at 10:38 pm

    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.

  3. X. Says:
    October 13th, 2008 at 3:25 am

    Looks like you are applying a 4D matrix to a 3D vector. So matrix3D is actually a 4D array?

    - X.

  4. Pixelero Says:
    October 13th, 2008 at 2:38 pm

    I guess this is the same ‘x20 bug – Matrix3D scales the result by 20 or 1/20′ as in here:

    http://www.adobe.com/cfusion/webforums/forum/messageview.cfm?forumid=72&catid=675&threadid=1387587&enterthread=y

    or:
    http://bugs.adobe.com/jira/browse/FP-670

  5. Mike Welsh Says:
    October 16th, 2008 at 2:31 am

    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. :)

  6. promethe Says:
    October 17th, 2008 at 1:06 am

    I posted

    http://www.adobe.com/cfusion/webforums/forum/messageview.cfm?forumid=72&catid=675&threadid=1387587&enterthread=y

    and

    http://bugs.adobe.com/jira/browse/FP-670

    a few weeks ago already if I remember correctly… and nothing has changed.

    The final version of Flash 10 still has those unbelievable math bugs. To me, the Matrix3D implementation is a complete non sense and suffers a great lack of consistency.

  7. Andre Michelle Says:
    October 17th, 2008 at 5:14 am

    promethe:
    I need to test this for my own with the latest SDK. I just read that they have fixed that. If it is still there it would be a another disappointment.

  8. Mike Welsh Says:
    October 17th, 2008 at 7:18 pm

    These bugs (append and transformVector) still exist in the CS4 release. Bummer!

  9. promethe Says:
    November 5th, 2008 at 1:01 am

    ok i’m working with the Flex SDK 3.2.0.3794 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.

  10. promethe Says:
    November 5th, 2008 at 2:57 am

    OK OK I think I found where the problem is… I’ll post on my blog when I’m sure

  11. Niels Says:
    October 13th, 2009 at 5:28 pm

    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!

  12. bgstaal » Perspective projection in flash Says:
    January 6th, 2010 at 3:35 pm

    [...] To make these concepts a bit easier to work with in actionscript I wrote three simple classes which provides a good foundation for doing custom 3d transformations and perspective projection in Flash: Point2d, Point3d & Matrix3d. This is the same kind of classes that make up the foundation for well known 3d libraries like papervision3d and away3d, only these classes are a bit easier to work with outside the context of a framework. (There is also a set of equivalent object types that ship with flash player 10 but I have experienced some bugs and actual miscalculations when using them and it seems I am not the only one) [...]

  13. novio Says:
    May 4th, 2010 at 9:10 pm

    tequiero guapa llamame

  14. novio Says:
    May 4th, 2010 at 9:11 pm

    venga
    michelle

  15. novio Says:
    May 4th, 2010 at 9:11 pm

    tequiero cogelo

  16. novio Says:
    May 4th, 2010 at 9:12 pm

    dame tu numero
    andre ldile que se ponga

  17. novio Says:
    May 4th, 2010 at 9:14 pm

    dame tu numero
    andre ldile que se pongaanda llegaste ya a casa

Leave a Reply