Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8588475
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T22:48:41+00:00 2026-06-11T22:48:41+00:00

I use this code inside a subclass of CALayer which instances are sublayers of

  • 0

I use this code inside a subclass of CALayer which instances are sublayers of the root CALayer.

-(void)setSelected:(bool)s {
    selected=s;
    if (s)
    {
        CATransform3D  rot = CATransform3DMakeRotation(M_PI, 0, 1, 0);
        rot.m34=-1.0 / 200;
        [self setTransform:rot];

    }
    else
    {
            CATransform3D  rot = CATransform3DMakeRotation(0, 0, 1, 0);
        rot.m34=-1.0 / 200;
        [self setTransform:rot];
    }
}

When the selected property to set to TRUE, here is what happens: the rotation is done until the angle is equal to M_PI/2, then the layer disappears because it is orthogonal. The end of the animation is wrong: the edge that appeared to grow in the first part of the animation (for example on the left side), ends the animation on the left side instead of the right side. However the content is flipped.

I think this has something to do with the interpolation between the two rotation matrices but I can’t understand exactly what is happening.

Details: The animation looks like it is doing this:

  1. increment rotation around Y axis by +Pi/2
  2. content flipping
  3. increment rotation around Y axis by -Pi/2, as if it bounced of the (yz)plane

The flipped content is what I am trying to achieve.

Here are the frames of the animation I get. As you can see, the small side of the trapezoid is always of the left; it should be on the right on at the end of the animation (top right frame).
A layer rotating around the Y-axis

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-11T22:48:42+00:00Added an answer on June 11, 2026 at 10:48 pm

    The math of your transform is not correct. You should apply the perspective transform after the rotation transform, which means concatenating both transforms. Changing the m34 coefficient of your rotation transform is not equivalent.

    You should replace your code by the following :

    -(void)setSelected:(bool)s {
        selected=s;
        CATransform3D perpectiveTransform = CATransform3DIdentity;
        perpectiveTransform.m34 =-1.0 / 200;
    
        if (s)
        {
    
            CATransform3D  rot = CATransform3DMakeRotation(M_PI, 0, 1, 0);
            [self setTransform:CATransform3DConcat(rot, perpectiveTransform)];
    
        }
        else
        {
            CATransform3D  rot = CATransform3DMakeRotation(0, 0, 1, 0);
            [self setTransform:CATransform3DConcat(rot, perpectiveTransform)];
        }
    }
    

    By the way, an often more convenient method to apply perspective transforms is to use the superlayer’s sublayerTransform property, thus applying it to every sublayer (if this is needed).

    This would yield something like :

    self.superlayer.sublayerTransform = perspectiveTransform;  //do this in your setup
    ....
    self.transform = rot;
    

    for an identical looking result.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a list of <p> inside a <div id=someDiv> I use this code
I use this code which is taken from MVC futures and attach the Attribute
I use this JavaScript code inside the head tag in order to populate the
I use this code to create arrays inside array. array_push($lists, $list); And then I
Hi i need to wrap this code inside a function to use it later
I use this code : MethodInvoker TileLoadCompleteMethodInvoker = delegate() { CleanStatusLabelTimer.Enabled = true; MemoryTextBox.Text
i use this code in my app. just found is not correct when compare
I use this code to connect to SQL Server 2012, but it does not
I use this code to select password field from the sql server 2012 db,
I use this code , to log $_SERVER['REMOTE_ADDR']; to my small db my issue

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.