CATransform3DRotate with m34 parameter need to kno

2019-04-16 04:40发布

问题:

I have the following transform code:

//preparing transform
CATransform3D basicTrans = CATransform3DIdentity;
basicTrans.m34 =1.0/-projection;

//calculating angle
double angle= [[self angleValueForBlockHeight:height] doubleValue];
double rangle;
if (up)
{
    rangle=angle/360*(2.0*M_PI);
}
else
{
    rangle=(360.0-angle)/360*(2.0*M_PI);
};


//NSLog(@"    angle: %g", angle);

//transforming
bView.layer.transform = CATransform3DRotate(basicTrans, rangle, 1.0f, 0.0f, 0.0f);

As you can see I'm rotating bView using specific angle to have a value of height variable after rotation. And as you can see I have a angleValueForBlockHeight method there. This method has very ugly code. My question is how can I calculate the needed angle for this transform. The formula or the piece of code would be great. Help me , please.

Thanks for your attention.