You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
According to this, algorithm of two matrices is something like this:
where I believe VectorMath's * operator represents ABin this equation. (meaning you can write A * B in swift to do same calculation.) If so, the function's lhs and rhs is reversed and since Matrix multiplication is not commutative, it'll produce different results.
I did write a simple Matrix4 <-> CATransform3D conversion code and check something like this:
let m1 = Matrix4( /* init with some values */)
let m2 = Matrix4( /* init with some other values */)
let con1 = CATransform3DConcat(CATransform3D(m1), CATransform3D(m2) )
let con2 = m1 * m2
XCTAssertTrue(Matrix4(con1) == con2) // this should pass, but fails
let con3 = m2 * m1
XCTAssertFalse(Matrix4(con1) == con3) // this should pass, but fails
Yeah CATransform works the opposite way round to what you'd expect. I think that's because it's view-centric or something, so it transforms objects from the PoV of the camera rather than the layer's own coordinate space.
Correct me if I'm wrong or midunderstangind something, but I think the order of matrix multiplication of VectorMath library seems reversed.
According to this, algorithm of two matrices is something like this:
where I believe VectorMath's
*
operator representsAB
in this equation. (meaning you can writeA * B
in swift to do same calculation.) If so, the function'slhs
andrhs
is reversed and since Matrix multiplication is not commutative, it'll produce different results.I did write a simple Matrix4 <-> CATransform3D conversion code and check something like this:
Here's what
CATransform3DConcat
s document says:I think it would be better to have reversed order for those methods.
The text was updated successfully, but these errors were encountered: