您的位置:首页 > 其它

根据三角形三边一内角,计算出显示在视图上的坐标点

2016-03-09 10:25 323 查看


CGFloat w = self.frame.size.width;

CGFloat h =
self.frame.size.height;

int rectangle = w > h ? h : w;
// 画布大小

double mMultiples =
1.0; // 缩放比例

// double a = 60;

// double b = 71;

// double c = 70.9721;

// double B = 65.0242;



float ax;

float ay;

float bx;

float by;

float cx;

float cy;



double max = getMax(fabs(a),
fabs(b), fabs(c));
// 3个边长中的最大值



mMultiples = max / (rectangle * 3 /
5);

a = a / mMultiples;

b = b / mMultiples;

c = c / mMultiples;



if (B > 90) {

bx = (float) (rectangle *
4 / 5 - a);

} else {

bx = rectangle / 5;

}

by = rectangle * 4 /
5;

cx = (float) (bx + a);

cy = by = rectangle * 4 /
5;



if (B > 90) {

ax = (float) (bx - c *
cos((180 - B) /
180 * M_PI));

ay = (float) (by - c *
sin((180 - B) /
180 * M_PI));

} else {

if (B < 90) {

ax = (float) (bx + c *
cos((B) / 180 *
M_PI));

ay = (float) (by - c *
sin((B) / 180 *
M_PI));

} else {

ax = bx;

ay = (float) (by - c);

}

}



CGPoint sPoints[3];//坐标点

sPoints[0] = CGPointMake(ax, ay);//坐标1

sPoints[1] = CGPointMake(bx, by);//坐标2

sPoints[2] = CGPointMake(cx, cy);//坐标3
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: