-
Notifications
You must be signed in to change notification settings - Fork 1.2k
Implement NSAffineTransform #93
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
Initializes all entries to zeros.
Initializes the receiver's matrix using another transform object and returns the receiver.
The `copy()` override is necessary because `NSObject.copy()` always returns `self` so far.
5b08c4a
to
7926b21
Compare
…while making them more efficient.
7926b21
to
47602c4
Compare
|
||
public init() { | ||
(self.m11, self.m12, self.m21, self.m22) = (CGFloat(), CGFloat(), CGFloat(), CGFloat()) | ||
(self.tX, self.tY) = (CGFloat(), CGFloat()) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this init
could (should?) just call the full memberwise init below 😄
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah, you're right. Thanks!
…by introduction helper varaibles and better spacing
Thank you, @jessesquires! |
I've updated the PR to include the following changes:
Tests for composed transformations are missing - working on it! |
It also adds missing arithmetic operators to `CGFloat` which are needed for the matrix inversion.
I've updated the PR to include the following changes:
Notes:
|
Be sure to update the Status doc when we finish a feature! https://github.com/apple/swift-corelibs-foundation/blob/master/Docs/Status.md |
[ 0 0 1 ] | ||
*/ | ||
static func rotation(radians angle: CGFloat) -> NSAffineTransformStruct { | ||
let α = Double(angle) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Love the use of unicode variable name here!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Cool, glad you like it. I wasn't sure if that is considered good style, though.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think it makes sense to use it in limited places like this, where it actually conveys some meaning.
Hi,
The changes in this PR improve the implementation of the transformation methods. The new implementation makes use of the fact that a 2D affine transformation matrix is not an arbitrary 3x3 matrix (see code comments), and is both simpler and more efficient by skipping unnecessary computation steps.
Also included is:
NSAffineTransformStruct.init()
which initializes all entries to zeros.NSAffineTransform.init(transform:)
NSCopying
methods forNSAffineTransform