I reckon I'm completely misunderstanding how perspective is applied.
I thought that the points in the layer would all have a z of 0 since
it's 2d, but that then the perspective transform would give them
"depth" based on m34 and the rotation of the sublayer, which would
then have to be mapped to an x,y point in 2d space.
BTW: The way I'm applying this at present is to combine the matrices
of all layers like so:
CG points implicitly have a zero Z component, so the m34 component
of the matrix has no effect. The full expansion to map a homogeneous
3D point 'p' to the point 'q' with the matrix applied is:
That's useful except that I do want to take into account the
perspective as applied by the sublayerTransform of a superlayer
(field m34 in the transform). Any idea where I might turn in
order to learn about how to do this?
the Z component of the transformed point is ignored, and the X and
Y components are correctly divided by W (unless W is <= 0),
John
On Mar 18, 2008, at 2:45 AM, Neil Clayton wrote:
Hello.
I'm wanting to draw a polygon around a layer. I want the polygon
to be 1 pixel wide regardless of the transformations applied to
the layer. As such a border/borderWidth solution won't work
because it'll be scaled if the layer is scaled. So I've computed
the scaled and rotated coordinates of said layer by walking up
the layer tree and applying the affine transforms top-down to
each of the four points making up the original rectangle of the
layer. This gives me what I want - until I do rotation with
sublayerTransforms.
In an ideal world I'd like to know if there is also a way to
apply a CATransform3D to a point.
For example, in order to compute the translation, scale and
rotation(z) of a given point from the original rectangle I need
do only:
point = CGPointApplyAffineTransform(point, [layer
affineTransform]);
However there doesn't seem to be an equivalent function for
CATransform3D transforms.
Any suggestions? I've spent the entire day reading about
perspective transformations and projections (lots of matrix
math). I'm happy (as happy as someone that's not done this
stuff for many years can be) to go down this path if it's
absolutely required, but was wondering if anyone knew of a
simpler way (rather than reinventing the wheel) of applying the
same (or close enough - similar) math that CA/OpenGL is applying
to the sublayerTransform a matrix.
To be clear, I'm talking specifically about computing the final
value of a point in a layer given that I've set the m34 field of
the sublayerTransform in order to achieve a perspective effect
(ala: CovertFlow).
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Quartz-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/quartz-dev/email@hidden
This email sent to email@hidden
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Quartz-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/quartz-dev/email@hidden