1

指定された数のサンプリング ポイントをループする必要があります。これらのサンプリング ポイントは、方向を表す正規化されたベクトルです。それらはコードで計算する必要があります。forward vector から始めて1, 0、原点を中心に回転させて、指定された数の方向を考え出します。

for(int i = 0; i < number_of_sampling_points; ++i)
{
    // get direction vector based on i and number_of_sampling_points
    // ...
}

たとえば、値のペア, , ,を取得したいループ内にあるとしnumber_of_sampling_pointsます。順番は関係ありません。41, 00, 1-1, 00, -1

4

2 に答える 2

2

これを試して:

const double PI = 3.14159265358979323846;
const int number_of_sampling_points = 4;
for (int i = 0; i < number_of_sampling_points; ++i)
{
    const double a = PI * 2 * (1.0 - i) / number_of_sampling_points;

    double x = sin(a);
    double y = cos(a);

    cout << "(" << x << " , " << y << ")" << endl;
}

出力 (丸め):

(1 , 0)
(0 , 1)
(-1 , 0)
(0 , -1)
于 2013-05-10T10:13:53.247 に答える