• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: CALayer transform, setting the Y value of rotation causes side-effects
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: CALayer transform, setting the Y value of rotation causes side-effects


  • Subject: Re: CALayer transform, setting the Y value of rotation causes side-effects
  • From: Dmitri Goutnik <email@hidden>
  • Date: Mon, 14 Jul 2008 23:14:59 +0400

John,

You're rotating layer around Y axis by 2.12041 which is greater than PI/2. So after rotation you're looking at the "back side" of the layer, that's why X and Z get close to PI (i.e. flipped).

- Dmitri

On Jul 14, 2008, at 8:57 PM, John Clayton wrote:

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


References: 
 >CALayer transform, setting the Y value of rotation causes side-effects (From: John Clayton <email@hidden>)

  • Prev by Date: Re: Creating and App menu from Scratch
  • Next by Date: Re: CALayer transform, setting the Y value of rotation causes side-effects
  • Previous by thread: Re: CALayer transform, setting the Y value of rotation causes side-effects
  • Next by thread: Re: CALayer transform, setting the Y value of rotation causes side-effects
  • Index(es):
    • Date
    • Thread