iPhone CALayer's rotation axis - iphone

I'm rotating a CALayer on the X axis, but even if it's displaced on the Z axis, it uses the Z = 0 as axis for the rotation?
Is there a way of telling it to use the bottom of the plane, as the axis?
Thank you!

The transform of a CALayer uses the layer's anchor as its origin. You could try adjusting the anchorPoint and anchorPointZ properties of the layer.

Related

Get specific corner co-ordinates of UIView/UIImageView irrespective of its rotation

I have a simple UIImageView of in my screen as follow:
To get the co-ordinates of highlighted corner of this UIImageView, I use simple formula:
CGPointMake(CGRectGetMaxX(imageView.frame), CGRectGetMaxY(imageView.frame))
Now I rotate this imageView and it looks as follows:
After this rotation, how can I get the co-ordinates of this highlighted point? Because after rotation, the previous code is not applicable.
You can consult the next link topic: Transformation of Coordinates Involving Rotation
https://www.math10.com/en/geometry/analytic-geometry/geometry1/coordinates-transformation.html
It only applies cos and sin functions to calculate (x,y) in the new rotated coordinate system. All you need is the rotation angle.

How to rotate image plane and take its projection visible on the screen?

I need a way to rotate a given image plane along an axis of which the ends are specified by the user. After the desired rotation the user must be able to get the projection of the image which he is looking at in the screen.
rotate(h,direction,alpha)
rotates the graphics object h by alpha degrees. direction is a two- or three-element vector that describes the axis of rotation in conjunction with the origin of the axis of rotation. The default origin of the axis of rotation is the center of the plot box. This point is not necessarily the origin of the axes.
Positive alpha is defined as the righthand-rule angle about the direction vector as it extends from the origin of rotation.
More detail is here

Images rotate along y axis

How can let the images rotate along y axis?
I try to use this code,but it just rotate along image's y axis.
imageView.layer.transform = CATransform3DConcat(imageView.layer.transform, CATransform3DMakeRotation(180,0.0,1.0,0.0));
Anybody can solve my question?many thanks.
Translate first (by half of image width) and then rotate.

How to rotate an image about a point that is not the image's center point using MATLAB?

What is the method to use to rotate an image about a point that is not the image's center point using MATLAB?
Two rotations of the same angle are equal up to a translation. So you can just do rotation around the center, and then translate the image to put your own center of rotation at its old position.
The help to 'rotate' says:
ROTATE Rotate objects about specified origin and direction.
ROTATE(H,[THETA PHI],ALPHA) rotates the objects with handles H
through angle ALPHA about an axis described by the 2-element
direction vector [THETA PHI] (spherical coordinates).
All the angles are in degrees. The handles in H must be children
of the same axes.
...
ROTATE(...,ORIGIN) uses the point ORIGIN = [x0,y0,y0] as the center
of rotation instead of the center of the plot box.
To rotate about a point other than the origin you:
Translate the point you want to rotate around to the origin. For example, if you want to rotate around (3,5), you would translate by (-3,-5).
Perform your rotation.
Undo the initial translation. So in my example you would now translate by (+3,+5).

UIImage rotation axis

I want to rotate an image (UIImage) but can only do it from a default axis which is dead centre of the image ! as in Fig A. I want to move the axis to the centre of the x axis at the foot of the image as in Fig B. Can someone help me with this? I can only think of work arounds such as placing the image on an imaginary circle around the origin where the centre of the image would be where I position, then rotate the objects. This is too complicated and hopefully unneccessary. Imagine i want to place a number of images around a clock face with the origin in the centre where the clock hands originate, that's what I want to achieve. (The maths for doing this would also be appreciated).
(mid x axis and mid y axis).
Try using the view's underlying CALayer's anchorPoint property.
http://developer.apple.com/library/mac/documentation/GraphicsImaging/Reference/CALayer_class/Introduction/Introduction.html#//apple_ref/doc/uid/TP40004500-CH1-SW36
I think you can do it by first rotating using CGContextRotateCTM and then shifting that center point to the point you want it to be by using CGContextTranslateCTM
Like rotate 90 degree first to right
then shift center(x,y) to newPoint((x- width/2), (y - height/2)) here width and height are of rotated image.
I hope this helps.