Created
September 14, 2011 07:14
-
-
Save rentzsch/1216022 to your computer and use it in GitHub Desktop.
NSString* JRNSStringFromCATransform3D(CATransform3D transform)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
static NSString* prettyFloat(CGFloat f) { | |
if (f == 0) { | |
return @"0"; | |
} else if (f == 1) { | |
return @"1"; | |
} else { | |
return [NSString stringWithFormat:@"%.3f", f]; | |
} | |
} | |
NSString* JRNSStringFromCATransform3D(CATransform3D transform) { | |
// format: [1 0 0 0; 0 1 0 0; 0 0 1 0; 0 0 0 1] | |
return CATransform3DIsIdentity(transform) | |
? @"CATransform3DIdentity" | |
: [NSString stringWithFormat:@"[%@ %@ %@ %@; %@ %@ %@ %@; %@ %@ %@ %@; %@ %@ %@ %@]", | |
prettyFloat(transform.m11), | |
prettyFloat(transform.m12), | |
prettyFloat(transform.m13), | |
prettyFloat(transform.m14), | |
prettyFloat(transform.m21), | |
prettyFloat(transform.m22), | |
prettyFloat(transform.m23), | |
prettyFloat(transform.m24), | |
prettyFloat(transform.m31), | |
prettyFloat(transform.m32), | |
prettyFloat(transform.m33), | |
prettyFloat(transform.m34), | |
prettyFloat(transform.m41), | |
prettyFloat(transform.m42), | |
prettyFloat(transform.m43), | |
prettyFloat(transform.m44) | |
]; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment