Z 軸を中心にベクトルを回転させる方法はありますか。

質問:

単位ベクトルを、2 度単位で 360 度回転させようとしています。X 座標と Y 座標は変えず、Z 軸だけを中心にして回転させようと考えています。

回答:

Matrix3 値」のトピックでは、ベクトル(Point3 値)を変換するための便利な方法を紹介しています。この中に、ワールド Z 軸を中心に回転させる方法も含まれています。rotateZMatrix 値を作成し、この値を使用して元のベクトルを変換するだけです。

スクリプト:

    resetMaxFile #noPrompt --reset the file
    theV = normalize [5,0,10] --the vector to rotate, normalized to unit vector
    theStep = 10 --the step by which you want to rotate
    --rotate from 0 to 360-theStep with step TheStep:
    for a = 0 to 360-theStep by theStep do
    (
      rm = rotateZMatrix a --create a rotation matrix from the value
      theRotV = theV * rm --transform the original vector using the matrix
      format "%: %\n" a theRotV --print the result to Listener
      c = cylinder() --create a cylinder
      c.dir = theRotV --orient along the vector to see what it looks like
    )

結果はマフィンのようになります。