TLDR; I have been researching this for hours and in checking out the image.transform options I can see that I think the transforms I need are already within pythonista, but I had chosen the wrong one initially and had never thought to look at the others. I feel quite stupid about now and am going back to the drawing board. I'm going to leave this post here because I've thought about and learned a lot and this has kind of formed my notes and I want to take the time to thank @JonB and @cvp for their time. I might revisit this code as an ObjC wrapper if I'm wrong, because I feel like I'm close to nailing it, but there is no NEED to reinvent the wheel.
I have to revisit the sample code I pasted at the origin because that was just plucked from SE and now I want to work out how I want to apply it. What I pasted isn't actually the code, I'm working on that part now. This is more about the learning for me at the moment and I am trying to get my head around the terminology for the transforms and matrixes. The maths is really beyond me and I'm starting to confuse a lot of these terms.
Looking at what @jonb has put together is based on some mistakes I think I have misstated.
This is where I'm thinking atm:
The code I pasted in the OT was from a SE site and not exactly right for my application. In learning the terms (mostly tonight) I need to MAKE the translation. At least, that's what I think I want.
I want the 3D equiv to CGAffineTransform, which doesn't take in the original instance (hence why I think I need the create/make version).
CATransform3DMakeRotation vs
CATransform3DRotate vs
CGAffineTransform <-- the 2D version
I think I need to use first one over the second.
I'm still confused by the c.CATrans....
where does the c
come from in JonB's code?
Swapping out ctypes.Structure
for just Structure
worked
CATransform3DMakeTranslation declaration:
CATransform3D CATransform3DMakeTranslation(CGFloat tx, CGFloat ty, CGFloat tz);
CATranform3DMakeRotation declaration
CATransform3D CATransform3DMakeRotation(CGFloat angle, CGFloat x, CGFloat y, CGFloat z);
They are both of type: CATransform3D, declared here:
typedef struct CATransform3D {
...
} CATransform3D;
Based on the code you guys have posted, I believe this is going to translate to:
class CATransform3D (Structure): ### NOTE 3D
_fields_ = [('m11', c_float),('m12', c_float),('m13', c_float),('m14', c_float),('m21', c_float),('m22', c_float),('m23', c_float),('m24', c_float), ('m31', c_float),('m32', c_float),('m33', c_float),('m34', c_float), ('m41', c_float),('m42', c_float),('m43', c_float),('m44', c_float)]
Now I have got it crashing too, and I think it's to do with the returned 3DTransform, I need to convert it back to Affine... which means I think I would need to take the original image and trying to 3DRotate it. It's the image from a ui.ImageView
which is..... it was at this point he knew he'd stuffed up
I'll post more when I recover.
I'll be back. :)