主要计算公式:
直线的一般方程 y = kx + b;
圆的一般方程 x^2 + y^2 + Dx + Ey + F = 0;
圆的基本系数关系 r = (根号(D^2 + E^2 - 4F))/2
一元二次方程求根公式 x = -b (+/-) (根号(b^2 - 4ac)) / 2a
/**
计算圆环上取色点,解任意点过圆心的直线与圆的交点取其一
@param pointOne 任意点
@param circleCenterPoint 圆心
*/
- (CGPoint)calculateColorPointWithPoint:(CGPoint)pointOne circleCenterPoint:(CGPoint)circleCenterPoint
{
//由于OC坐标系与数学坐标系的差异,y值取反,转成数学坐标系
CGPointtemp1 = pointOne;
CGPointtemp2 = circleCenterPoint;
pointOne =CGPointMake(temp1.x, -temp1.y);
circleCenterPoint =CGPointMake(temp2.x, -temp2.y);
//计算过圆心直线斜率和常数b
lineK= (CGFloat)(pointOne.y- circleCenterPoint.y) / (CGFloat)(pointOne.x- circleCenterPoint.x);
lineB= circleCenterPoint.y-lineK*circleCe