FOV矢量方向矩阵

时间:2017-06-09 16:03:56

标签: c# math unity3d matrix direction

我有一个产生以下输出的小功能。正如你所看到的那样有点扭曲,我不是数学中的天才。

private Vector3[] GetFovDirections(int points, float fov) {
    Vector3[] directions = new Vector3[points * points];

    for(int i = 0; i < points; i++)
        for (int j = 0; j < points; j++) {
            float angleX = transform.eulerAngles.y - fov / 2 + points * i;
            float angleY = transform.eulerAngles.x - fov / 2 + points * j;

            float x = Mathf.Sin(angleX * Mathf.Deg2Rad);
            float y = Mathf.Sin(angleY * Mathf.Deg2Rad);
            float z = Mathf.Cos(angleX * Mathf.Deg2Rad);

            directions[i + j * points] = new Vector3(x, y, z);
        }

    return directions;
}

enter image description here

0 个答案:

没有答案