Tokamak
Tokamak copied to clipboard
`CGAffineTransform` Implementation Fix
In this PR:
- The
rotated(by:)
,scaledBy(x:y:)
, andtranslatedBy(x:y:)
operators are made cumulative; - The implementation of
inverted()
is corrected to returnself
when the matrix is not invertible; - The implementation of
concatenating(_:)
is simplified; and - The documentation of matrix entries is improved.
Further work still needs to be done; namely:
- The implementation of the aforementioned operators could be optimized (by not using concatenations) — of course, that should be properly documented;
- The optimizations in the implementation of
inverted()
should be explained; - SIMD could optimize concatenations, inversions, and the other transformation operations; and,
- Unit tests should be added to help catch bugs and future regressions.
Update
- The foundation patch has been corrected and now there's substantial test support for the non-NS
AffineTransform
; it is currently awaiting review. - Tokamak now implements
CGAffineTransform
as a wrapper aroundFoundation.AffineTransform
; it has its own tests, nonetheless. This means that until the Foundation patch is merged, tests will fail on this branch. - Since we rely on Foundation's implementation, there's no need to document the operation — that's covered by the patch.
- The "optimized” SIMD versions were benchmarked (with Google Benchmarks), but found to be less efficient in some cases, especially in release builds, where they offer little —to no— performance boost.
Your Foundation patch has landed in Swift 5.7, so I hope we'll be able to update the PR later this year when that Swift version and its corresponding SwiftWasm version are released.