Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to apply a CGAffineTransform to a CGPoint

If I have a transformation matrix, as a CGAffineTransform, and a point, as a CGPoint, how can I get the matrix-vector product?

For those wondering why I'm asking, I'm looking for a way to transform points between user coordinates and device coordinates. The functions CGContextConvertPointToUserSpace and CGContextConvertPointToDeviceSpace only seem to work in drawRect. I want to be able to get touch input, coming from a gesture recognizer in device coordinates, and transform it to user coordinates using the saved transformation matrix (CGContextGetCTM).

like image 762
rmp251 Avatar asked Mar 05 '14 05:03

rmp251


1 Answers

The function CGPointApplyAffineTransform() seems to do what you want.

like image 50
user1118321 Avatar answered Nov 05 '22 21:11

user1118321