Ejemplo n.º 1
0
        /**
         * この関数は、2次元座標系の矩形を表す直線式と、3次元座標系の矩形のオフセット座標値から、回転行列を計算します。
         * <p>メモ -
         * Cで実装するときは、配列のポインタ版関数と2重化すること
         * </p>
         * @param i_linear
         * 直線式。4要素である必要があります。
         * @param i_sqvertex
         * 矩形の3次元オフセット座標。4要素である必要があります。
         * @
         */
        public virtual bool initRotBySquare(NyARLinear[] i_linear, NyARDoublePoint2d[] i_sqvertex)
        {
            NyARRotVectorV2 vec1 = this.__initRot_vec1;
            NyARRotVectorV2 vec2 = this.__initRot_vec2;

            //向かい合った辺から、2本のベクトルを計算

            //軸1
            vec1.exteriorProductFromLinear(i_linear[0], i_linear[2]);
            if (!vec1.checkVectorByVertex(i_sqvertex[0], i_sqvertex[1]))
            {
                return(false);
            }

            //軸2
            vec2.exteriorProductFromLinear(i_linear[1], i_linear[3]);
            if (!vec2.checkVectorByVertex(i_sqvertex[3], i_sqvertex[0]))
            {
                return(false);
            }

            //回転の最適化?
            if (!NyARRotVectorV2.checkRotation(vec1, vec2))
            {
                return(false);
            }

            this.m00 = vec1.v1;
            this.m10 = vec1.v2;
            this.m20 = vec1.v3;
            this.m01 = vec2.v1;
            this.m11 = vec2.v2;
            this.m21 = vec2.v3;

            //最後の軸を計算
            double w02 = vec1.v2 * vec2.v3 - vec1.v3 * vec2.v2;
            double w12 = vec1.v3 * vec2.v1 - vec1.v1 * vec2.v3;
            double w22 = vec1.v1 * vec2.v2 - vec1.v2 * vec2.v1;
            double w   = Math.Sqrt(w02 * w02 + w12 * w12 + w22 * w22);

            this.m02 = w02 / w;
            this.m12 = w12 / w;
            this.m22 = w22 / w;
            return(true);
        }
Ejemplo n.º 2
0
 /**
  * コンストラクタです。
  * 参照する射影変換オブジェクトを指定して、インスタンスを生成します。
  * @param i_matrix
  * 参照する射影変換オブジェクト
  * @
  */
 public NyARRotMatrix(NyARPerspectiveProjectionMatrix i_matrix)
 {
     this.__initRot_vec1 = new NyARRotVectorV2(i_matrix);
     this.__initRot_vec2 = new NyARRotVectorV2(i_matrix);
     return;
 }