I am attempting to develop an application that makes use of some simple trig functions. Unfortunately, with the way the coordinate system is set up on the iPhone, amongst many other devices, I am having trouble with my calculations — all centering around the offset.
For instance, the app I am creating has a small point that orbits around my center. Unforunately, because the center is not (0,0), I’m forced to put in any additional check to flip my coordinates (+180 degrees) upon reaching the center as well as adding in additional calculations to the trig functions to adjust — simply to account for how the origin system works.
I would like the center of the device, in this case (160,240) to be the center origin of my application. e.g. (160,240) = (0,0) That would mean, if I were to place any sub view to the left of the main view’s center, the X coordinates of that view would have a negative X. Otherwise, I’ll have to go through more calculations to adjust for the offset — which has proven to be a headache thus far.
I’ve set the origin of my view, using the editor, to the center. However, anything I drop on the view still retains a top, left 0,0 coordinate structure.
Is this possible? I would assume sense I can set the origin of my view to center, it must do something useful?
You could use the
sublayerTransformproperty of your view’slayer.