1

我正在尝试仅绘制 3d 圆的扇区/部分- 给出 2 个角度(开始,结束)、中心坐标、圆的半径和宽度。我在 Photoshop 中绘制了什么结果必须是这样的。 圆的扇区

你能帮我做吗(2d 例子,有 1 条简单的曲线,也可以)?只是想了解如何做到这一点...

ps对不起英语不好

4

1 回答 1

2

给定半径、圆心 (x0/y0) 和角度(以弧度为单位)的圆上点的计算公式

float x = radius * cos(angle) + x0;
float y = radius * sin(angle) + y0;

使用它来构建相应的三角形带(参见例如http://en.wikipedia.org/wiki/Triangle_strip):

float[] coordinates = new float[steps * 3];
float t = start_angle;
int pos = 0;
for (int i = 0; i < steps; i++) {
  float x_inner = radius_inner * cos(t) + x0;
  float y_inner = radius_inner * sin(t) + y0;

  float x_outer = radius_outer * cos(t) + x0;
  float y_outer = radius_outer * sin(t) + y0;

  coordinates[pos++] = x_inner;
  coordinates[pos++] = y_inner;
  coordinates[pos++] = 0f;

  coordinates[pos++] = x_outer;
  coordinates[pos++] = y_outer;
  coordinates[pos++] = 0f;

  t += (end_angle - start_angle) / steps;
}

// Now you need to hand over the coordinates to gl here in your preferred way,
// then call glDrawArrays(GL_TRIANGLE_STRIP, 0, steps * 2);
于 2013-11-09T19:33:50.497 回答