CATransform3DRotate with m34 parameter need to know angle to fit specific height

爱⌒轻易说出口 提交于 2019-12-06 16:17:51

问题


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.

来源:https://stackoverflow.com/questions/13840691/catransform3drotate-with-m34-parameter-need-to-know-angle-to-fit-specific-height

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!