原算法引用地址 http://slabode.exofire.net/circle_draw.shtml

这里是用点来分割画出圆, num_segments 是点的个数 这里theta =360/num_segments
x y,分别代表新的点位的坐标
y += ty * tangetial_factor; 这步就是 求BC 因为AB长度为r r*tan( theta)
void DrawArc(float cx, float cy, float r, float start_angle, float arc_angle, int num_segments)
{
float theta = arc_angle / float(num_segments - 1);//theta is now calculated from the arc angle instead, the - 1 bit comes from the fact that the arc is open
float tangetial_factor = tanf(theta);
float radial_factor = cosf(theta);
float x = r * cosf(start_angle);//we now start at the start angle
float y = r * sinf(start_angle);
glBegin(GL_LINE_STRIP);//since the arc is not a closed curve, this is a strip now
for(int ii = 0; ii < num_segments; ii++)
{
glVertex2f(x + cx, y + cy);
float tx = -y;
float ty = x;
x += tx * tangetial_factor;
y += ty * tangetial_factor;
x *= radial_factor;
y *= radial_factor;
}
glEnd();
}
本文介绍了一种使用OpenGL ES实现美颜效果的方法,通过调整点的位置来绘制圆弧,适用于实时视频处理和直播特效应用。算法基于tangetial_factor和radial_factor计算新的点位坐标,以创建平滑的曲线。
1160

被折叠的 条评论
为什么被折叠?



