用Cos和Sin数学函数绘制的变形圆Unity C#

时间:2018-04-19 17:41:39

标签: c# unity3d math line angle

我希望下面看到的紫色圆圈像第二张图像一样旋转。

enter image description here

enter image description here

问题 - 正如你所看到的 - 是圆圈变形了。我知道为什么,

这是第一张图片的代码

Vector3 pos = new Vector3 (radius * Mathf.Cos (theta), radius * Mathf.Sin (theta), 0f);

我将第二个参数切换为第三个,并且排序工作(如您所见,紫色圆圈变形)。

Vector3 pos = new Vector3 (radius * Mathf.Cos (theta), 0f, radius * Mathf.Sin (theta));
private void Circle() {
    lineRenderer.widthMultiplier = lineWidth;

    float deltaTheta = (2f * Mathf.PI) / vertexCount;
    float theta = 0f;

    lineRenderer.positionCount = vertexCount;
    for (int i = 0; i < lineRenderer.positionCount; i++) {
        Vector3 pos = new Vector3 (radius * Mathf.Cos (theta), 0f, radius * Mathf.Sin (theta));
        lineRenderer.SetPosition (i, pos);
        theta += deltaTheta;
    }
}

0 个答案:

没有答案