CALayer transform, setting the Y value of rotation causes side-effects
CALayer transform, setting the Y value of rotation causes side-effects
- Subject: CALayer transform, setting the Y value of rotation causes side-effects
- From: John Clayton <email@hidden>
- Date: Mon, 14 Jul 2008 18:57:42 +0200
Hi All,
I'm setting the rotation values of a CALayer, and notice that when
setting the Y component of rotation of a CATransform3D structure via
the :
[layer setValue:someValue forKeyPath:@"transform.rotation.y"]
call, that in certain cases of 'someValue' (the y rotation), the X and
Z rotation values are modified as well.
I set the value of the transform.rotation.Y using the standard
setValue:forKeyPath: method, and logged the resulting X, Y and Z
rotation values. Here's the code and logging results:
- (void) awakeFromNib {
CALayer* testLayer = [CALayer new];
NSLog(@"before: x, y, x = %@ / %@ / %@",
[testLayer valueForKeyPath:@"transform.rotation.x"],
[testLayer valueForKeyPath:@"transform.rotation.y"],
[testLayer valueForKeyPath:@"transform.rotation.z"]);
// but this breaks the X and Z, how come?
[testLayer setValue:[NSNumber numberWithDouble:2.12041]
forKeyPath:@"transform.rotation.y"];
NSLog(@"after: x, y, x = %@ / %@ / %@",
[testLayer valueForKeyPath:@"transform.rotation.x"],
[testLayer valueForKeyPath:@"transform.rotation.y"],
[testLayer valueForKeyPath:@"transform.rotation.z"]);
[testLayer release];
}
2008-07-14 17:48:23.555 Annotate[42997:10b] before: x, y, x = 0 / -0 / 0
2008-07-14 17:48:23.562 Annotate[42997:10b] after: x, y, x =
3.141593 / 1.021183 / 3.141593
Huh?
Question 1: Why do X and Z get very close to PI?
Question 2: Why does Y end up being 1.02 when I set it to 2.12041?
Does anyone know what's going on here? I'm a little stumped by this
one.
Thanks
--
John Clayton
Skype: johncclayton
_______________________________________________
Cocoa-dev mailing list (email@hidden)
Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden