views:

77

answers:

2

Hi. I have 2 points in a UIView, but I am unable to get the correct line equation between these two points because UIView coordinate system is not cartesian. When I apply the cartesian slope of a line, I keep getting the wrong slope for the UIView coordinate system. Maybe I'm applying the identity matrix incorrectly or using the wrong identity matrix. Do I need to translate the point-slope form equation too? I'm not sure. Any help would be greatly appreciated.

A: 

Are you getting the wrong slope because the CG coordinate system is flipped/mirrored upside-down between the iPhone and Mac OS? If so then just change dy to -dy in your slope equation.

hotpaw2
Thanks, but doesn't that only just make the slope negative of its current value? It doesn't seem to work for all instances. The iPhone screen is mirrored so y increases down instead of up like in cartesian. The problem is that the two points are in the iPhone coordinate system and I am unable to calculate the line that is formed by these two points. Whenever I apply the formula for a line, the answer is not always correct depending on the location of the points.
A: 

Sorry. You were write hotpaw2. The thing I got wrong was whether I am counting left to right or right to left for the slope. The mirrored UIView coordinate system is a little confusing.