OSDN Git Service

[バックアップ]NyARToolkit
authornyatla <nyatla@7cac0a50-4618-4814-88d0-24b83990f816>
Sun, 12 Oct 2008 09:01:04 +0000 (09:01 +0000)
committernyatla <nyatla@7cac0a50-4618-4814-88d0-24b83990f816>
Sun, 12 Oct 2008 09:01:04 +0000 (09:01 +0000)
固定小数点演算系のバグ修正など

15 files changed:
sample/sandbox/jp/nyatla/nyartoolkit/sandbox/vertexdetect/NyARVertexDetector.java
sample/sandbox/jp/nyatla/nyartoolkit/sandbox/x2/NyARFixedFloatFitVecCalculator.java
sample/sandbox/jp/nyatla/nyartoolkit/sandbox/x2/NyARFixedFloatObserv2IdealMap.java [moved from sample/sandbox/jp/nyatla/nyartoolkit/sandbox/x2/NyARFixedFloatCameraDistortionFactorMap.java with 67% similarity]
sample/sandbox/jp/nyatla/nyartoolkit/sandbox/x2/NyARFixedFloatRotMatrix.java
sample/sandbox/jp/nyatla/nyartoolkit/sandbox/x2/NyARFixedFloatRotTransOptimize_O2.java
sample/sandbox/jp/nyatla/nyartoolkit/sandbox/x2/NyARFixedFloatRotVector.java
sample/sandbox/jp/nyatla/nyartoolkit/sandbox/x2/NyARFixedFloatTransOffset.java
sample/sandbox/jp/nyatla/nyartoolkit/sandbox/x2/NyARSingleDetectMarker_X2.java
sample/sandbox/jp/nyatla/nyartoolkit/sandbox/x2/NyARSquareDetector_X2.java
sample/sandbox/jp/nyatla/nyartoolkit/sandbox/x2/NyARTransMat_X2.java
sample/sandbox/jp/nyatla/nyartoolkit/sandbox/x2/NyMath.java
src/jp/nyatla/nyartoolkit/core/NyARSquareDetector.java
src/jp/nyatla/nyartoolkit/core/param/NyARObserv2IdealMap.java [moved from src/jp/nyatla/nyartoolkit/core/param/NyARCameraDistortionFactorMap.java with 59% similarity]
src/jp/nyatla/nyartoolkit/core2/types/NyARFixedFloat16Point3d.java
src/jp/nyatla/nyartoolkit/core2/types/matrix/NyARFixedFloat24Matrix33.java

index 2949199..b6b5a42 100644 (file)
@@ -56,14 +56,14 @@ public class NyARVertexDetector implements INyARSquareDetector
        private final NyARLabelingImage _limage;\r
 \r
        private final OverlapChecker _overlap_checker = new OverlapChecker();\r
-       private final NyARCameraDistortionFactorMap _dist_factor_ref;\r
+       private final NyARObserv2IdealMap _dist_factor_ref;\r
 \r
        /**\r
         * 最大i_squre_max個のマーカーを検出するクラスを作成する。\r
         * \r
         * @param i_param\r
         */\r
-       public NyARVertexDetector(NyARCameraDistortionFactorMap i_dist_factor_ref,NyARIntSize i_size) throws NyARException\r
+       public NyARVertexDetector(NyARObserv2IdealMap i_dist_factor_ref,NyARIntSize i_size) throws NyARException\r
        {\r
                this._width = i_size.w;\r
                this._height = i_size.h;\r
@@ -237,7 +237,7 @@ public class NyARVertexDetector implements INyARSquareDetector
 \r
        private void getSquare(int[] i_mkvertex, int[] i_xcoord, int[] i_ycoord, NyARSquare o_square)\r
        {\r
-               final NyARCameraDistortionFactorMap dist_factor=this._dist_factor_ref;          \r
+               final NyARObserv2IdealMap dist_factor=this._dist_factor_ref;            \r
                final NyARDoublePoint2d[] vertex=o_square.sqvertex;\r
                //歪み補正\r
                for(int i=0;i<4;i++)\r
index 914d965..02e910a 100644 (file)
@@ -73,11 +73,11 @@ public class NyARFixedFloatFitVecCalculator
        private final NyARFixedFloat16Mat _mat_d = new NyARFixedFloat16Mat(3,3);\r
        private final NyARCustomMatrix _mat_d2=new NyARCustomMatrix(3,3);\r
        private final NyARPerspectiveProjectionMatrix _projection_mat;\r
-       private final NyARFixedFloatCameraDistortionFactorMap _distortionfactor;\r
+       private final NyARFixedFloatIdeal2Observ _distortionfactor;\r
 \r
 \r
 //     private NyARDoublePoint2d[] _vertex_2d_ref;\r
-       public NyARFixedFloatFitVecCalculator(final NyARPerspectiveProjectionMatrix i_projection_mat_ref,final NyARFixedFloatCameraDistortionFactorMap i_distortion_ref)\r
+       public NyARFixedFloatFitVecCalculator(final NyARPerspectiveProjectionMatrix i_projection_mat_ref,final NyARCameraDistortionFactor i_distortion_ref)\r
        {\r
                // 変換マトリクスdとbの準備(arGetTransMatSubの一部)\r
                final long[][] a_array = this._mat_a.getArray();\r
@@ -92,7 +92,7 @@ public class NyARFixedFloatFitVecCalculator
                        a_array[x2 + 1][1] = b_array[1][x2 + 1] =(long)(i_projection_mat_ref.m11*NyMath.FIXEDFLOAT16_1);// mat_a->m[j*6+4] =mat_b->m[num*2+j*2+1]= cpara[1][1];\r
                }\r
                this._projection_mat=i_projection_mat_ref;\r
-               this._distortionfactor=i_distortion_ref;\r
+               this._distortionfactor=new NyARFixedFloatIdeal2Observ(i_distortion_ref);\r
                return;\r
        }\r
        private final NyARFixedFloat16Point2d[] _fitsquare_vertex=NyARFixedFloat16Point2d.createArray(4);;\r
@@ -116,7 +116,7 @@ public class NyARFixedFloatFitVecCalculator
         * @param i_square_vertex\r
         * @throws NyARException\r
         */\r
-       public void setFittedSquare(NyARDoublePoint2d[] i_square_vertex) throws NyARException\r
+       public void setFittedSquare(NyARFixedFloat16Point2d[] i_square_vertex) throws NyARException\r
        {\r
                final NyARFixedFloat16Point2d[] vertex=_fitsquare_vertex;\r
                for(int i=0;i<4;i++){\r
@@ -33,19 +33,18 @@ package jp.nyatla.nyartoolkit.sandbox.x2;
 \r
 import jp.nyatla.nyartoolkit.core.types.*;\r
 import jp.nyatla.nyartoolkit.core.param.*;\r
-import jp.nyatla.nyartoolkit.core2.types.NyARFixedFloat16Point2d;\r
 /**\r
  * 歪み成分マップを使用するINyARCameraDistortionFactor\r
  * 内部マップをint(1:15:16)フォーマットの固定小数点で保持する。\r
  * 固定小数点で値を提供するインタフェイスを持ちます。\r
  */\r
-final public class NyARFixedFloatCameraDistortionFactorMap\r
+final public class NyARFixedFloatObserv2IdealMap\r
 {\r
        private double[] _factor=new double[4];\r
        private int _stride;\r
        private int[] _mapx;\r
        private int[] _mapy;\r
-       public NyARFixedFloatCameraDistortionFactorMap(NyARCameraDistortionFactor i_distfactor,NyARIntSize i_screen_size)\r
+       public NyARFixedFloatObserv2IdealMap(NyARCameraDistortionFactor i_distfactor,NyARIntSize i_screen_size)\r
        {\r
                NyARDoublePoint2d opoint=new NyARDoublePoint2d();\r
                this._mapx=new int[i_screen_size.w*i_screen_size.h];\r
@@ -57,7 +56,7 @@ final public class NyARFixedFloatCameraDistortionFactorMap
                {\r
                        for(int i2=i_screen_size.w-1;i2>=0;i2--)\r
                        {\r
-                               i_distfactor.observ2Ideal(i2,i, opoint);\r
+                               i_distfactor.observ2Ideal(i2,i,opoint);\r
                                this._mapx[ptr]=(int)(opoint.x*65536);\r
                                this._mapy[ptr]=(int)(opoint.y*65536);\r
                                ptr--;\r
@@ -66,43 +65,6 @@ final public class NyARFixedFloatCameraDistortionFactorMap
                i_distfactor.getValue(this._factor);\r
                return;\r
        }       \r
-       public void ideal2ObservBatch(final NyARDoublePoint2d[] i_in, NyARFixedFloat16Point2d[] o_out, int i_size)\r
-       {\r
-               double x, y;\r
-               final double d0 = this._factor[0];\r
-               final double d1 = this._factor[1];\r
-               final double d3 = this._factor[3];\r
-               final double d2_w = this._factor[2] / 100000000.0;\r
-               for (int i = 0; i < i_size; i++) {\r
-                       x = (i_in[i].x - d0) * d3;\r
-                       y = (i_in[i].y - d1) * d3;\r
-                       if (x == 0.0 && y == 0.0) {\r
-                               o_out[i].x = (long)(d0*NyMath.FIXEDFLOAT16_1);\r
-                               o_out[i].y = (long)(d1*NyMath.FIXEDFLOAT16_1);\r
-                       } else {\r
-                               final double d = 1.0 - d2_w * (x * x + y * y);\r
-                               o_out[i].x = (long)((x * d + d0)*NyMath.FIXEDFLOAT16_1);\r
-                               o_out[i].y = (long)((y * d + d1)*NyMath.FIXEDFLOAT16_1);\r
-                       }\r
-               }\r
-               return;\r
-       }\r
-       public void ideal2Observ(final NyARDoublePoint2d i_in, NyARFixedFloat16Point2d o_out)\r
-       {\r
-               final double f0=this._factor[0];\r
-               final double f1=this._factor[1];\r
-               final double x = (i_in.x - f0) * this._factor[3];\r
-               final double y = (i_in.y - f1) * this._factor[3];\r
-               if (x == 0.0 && y == 0.0) {\r
-                       o_out.x = (long)(f0*NyMath.FIXEDFLOAT16_1);\r
-                       o_out.y = (long)(f1*NyMath.FIXEDFLOAT16_1);\r
-               } else {\r
-                       final double d = 1.0 - this._factor[2] / 100000000.0 * (x * x + y * y);\r
-                       o_out.x = (long)((x * d + f0)*NyMath.FIXEDFLOAT16_1);\r
-                       o_out.y = (long)((y * d + f1)*NyMath.FIXEDFLOAT16_1);\r
-               }\r
-               return;\r
-       }       \r
        /**\r
         * 点集合のi_start~i_numまでの間から、最大i_sample_count個の頂点を取得して返します。\r
         * i_sample_countは偶数である必要があります。\r
@@ -121,7 +83,7 @@ final public class NyARFixedFloatCameraDistortionFactorMap
         int idx;\r
         if (i_num < i_sample_count)\r
         {\r
-            for (int i = i_num - 1; i >= 0; i -= 2)\r
+            for (int i = i_num - 1; i >= 0; i--)\r
             {\r
                 idx = i_x_coord[i_start + i] + i_y_coord[i_start + i] * this._stride;\r
                 o_x_coord[i] = this._mapx[idx];\r
index 9175e3b..f3d7f2e 100644 (file)
@@ -34,9 +34,8 @@ package jp.nyatla.nyartoolkit.sandbox.x2;
 import jp.nyatla.nyartoolkit.NyARException;\r
 import jp.nyatla.nyartoolkit.core.transmat.NyARTransMatResult;\r
 import jp.nyatla.nyartoolkit.core.types.*;\r
-import jp.nyatla.nyartoolkit.core.types.matrix.*;\r
 import jp.nyatla.nyartoolkit.core.param.*;\r
-import jp.nyatla.nyartoolkit.core2.types.NyARFixedFloat16Point3d;\r
+import jp.nyatla.nyartoolkit.core2.types.*;\r
 import jp.nyatla.nyartoolkit.core2.types.matrix.NyARFixedFloat24Matrix33;\r
 \r
 \r
@@ -79,7 +78,7 @@ public class NyARFixedFloatRotMatrix extends NyARFixedFloat24Matrix33
                return;\r
        }\r
 \r
-       public final void initRotBySquare(final NyARLinear[] i_linear, final NyARDoublePoint2d[] i_sqvertex) throws NyARException\r
+       public final void initRotBySquare(final NyARLinear[] i_linear, final NyARFixedFloat16Point2d[] i_sqvertex) throws NyARException\r
        {\r
                final NyARFixedFloatRotVector vec1 = this.__initRot_vec1;\r
                final NyARFixedFloatRotVector vec2 = this.__initRot_vec2;\r
@@ -96,19 +95,22 @@ public class NyARFixedFloatRotMatrix extends NyARFixedFloat24Matrix33
 \r
                // 回転の最適化?\r
                NyARFixedFloatRotVector.checkRotation(vec1, vec2);\r
+       \r
+\r
+               this.m00 = vec1.v1<<8;\r
+               this.m10 = vec1.v2<<8;\r
+               this.m20 = vec1.v3<<8;\r
+               this.m01 = vec2.v1<<8;\r
+               this.m11 = vec2.v2<<8;\r
+               this.m21 = vec2.v3<<8;\r
+               \r
 \r
-               this.m00 = (long)(vec1.v1*NyMath.FIXEDFLOAT24_1);\r
-               this.m10 = (long)(vec1.v2*NyMath.FIXEDFLOAT24_1);\r
-               this.m20 = (long)(vec1.v3*NyMath.FIXEDFLOAT24_1);\r
-               this.m01 = (long)(vec2.v1*NyMath.FIXEDFLOAT24_1);\r
-               this.m11 = (long)(vec2.v2*NyMath.FIXEDFLOAT24_1);\r
-               this.m21 = (long)(vec2.v3*NyMath.FIXEDFLOAT24_1);\r
 \r
                // 最後の軸を計算\r
-               final long w02 = (long)((vec1.v2 * vec2.v3 - vec1.v3 * vec2.v2)*NyMath.FIXEDFLOAT24_1);//S24\r
-               final long w12 = (long)((vec1.v3 * vec2.v1 - vec1.v1 * vec2.v3)*NyMath.FIXEDFLOAT24_1);//S24\r
-               final long w22 = (long)((vec1.v1 * vec2.v2 - vec1.v2 * vec2.v1)*NyMath.FIXEDFLOAT24_1);//S24\r
-               final long w = NyMath.sqrtFixdFloat((w02 * w02 + w12 * w12 + w22 * w22)>>24,24);//S24\r
+               final long w02 = (vec1.v2 * vec2.v3 - vec1.v3 * vec2.v2)>>16;//S16\r
+               final long w12 = (vec1.v3 * vec2.v1 - vec1.v1 * vec2.v3)>>16;//S16\r
+               final long w22 = (vec1.v1 * vec2.v2 - vec1.v2 * vec2.v1)>>16;//S16\r
+               final long w = NyMath.sqrtFixdFloat((w02 * w02 + w12 * w12 + w22 * w22)>>16,16);//S16\r
                this.m02 = (w02<<24) / w;\r
                this.m12 = (w12<<24) / w;\r
                this.m22 = (w22<<24) / w;\r
@@ -132,11 +134,11 @@ public class NyARFixedFloatRotMatrix extends NyARFixedFloat24Matrix33
                        this.m22 = -NyMath.FIXEDFLOAT24_1;// <Optimize/>rot[2][2] = -1.0;\r
                }\r
                cosb = this.m22;// <Optimize/>cosb = rot[2][2];\r
-               b=(int)(Math.acos((double)cosb/NyMath.FIXEDFLOAT24_1)*NyMath.FIXEDFLOAT16_1);\r
+               b=NyMath.acosFixedFloat16((int)cosb);\r
                sinb = (long)NyMath.sinFixedFloat24(b);\r
                final long rot02 = this.m02;\r
                final long rot12 = this.m12;\r
-               if (b!=0) {\r
+               if (sinb!=0) {\r
                        cosa = (rot02<<24) / sinb;// <Optimize/>cosa = rot[0][2] / sinb;\r
                        sina = (rot12<<24) / sinb;// <Optimize/>sina = rot[1][2] / sinb;\r
                        if (cosa > NyMath.FIXEDFLOAT24_1) {\r
@@ -159,7 +161,7 @@ public class NyARFixedFloatRotMatrix extends NyARFixedFloat24Matrix33
                                sina = -NyMath.FIXEDFLOAT24_1;\r
                                cosa = 0;\r
                        }\r
-                       a = (int)(Math.acos((double)cosa/NyMath.FIXEDFLOAT24_1)*NyMath.FIXEDFLOAT16_1);\r
+                       a = (int)NyMath.acosFixedFloat16((int)cosa);\r
                        if (sina < 0) {\r
                                a = -a;\r
                        }\r
@@ -191,7 +193,7 @@ public class NyARFixedFloatRotMatrix extends NyARFixedFloat24Matrix33
                                sinc = -NyMath.FIXEDFLOAT24_1;\r
                                cosc = 0;\r
                        }\r
-                       c = (int)(Math.acos((double)cosc/NyMath.FIXEDFLOAT24_1)*NyMath.FIXEDFLOAT16_1);\r
+                       c = (int)NyMath.acosFixedFloat16((int)cosc);\r
                        if (sinc < 0) {\r
                                c = -c;\r
                        }\r
@@ -221,7 +223,7 @@ public class NyARFixedFloatRotMatrix extends NyARFixedFloat24Matrix33
                                sinc = -NyMath.FIXEDFLOAT24_1;\r
                                cosc = 0;\r
                        }\r
-                       c = (int)(Math.acos((double)cosc/NyMath.FIXEDFLOAT24_1)*NyMath.FIXEDFLOAT16_1);\r
+                       c = (int)NyMath.acosFixedFloat16((int)cosc);\r
                        if (sinc < 0) {\r
                                c = -c;\r
                        }\r
index bcbb705..a378a52 100644 (file)
@@ -45,7 +45,7 @@ import jp.nyatla.nyartoolkit.core2.types.NyARFixedFloat16Point3d;
  */\r
 public class NyARFixedFloatRotTransOptimize_O2\r
 {\r
-       private final static int AR_GET_TRANS_MAT_MAX_LOOP_COUNT = 5;// #define AR_GET_TRANS_MAT_MAX_LOOP_COUNT 5\r
+       private final static int AR_GET_TRANS_MAT_MAX_LOOP_COUNT = 1;// #define AR_GET_TRANS_MAT_MAX_LOOP_COUNT 5\r
        private final NyARPerspectiveProjectionMatrix _projection_mat_ref;\r
        public NyARFixedFloatRotTransOptimize_O2(NyARPerspectiveProjectionMatrix i_projection_mat_ref)\r
        {\r
index 98c6ed0..d126bc6 100644 (file)
@@ -34,170 +34,451 @@ package jp.nyatla.nyartoolkit.sandbox.x2;
 import jp.nyatla.nyartoolkit.NyARException;\r
 import jp.nyatla.nyartoolkit.core.NyARMat;\r
 import jp.nyatla.nyartoolkit.core.types.*;\r
-import jp.nyatla.nyartoolkit.core.types.matrix.*;\r
 import jp.nyatla.nyartoolkit.core.param.*;\r
-import jp.nyatla.nyartoolkit.core2.types.matrix.NyARFixedFloat16Matrix33;\r
+import jp.nyatla.nyartoolkit.core2.types.matrix.*;\r
+import jp.nyatla.nyartoolkit.core2.types.*;\r
 \r
 public class NyARFixedFloatRotVector\r
 {\r
+    //publicメンバ達\r
+    public long v1;\r
 \r
-       //publicメンバ達\r
-       public double v1;\r
+    public long v2;\r
 \r
-       public double v2;\r
+    public long v3;\r
 \r
-       public double v3;\r
+    //privateメンバ達\r
+    private NyARFixedFloat16Matrix33 _cmat = new NyARFixedFloat16Matrix33();\r
 \r
-       //privateメンバ達\r
-       private NyARFixedFloat16Matrix33 _cmat=new NyARFixedFloat16Matrix33();\r
-       \r
-       private NyARPerspectiveProjectionMatrix _projection_mat_ref;\r
+    private NyARPerspectiveProjectionMatrix _projection_mat_ref;\r
 \r
-       private double[][] _inv_cpara_array_ref;\r
+    private double[][] _inv_cpara_array_ref;\r
+\r
+    public NyARFixedFloatRotVector(NyARPerspectiveProjectionMatrix i_cmat) throws NyARException\r
+    {\r
+       final NyARMat mat_a = new NyARMat(3, 3);\r
+        final double[][] a_array = mat_a.getArray();\r
+\r
+        a_array[0][0] = i_cmat.m00;\r
+        a_array[0][1] = i_cmat.m01;\r
+        a_array[0][2] = i_cmat.m02;\r
+        a_array[1][0] = i_cmat.m10;\r
+        a_array[1][1] = i_cmat.m11;\r
+        a_array[1][2] = i_cmat.m12;\r
+        a_array[2][0] = i_cmat.m20;\r
+        a_array[2][1] = i_cmat.m21;\r
+        a_array[2][2] = i_cmat.m22;\r
+\r
+        mat_a.matrixSelfInv();\r
+        this._projection_mat_ref = i_cmat;\r
+        //FixedFloat16にコピー\r
+        this._cmat.m00 = (long)(i_cmat.m00 * NyMath.FIXEDFLOAT24_1);\r
+        this._cmat.m01 = (long)(i_cmat.m01 * NyMath.FIXEDFLOAT24_1);\r
+        this._cmat.m02 = (long)(i_cmat.m02 * NyMath.FIXEDFLOAT24_1);\r
+        this._cmat.m10 = (long)(i_cmat.m10 * NyMath.FIXEDFLOAT24_1);\r
+        this._cmat.m11 = (long)(i_cmat.m11 * NyMath.FIXEDFLOAT24_1);\r
+        this._cmat.m12 = (long)(i_cmat.m12 * NyMath.FIXEDFLOAT24_1);\r
+        this._cmat.m20 = (long)(i_cmat.m20 * NyMath.FIXEDFLOAT24_1);\r
+        this._cmat.m21 = (long)(i_cmat.m21 * NyMath.FIXEDFLOAT24_1);\r
+        this._cmat.m22 = (long)(i_cmat.m22 * NyMath.FIXEDFLOAT24_1);\r
+        this._inv_cpara_array_ref = mat_a.getArray();\r
+        //GCない言語のときは、ここで配列の所有権委譲してね!\r
+    }\r
+\r
+    /**\r
+     * 2直線に直交するベクトルを計算する・・・だと思う。\r
+     * @param i_linear1\r
+     * @param i_linear2\r
+     */\r
+    public void exteriorProductFromLinear(NyARLinear i_linear1, NyARLinear i_linear2)\r
+    {\r
+        //1行目\r
+        NyARPerspectiveProjectionMatrix cmat = this._projection_mat_ref;\r
+        final double w1 = i_linear1.run * i_linear2.rise - i_linear2.run * i_linear1.rise;\r
+        final double w2 = i_linear1.rise * i_linear2.intercept - i_linear2.rise * i_linear1.intercept;\r
+        final double w3 = i_linear1.intercept * i_linear2.run - i_linear2.intercept * i_linear1.run;\r
+\r
+        final double m0 = w1 * (cmat.m01 * cmat.m12 - cmat.m02 * cmat.m11) + w2 * cmat.m11 - w3 * cmat.m01;//w1 * (cpara[0 * 4 + 1] * cpara[1 * 4 + 2] - cpara[0 * 4 + 2] * cpara[1 * 4 + 1]) + w2 * cpara[1 * 4 + 1] - w3 * cpara[0 * 4 + 1];\r
+        final double m1 = -w1 * cmat.m00 * cmat.m12 + w3 * cmat.m00;//-w1 * cpara[0 * 4 + 0] * cpara[1 * 4 + 2] + w3 * cpara[0 * 4 + 0];\r
+        final double m2 = w1 * cmat.m00 * cmat.m11;//w1 * cpara[0 * 4 + 0] * cpara[1 * 4 + 1];\r
+        final double w = Math.sqrt(m0 * m0 + m1 * m1 + m2 * m2);\r
+        this.v1 = (long)(m0 * NyMath.FIXEDFLOAT16_1 / w);\r
+        this.v2 = (long)(m1 * NyMath.FIXEDFLOAT16_1 / w);\r
+        this.v3 = (long)(m2 * NyMath.FIXEDFLOAT16_1 / w);\r
+        return;\r
+    }\r
+\r
+    /**\r
+     * static int check_dir( double dir[3], double st[2], double ed[2],double cpara[3][4] ) Optimize:STEP[526->468]\r
+     * ベクトルの開始/終了座標を指定して、ベクトルの方向を調整する。\r
+     * @param i_start_vertex\r
+     * @param i_end_vertex\r
+     * @param cpara\r
+     */\r
+    public void checkVectorByVertex(NyARFixedFloat16Point2d i_start_vertex, NyARFixedFloat16Point2d i_end_vertex) throws NyARException\r
+    {\r
+        long h;\r
+        final double[][] inv_cpara = this._inv_cpara_array_ref;\r
+        final double stx = (double)(i_start_vertex.x / NyMath.FIXEDFLOAT16_1);\r
+        final double sty = (double)(i_start_vertex.y / NyMath.FIXEDFLOAT16_1);\r
+\r
+        //final double[] world = __checkVectorByVertex_world;// [2][3];\r
+        final long world0 = (long)((inv_cpara[0][0] * stx + inv_cpara[0][1] * sty + inv_cpara[0][2]) * 10.0 * NyMath.FIXEDFLOAT16_1);// mat_a->m[0]*st[0]*10.0+\r
+        final long world1 = (long)((inv_cpara[1][0] * stx + inv_cpara[1][1] * sty + inv_cpara[1][2]) * 10.0 * NyMath.FIXEDFLOAT16_1);// mat_a->m[3]*st[0]*10.0+\r
+        final long world2 = (long)((inv_cpara[2][0] * stx + inv_cpara[2][1] * sty + inv_cpara[2][2]) * 10.0 * NyMath.FIXEDFLOAT16_1);// mat_a->m[6]*st[0]*10.0+\r
+        final long world3 = world0 + (this.v1);\r
+        final long world4 = world1 + (this.v2);\r
+        final long world5 = world2 + (this.v3);\r
+        // </Optimize>\r
+\r
+        //final double[] camera = __checkVectorByVertex_camera;// [2][2];\r
+        //h = cpara[2 * 4 + 0] * world0 + cpara[2 * 4 + 1] * world1 + cpara[2 * 4 + 2] * world2;\r
+        h = (this._cmat.m20 * world0 + this._cmat.m21 * world1 + this._cmat.m22 * world2) >> 16;\r
+        if (h == 0)\r
+        {\r
+            throw new NyARException();\r
+        }\r
+        //final double camera0 = (cpara[0 * 4 + 0] * world0 + cpara[0 * 4 + 1] * world1 + cpara[0 * 4 + 2] * world2) / h;\r
+        //final double camera1 = (cpara[1 * 4 + 0] * world0 + cpara[1 * 4 + 1] * world1 + cpara[1 * 4 + 2] * world2) / h;\r
+        final long camera0 = (this._cmat.m00 * world0 + this._cmat.m01 * world1 + this._cmat.m02 * world2) / h;\r
+        final long camera1 = (this._cmat.m10 * world0 + this._cmat.m11 * world1 + this._cmat.m12 * world2) / h;\r
+\r
+        //h = cpara[2 * 4 + 0] * world3 + cpara[2 * 4 + 1] * world4 + cpara[2 * 4 + 2] * world5;\r
+        h = (this._cmat.m20 * world3 + this._cmat.m21 * world4 + this._cmat.m22 * world5) >> 16;\r
+        if (h == 0)\r
+        {\r
+            throw new NyARException();\r
+        }\r
+        //final double camera2 = (cpara[0 * 4 + 0] * world3 + cpara[0 * 4 + 1] * world4 + cpara[0 * 4 + 2] * world5) / h;\r
+        //final double camera3 = (cpara[1 * 4 + 0] * world3 + cpara[1 * 4 + 1] * world4 + cpara[1 * 4 + 2] * world5) / h;\r
+        final long camera2 = (this._cmat.m00 * world3 + this._cmat.m01 * world4 + this._cmat.m02 * world5) / h;\r
+        final long camera3 = (this._cmat.m10 * world3 + this._cmat.m11 * world4 + this._cmat.m12 * world5) / h;\r
 \r
-       public NyARFixedFloatRotVector(NyARPerspectiveProjectionMatrix i_cmat) throws NyARException\r
-       {\r
-               NyARMat mat_a = new NyARMat(3, 3);\r
-               double[][] a_array = mat_a.getArray();\r
-               \r
-               a_array[0][0] =i_cmat.m00;\r
-               a_array[0][1] =i_cmat.m01;\r
-               a_array[0][2] =i_cmat.m02;\r
-               a_array[1][0] =i_cmat.m10;\r
-               a_array[1][1] =i_cmat.m11;\r
-               a_array[1][2] =i_cmat.m12;\r
-               a_array[2][0] =i_cmat.m20;\r
-               a_array[2][1] =i_cmat.m21;\r
-               a_array[2][2] =i_cmat.m22;\r
-               \r
-               mat_a.matrixSelfInv();\r
-               this._projection_mat_ref = i_cmat;\r
-               //FixedFloat16にコピー\r
-               this._cmat.m00=(long)(i_cmat.m00*0x10000);\r
-               this._cmat.m01=(long)(i_cmat.m01*0x10000);\r
-               this._cmat.m02=(long)(i_cmat.m02*0x10000);\r
-               this._cmat.m10=(long)(i_cmat.m10*0x10000);\r
-               this._cmat.m11=(long)(i_cmat.m11*0x10000);\r
-               this._cmat.m12=(long)(i_cmat.m12*0x10000);\r
-               this._cmat.m20=(long)(i_cmat.m20*0x10000);\r
-               this._cmat.m21=(long)(i_cmat.m21*0x10000);\r
-               this._cmat.m22=(long)(i_cmat.m22*0x10000);\r
-               this._inv_cpara_array_ref = mat_a.getArray();\r
-               //GCない言語のときは、ここで配列の所有権委譲してね!\r
-       }\r
-\r
-       /**\r
-        * 2直線に直交するベクトルを計算する・・・だと思う。\r
-        * @param i_linear1\r
-        * @param i_linear2\r
-        */\r
-       public void exteriorProductFromLinear(NyARLinear i_linear1, NyARLinear i_linear2)\r
-       {\r
-               //1行目\r
-               final NyARPerspectiveProjectionMatrix cmat= this._projection_mat_ref;\r
-               final double w1 = i_linear1.run * i_linear2.rise - i_linear2.run * i_linear1.rise;\r
-               final double w2 = i_linear1.rise * i_linear2.intercept - i_linear2.rise * i_linear1.intercept;\r
-               final double w3 = i_linear1.intercept * i_linear2.run - i_linear2.intercept * i_linear1.run;\r
-\r
-               final double m0 = w1 * (cmat.m01 * cmat.m12 - cmat.m02 * cmat.m11) + w2 * cmat.m11 - w3 * cmat.m01;//w1 * (cpara[0 * 4 + 1] * cpara[1 * 4 + 2] - cpara[0 * 4 + 2] * cpara[1 * 4 + 1]) + w2 * cpara[1 * 4 + 1] - w3 * cpara[0 * 4 + 1];\r
-               final double m1 = -w1 * cmat.m00 * cmat.m12 + w3 * cmat.m00;//-w1 * cpara[0 * 4 + 0] * cpara[1 * 4 + 2] + w3 * cpara[0 * 4 + 0];\r
-               final double m2 = w1 * cmat.m00 * cmat.m11;//w1 * cpara[0 * 4 + 0] * cpara[1 * 4 + 1];\r
-               final double w = Math.sqrt(m0 * m0 + m1 * m1 + m2 * m2);\r
-               this.v1 = m0 / w;\r
-               this.v2 = m1 / w;\r
-               this.v3 = m2 / w;\r
-               return;\r
-       }\r
-\r
-       /**\r
-        * static int check_dir( double dir[3], double st[2], double ed[2],double cpara[3][4] ) Optimize:STEP[526->468]\r
-        * ベクトルの開始/終了座標を指定して、ベクトルの方向を調整する。\r
-        * @param i_start_vertex\r
-        * @param i_end_vertex\r
-        * @param cpara\r
-        */\r
-       public void checkVectorByVertex(final NyARDoublePoint2d i_start_vertex, final NyARDoublePoint2d i_end_vertex) throws NyARException\r
-       {\r
-               double h;\r
-               final double[][] inv_cpara = this._inv_cpara_array_ref;\r
-               //final double[] world = __checkVectorByVertex_world;// [2][3];\r
-               final double world0 = inv_cpara[0][0] * i_start_vertex.x * 10.0 + inv_cpara[0][1] * i_start_vertex.y * 10.0 + inv_cpara[0][2] * 10.0;// mat_a->m[0]*st[0]*10.0+\r
-               final double world1 = inv_cpara[1][0] * i_start_vertex.x * 10.0 + inv_cpara[1][1] * i_start_vertex.y * 10.0 + inv_cpara[1][2] * 10.0;// mat_a->m[3]*st[0]*10.0+\r
-               final double world2 = inv_cpara[2][0] * i_start_vertex.x * 10.0 + inv_cpara[2][1] * i_start_vertex.y * 10.0 + inv_cpara[2][2] * 10.0;// mat_a->m[6]*st[0]*10.0+\r
-               final double world3 = world0 + this.v1;\r
-               final double world4 = world1 + this.v2;\r
-               final double world5 = world2 + this.v3;\r
-               // </Optimize>\r
-\r
-               //final double[] camera = __checkVectorByVertex_camera;// [2][2];\r
-               final NyARPerspectiveProjectionMatrix cmat= this._projection_mat_ref;\r
-               //h = cpara[2 * 4 + 0] * world0 + cpara[2 * 4 + 1] * world1 + cpara[2 * 4 + 2] * world2;\r
-               h = cmat.m20 * world0 + cmat.m21 * world1 + cmat.m22 * world2;\r
-               if (h == 0.0) {\r
-                       throw new NyARException();\r
-               }\r
-               //final double camera0 = (cpara[0 * 4 + 0] * world0 + cpara[0 * 4 + 1] * world1 + cpara[0 * 4 + 2] * world2) / h;\r
-               //final double camera1 = (cpara[1 * 4 + 0] * world0 + cpara[1 * 4 + 1] * world1 + cpara[1 * 4 + 2] * world2) / h;\r
-               final double camera0 = (cmat.m00 * world0 + cmat.m01 * world1 + cmat.m02 * world2) / h;\r
-               final double camera1 = (cmat.m10 * world0 + cmat.m11 * world1 + cmat.m12 * world2) / h;\r
-\r
-               //h = cpara[2 * 4 + 0] * world3 + cpara[2 * 4 + 1] * world4 + cpara[2 * 4 + 2] * world5;\r
-               h = cmat.m20 * world3 + cmat.m21 * world4 + cmat.m22 * world5;\r
-               if (h == 0.0) {\r
-                       throw new NyARException();\r
-               }\r
-               //final double camera2 = (cpara[0 * 4 + 0] * world3 + cpara[0 * 4 + 1] * world4 + cpara[0 * 4 + 2] * world5) / h;\r
-               //final double camera3 = (cpara[1 * 4 + 0] * world3 + cpara[1 * 4 + 1] * world4 + cpara[1 * 4 + 2] * world5) / h;\r
-               final double camera2 = (cmat.m00 * world3 + cmat.m01 * world4 + cmat.m02 * world5) / h;\r
-               final double camera3 = (cmat.m10 * world3 + cmat.m11 * world4 + cmat.m12 * world5) / h;\r
-\r
-               final double v = (i_end_vertex.x - i_start_vertex.x) * (camera2 - camera0) + (i_end_vertex.y - i_start_vertex.y) * (camera3 - camera1);\r
-               if (v < 0) {\r
-                       this.v1 = -this.v1;\r
-                       this.v2 = -this.v2;\r
-                       this.v3 = -this.v3;\r
-               }\r
-       }\r
-       /**\r
-        * int check_rotation( double rot[2][3] )\r
-        * 2つのベクトル引数の調整をする?\r
-        * @param i_r\r
-        * @throws NyARException\r
-        */\r
 \r
+        long v = ((i_end_vertex.x - i_start_vertex.x) * (camera2 - camera0) + (i_end_vertex.y - i_start_vertex.y) * (camera3 - camera1)) >> 16;\r
+\r
+        if (v < 0)\r
+        {\r
+            this.v1 = -this.v1;\r
+            this.v2 = -this.v2;\r
+            this.v3 = -this.v3;\r
+        }\r
+\r
+        return;\r
+    }\r
+    /**\r
+     * int check_rotation( double rot[2][3] )\r
+     * 2つのベクトル引数の調整をする?\r
+     * @param i_r\r
+     * @throws NyARException\r
+     */\r
+/*\r
+    public static void checkRotation(NyARFixedFloatRotVector io_vec1, NyARFixedFloatRotVector io_vec2) throws NyARException\r
+    {\r
+        long w;\r
+        int f;\r
+\r
+        long vec10 = io_vec1.v1;\r
+        long vec11 = io_vec1.v2;\r
+        long vec12 = io_vec1.v3;\r
+        long vec20 = io_vec2.v1;\r
+        long vec21 = io_vec2.v2;\r
+        long vec22 = io_vec2.v3;\r
+\r
+        long vec30 = (vec11 * vec22 - vec12 * vec21) >> 24;\r
+        long vec31 = (vec12 * vec20 - vec10 * vec22) >> 24;\r
+        long vec32 = (vec10 * vec21 - vec11 * vec20) >> 24;\r
+        w = NyMath.sqrtFixdFloat((vec30 * vec30 + vec31 * vec31 + vec32 * vec32) >> 24, 24);\r
+        if (w == 0)\r
+        {\r
+            throw new NyARException();\r
+        }\r
+        vec30 = (vec30 << 24) / w;\r
+        vec31 = (vec31 << 24) / w;\r
+        vec32 = (vec32 << 24) / w;\r
+\r
+        long cb = (vec10 * vec20 + vec11 * vec21 + vec12 * vec22) >> 24;\r
+        if (cb < 0)\r
+        {\r
+            cb = -cb;//cb *= -1.0;                     \r
+        }\r
+        long ca = (NyMath.sqrtFixdFloat(cb + NyMath.FIXEDFLOAT24_1, 24) + NyMath.sqrtFixdFloat(NyMath.FIXEDFLOAT24_1 - cb, 24)) >> 1;\r
+\r
+        if (vec31 * vec10 - vec11 * vec30 != 0)\r
+        {\r
+            f = 0;\r
+        }\r
+        else\r
+        {\r
+            if (vec32 * vec10 - vec12 * vec30 != 0)\r
+            {\r
+                w = vec11; vec11 = vec12; vec12 = w;\r
+                w = vec31; vec31 = vec32; vec32 = w;\r
+                f = 1;\r
+            }\r
+            else\r
+            {\r
+                w = vec10; vec10 = vec12; vec12 = w;\r
+                w = vec30; vec30 = vec32; vec32 = w;\r
+                f = 2;\r
+            }\r
+        }\r
+        if (vec31 * vec10 - vec11 * vec30 == 0)\r
+        {\r
+            throw new NyARException();\r
+        }\r
+\r
+        long k1, k2, k3, k4;\r
+        long a, b, c, d;\r
+        long p1, q1, r1;\r
+        long p2, q2, r2;\r
+        long p3, q3, r3;\r
+        long p4, q4, r4;\r
+\r
+\r
+        k1 = (vec11 * vec32 - vec31 * vec12) / ((vec31 * vec10 - vec11 * vec30) >> 24);\r
+        k2 = (vec31 * ca) / ((vec31 * vec10 - vec11 * vec30) >> 24);\r
+        k3 = (vec10 * vec32 - vec30 * vec12) / ((vec30 * vec11 - vec10 * vec31) >> 24);\r
+        k4 = (vec30 * ca) / ((vec30 * vec11 - vec10 * vec31) >> 24);\r
+\r
+        a = ((k1 * k1 + k3 * k3) >> 24) + NyMath.FIXEDFLOAT24_1;\r
+        b = ((k1 * k2 + k3 * k4) >> 24);\r
+        c = ((k2 * k2 + k4 * k4) >> 24) - NyMath.FIXEDFLOAT24_1;\r
+\r
+        d = ((b>>8) * (b>>8) - (a>>8) * (c>>8)) >> 8;\r
+        if (d < 0)\r
+        {\r
+            throw new NyARException();\r
+        }\r
+        r1 = ((-b + NyMath.sqrtFixdFloat(d, 24)) << 24) / a;\r
+        p1 = ((k1 * r1) >> 24) + k2;\r
+        q1 = ((k3 * r1) >> 24) + k4;\r
+        r2 = ((-b - NyMath.sqrtFixdFloat(d, 24)) << 24) / a;\r
+        p2 = ((k1 * r2) >> 24) + k2;\r
+        q2 = ((k3 * r2) >> 24) + k4;\r
+        if (f == 1)\r
+        {\r
+            w = q1; q1 = r1; r1 = w;\r
+            w = q2; q2 = r2; r2 = w;\r
+            w = vec11; vec11 = vec12; vec12 = w;\r
+            w = vec31; vec31 = vec32; vec32 = w;\r
+            f = 0;\r
+        }\r
+        if (f == 2)\r
+        {\r
+            w = p1; p1 = r1; r1 = w;\r
+            w = p2; p2 = r2; r2 = w;\r
+            w = vec10; vec10 = vec12; vec12 = w;\r
+            w = vec30; vec30 = vec32; vec32 = w;\r
+            f = 0;\r
+        }\r
+\r
+        if (vec31 * vec20 - vec21 * vec30 != 0)\r
+        {\r
+            f = 0;\r
+        }\r
+        else\r
+        {\r
+            if (vec32 * vec20 - vec22 * vec30 != 0)\r
+            {\r
+                w = vec21; vec21 = vec22; vec22 = w;\r
+                w = vec31; vec31 = vec32; vec32 = w;\r
+                f = 1;\r
+            }\r
+            else\r
+            {\r
+                w = vec20; vec20 = vec22; vec22 = w;\r
+                w = vec30; vec30 = vec32; vec32 = w;\r
+                f = 2;\r
+            }\r
+        }\r
+        if (vec31 * vec20 - vec21 * vec30 == 0)\r
+        {\r
+            throw new NyARException();\r
+        }\r
+        k1 = (vec21 * vec32 - vec31 * vec22) / ((vec31 * vec20 - vec21 * vec30) >> 24);\r
+        k2 = (vec31 * ca) / ((vec31 * vec20 - vec21 * vec30) >> 24);\r
+        k3 = (vec20 * vec32 - vec30 * vec22) / ((vec30 * vec21 - vec20 * vec31) >> 24);\r
+        k4 = (vec30 * ca) / ((vec30 * vec21 - vec20 * vec31) >> 24);\r
+\r
+        a = ((k1 * k1 + k3 * k3) >> 24) + NyMath.FIXEDFLOAT24_1;\r
+        b = ((k1 * k2 + k3 * k4) >> 24);\r
+        c = ((k2 * k2 + k4 * k4) >> 24) - NyMath.FIXEDFLOAT24_1;\r
+\r
+        d = ((b>>8) * (b>>8) - (a>>8) * (c>>8)) >> 8;\r
+        if (d < 0)\r
+        {\r
+            throw new NyARException();\r
+        }\r
+        r3 = ((-b + NyMath.sqrtFixdFloat(d, 24)) << 24) / a;\r
+        p3 = ((k1 * r3) >> 24) + k2;\r
+        q3 = ((k3 * r3) >> 24) + k4;\r
+        r4 = ((-b - NyMath.sqrtFixdFloat(d, 24)) << 24) / a;\r
+        p4 = ((k1 * r4) >> 24) + k2;\r
+        q4 = ((k3 * r4) >> 24) + k4;\r
+        if (f == 1)\r
+        {\r
+            w = q3; q3 = r3; r3 = w;\r
+            w = q4; q4 = r4; r4 = w;\r
+            w = vec21; vec21 = vec22; vec22 = w;\r
+            w = vec31; vec31 = vec32; vec32 = w;\r
+            f = 0;\r
+        }\r
+        if (f == 2)\r
+        {\r
+            w = p3; p3 = r3; r3 = w;\r
+            w = p4; p4 = r4; r4 = w;\r
+            w = vec20; vec20 = vec22; vec22 = w;\r
+            w = vec30; vec30 = vec32; vec32 = w;\r
+            f = 0;\r
+        }\r
+\r
+        long e1 = (p1 * p3 + q1 * q3 + r1 * r3) >> 24;\r
+        if (e1 < 0)\r
+        {\r
+            e1 = -e1;\r
+        }\r
+        long e2 = (p1 * p4 + q1 * q4 + r1 * r4) >> 24;\r
+        if (e2 < 0)\r
+        {\r
+            e2 = -e2;\r
+        }\r
+        long e3 = (p2 * p3 + q2 * q3 + r2 * r3) >> 24;\r
+        if (e3 < 0)\r
+        {\r
+            e3 = -e3;\r
+        }\r
+        long e4 = (p2 * p4 + q2 * q4 + r2 * r4) >> 24;\r
+        if (e4 < 0)\r
+        {\r
+            e4 = -e4;\r
+        }\r
+        if (e1 < e2)\r
+        {\r
+            if (e1 < e3)\r
+            {\r
+                if (e1 < e4)\r
+                {\r
+                    io_vec1.v1 = p1;\r
+                    io_vec1.v2 = q1;\r
+                    io_vec1.v3 = r1;\r
+                    io_vec2.v1 = p3;\r
+                    io_vec2.v2 = q3;\r
+                    io_vec2.v3 = r3;\r
+                }\r
+                else\r
+                {\r
+                    io_vec1.v1 = p2;\r
+                    io_vec1.v2 = q2;\r
+                    io_vec1.v3 = r2;\r
+                    io_vec2.v1 = p4;\r
+                    io_vec2.v2 = q4;\r
+                    io_vec2.v3 = r4;\r
+                }\r
+            }\r
+            else\r
+            {\r
+                if (e3 < e4)\r
+                {\r
+                    io_vec1.v1 = p2;\r
+                    io_vec1.v2 = q2;\r
+                    io_vec1.v3 = r2;\r
+                    io_vec2.v1 = p3;\r
+                    io_vec2.v2 = q3;\r
+                    io_vec2.v3 = r3;\r
+                }\r
+                else\r
+                {\r
+                    io_vec1.v1 = p2;\r
+                    io_vec1.v2 = q2;\r
+                    io_vec1.v3 = r2;\r
+                    io_vec2.v1 = p4;\r
+                    io_vec2.v2 = q4;\r
+                    io_vec2.v3 = r4;\r
+                }\r
+            }\r
+        }\r
+        else\r
+        {\r
+            if (e2 < e3)\r
+            {\r
+                if (e2 < e4)\r
+                {\r
+                    io_vec1.v1 = p1;\r
+                    io_vec1.v2 = q1;\r
+                    io_vec1.v3 = r1;\r
+                    io_vec2.v1 = p4;\r
+                    io_vec2.v2 = q4;\r
+                    io_vec2.v3 = r4;\r
+                }\r
+                else\r
+                {\r
+                    io_vec1.v1 = p2;\r
+                    io_vec1.v2 = q2;\r
+                    io_vec1.v3 = r2;\r
+                    io_vec2.v1 = p4;\r
+                    io_vec2.v2 = q4;\r
+                    io_vec2.v3 = r4;\r
+                }\r
+            }\r
+            else\r
+            {\r
+                if (e3 < e4)\r
+                {\r
+                    io_vec1.v1 = p2;\r
+                    io_vec1.v2 = q2;\r
+                    io_vec1.v3 = r2;\r
+                    io_vec2.v1 = p3;\r
+                    io_vec2.v2 = q3;\r
+                    io_vec2.v3 = r3;\r
+                }\r
+                else\r
+                {\r
+                    io_vec1.v1 = p2;\r
+                    io_vec1.v2 = q2;\r
+                    io_vec1.v3 = r2;\r
+                    io_vec2.v1 = p4;\r
+                    io_vec2.v2 = q4;\r
+                    io_vec2.v3 = r4;\r
+                }\r
+            }\r
+        }\r
+        return;\r
+    }*/\r
+       //16bit固定小数点版\r
        public final static void checkRotation(NyARFixedFloatRotVector io_vec1, NyARFixedFloatRotVector io_vec2) throws NyARException\r
        {\r
-               double w;\r
+               long w;\r
                int f;\r
 \r
-               double vec10 = io_vec1.v1;\r
-               double vec11 = io_vec1.v2;\r
-               double vec12 = io_vec1.v3;\r
-               double vec20 = io_vec2.v1;\r
-               double vec21 = io_vec2.v2;\r
-               double vec22 = io_vec2.v3;\r
+               long vec10 = io_vec1.v1;\r
+               long vec11 = io_vec1.v2;\r
+               long vec12 = io_vec1.v3;\r
+               long vec20 = io_vec2.v1;\r
+               long vec21 = io_vec2.v2;\r
+               long vec22 = io_vec2.v3;\r
                \r
-               double vec30 = vec11 * vec22 - vec12 * vec21;\r
-               double vec31 = vec12 * vec20 - vec10 * vec22;\r
-               double vec32 = vec10 * vec21 - vec11 * vec20;\r
-               w = Math.sqrt(vec30 * vec30 + vec31 * vec31 + vec32 * vec32);\r
-               if (w == 0.0) {\r
+               long vec30 = (vec11 * vec22 - vec12 * vec21)>>16;\r
+               long vec31 = (vec12 * vec20 - vec10 * vec22)>>16;\r
+               long vec32 = (vec10 * vec21 - vec11 * vec20)>>16;\r
+               w = NyMath.sqrtFixdFloat16((vec30 * vec30 + vec31 * vec31 + vec32 * vec32)>>16);\r
+               if (w == 0) {\r
                        throw new NyARException();\r
                }\r
-               vec30 /= w;\r
-               vec31 /= w;\r
-               vec32 /= w;\r
+               vec30= (vec30<<16)/w;\r
+               vec31= (vec31<<16)/w;\r
+               vec32= (vec32<<16)/w;\r
 \r
-               double cb = vec10 * vec20 + vec11 * vec21 + vec12 * vec22;\r
+               long cb = (vec10 * vec20 + vec11 * vec21 + vec12 * vec22)>>16;\r
                if (cb < 0){\r
                        cb=-cb;//cb *= -1.0;                    \r
                }\r
-               final double ca = (Math.sqrt(cb + 1.0) + Math.sqrt(1.0 - cb)) * 0.5;\r
+               final long ca = (NyMath.sqrtFixdFloat16(cb + NyMath.FIXEDFLOAT16_1) + NyMath.sqrtFixdFloat16(NyMath.FIXEDFLOAT16_1 - cb)) >>1;\r
 \r
-               if (vec31 * vec10 - vec11 * vec30 != 0.0) {\r
+               if (vec31 * vec10 - vec11 * vec30 != 0) {\r
                        f = 0;\r
                } else {\r
-                       if (vec32 * vec10 - vec12 * vec30 != 0.0) {\r
+                       if (vec32 * vec10 - vec12 * vec30 != 0) {\r
                                w = vec11;vec11 = vec12;vec12 = w;\r
                                w = vec31;vec31 = vec32;vec32 = w;\r
                                f = 1;\r
@@ -207,37 +488,37 @@ public class NyARFixedFloatRotVector
                                f = 2;\r
                        }\r
                }\r
-               if (vec31 * vec10 - vec11 * vec30 == 0.0) {\r
+               if (vec31 * vec10 - vec11 * vec30 == 0) {\r
                        throw new NyARException();\r
                }\r
                \r
-               double k1,k2,k3,k4;\r
-               double a, b, c, d;\r
-               double p1, q1, r1;\r
-               double p2, q2, r2;\r
-               double p3, q3, r3;\r
-               double p4, q4, r4;              \r
+               long k1,k2,k3,k4;\r
+               long a, b, c, d;\r
+               long p1, q1, r1;\r
+               long p2, q2, r2;\r
+               long p3, q3, r3;\r
+               long p4, q4, r4;                \r
                \r
                \r
-               k1 = (vec11 * vec32 - vec31 * vec12) / (vec31 * vec10 - vec11 * vec30);\r
-               k2 = (vec31 * ca) / (vec31 * vec10 - vec11 * vec30);\r
-               k3 = (vec10 * vec32 - vec30 * vec12) / (vec30 * vec11 - vec10 * vec31);\r
-               k4 = (vec30 * ca) / (vec30 * vec11 - vec10 * vec31);\r
+               k1 = ((vec11 * vec32 - vec31 * vec12)) / ((vec31 * vec10 - vec11 * vec30)>>16);\r
+               k2 = (vec31 * ca) / ((vec31 * vec10 - vec11 * vec30)>>16);\r
+               k3 = (vec10 * vec32 - vec30 * vec12) / ((vec30 * vec11 - vec10 * vec31)>>16);\r
+               k4 = (vec30 * ca) / ((vec30 * vec11 - vec10 * vec31)>>16);\r
 \r
-               a = k1 * k1 + k3 * k3 + 1;\r
-               b = k1 * k2 + k3 * k4;\r
-               c = k2 * k2 + k4 * k4 - 1;\r
-\r
-               d = b * b - a * c;\r
+               a = ((k1 * k1 + k3 * k3)>>16) + NyMath.FIXEDFLOAT16_1;\r
+               b = ((k1 * k2 + k3 * k4)>>16);\r
+               c = ((k2 * k2 + k4 * k4)>>16) - NyMath.FIXEDFLOAT16_1;\r
+               d = (b*b - a*c)>>16;\r
                if (d < 0) {\r
-                       throw new NyARException();\r
+                       //誤差で計算エラーが頻発するのでExceptionはしない\r
+                       //throw new NyARException();\r
                }\r
-               r1 = (-b + Math.sqrt(d)) / a;\r
-               p1 = k1 * r1 + k2;\r
-               q1 = k3 * r1 + k4;\r
-               r2 = (-b - Math.sqrt(d)) / a;\r
-               p2 = k1 * r2 + k2;\r
-               q2 = k3 * r2 + k4;\r
+               r1 = ((-b + NyMath.sqrtFixdFloat16(d))<<16) / a;\r
+               p1 = ((k1 * r1)>>16) + k2;\r
+               q1 = ((k3 * r1)>>16) + k4;\r
+               r2 = ((-b - NyMath.sqrtFixdFloat16(d))<<16) / a;\r
+               p2 = ((k1 * r2)>>16) + k2;\r
+               q2 = ((k3 * r2)>>16) + k4;\r
                if (f == 1) {\r
                        w = q1;q1 = r1;r1 = w;\r
                        w = q2;q2 = r2;r2 = w;\r
@@ -253,10 +534,10 @@ public class NyARFixedFloatRotVector
                        f = 0;\r
                }\r
 \r
-               if (vec31 * vec20 - vec21 * vec30 != 0.0) {\r
+               if (vec31 * vec20 - vec21 * vec30 != 0) {\r
                        f = 0;\r
                } else {\r
-                       if (vec32 * vec20 - vec22 * vec30 != 0.0) {\r
+                       if (vec32 * vec20 - vec22 * vec30 != 0) {\r
                                w = vec21;vec21 = vec22;vec22 = w;\r
                                w = vec31;vec31 = vec32;vec32 = w;\r
                                f = 1;\r
@@ -266,28 +547,29 @@ public class NyARFixedFloatRotVector
                                f = 2;\r
                        }\r
                }\r
-               if (vec31 * vec20 - vec21 * vec30 == 0.0) {\r
+               if (vec31 * vec20 - vec21 * vec30 == 0) {\r
                        throw new NyARException();\r
                }\r
-               k1 = (vec21 * vec32 - vec31 * vec22) / (vec31 * vec20 - vec21 * vec30);\r
-               k2 = (vec31 * ca) / (vec31 * vec20 - vec21 * vec30);\r
-               k3 = (vec20 * vec32 - vec30 * vec22) / (vec30 * vec21 - vec20 * vec31);\r
-               k4 = (vec30 * ca) / (vec30 * vec21 - vec20 * vec31);\r
+               k1 = (vec21 * vec32 - vec31 * vec22) / ((vec31 * vec20 - vec21 * vec30)>>16);\r
+               k2 = (vec31 * ca) / ((vec31 * vec20 - vec21 * vec30)>>16);\r
+               k3 = (vec20 * vec32 - vec30 * vec22) / ((vec30 * vec21 - vec20 * vec31)>>16);\r
+               k4 = (vec30 * ca) / ((vec30 * vec21 - vec20 * vec31)>>16);\r
 \r
-               a = k1 * k1 + k3 * k3 + 1;\r
-               b = k1 * k2 + k3 * k4;\r
-               c = k2 * k2 + k4 * k4 - 1;\r
+               a = ((k1 * k1 + k3 * k3)>>16) + NyMath.FIXEDFLOAT16_1;\r
+               b = ((k1 * k2 + k3 * k4)>>16);\r
+               c = ((k2 * k2 + k4 * k4)>>16) - NyMath.FIXEDFLOAT16_1;\r
 \r
-               d = b * b - a * c;\r
+               d = (b*b - a*c)>>16;\r
                if (d < 0) {\r
-                       throw new NyARException();\r
+                       //誤差で計算エラーが頻発するのでExceptionはしない\r
+//                     throw new NyARException();\r
                }\r
-               r3 = (-b + Math.sqrt(d)) / a;\r
-               p3 = k1 * r3 + k2;\r
-               q3 = k3 * r3 + k4;\r
-               r4 = (-b - Math.sqrt(d)) / a;\r
-               p4 = k1 * r4 + k2;\r
-               q4 = k3 * r4 + k4;\r
+               r3 = ((-b + NyMath.sqrtFixdFloat16(d))<<16) / a;\r
+               p3 = ((k1 * r3)>>16) + k2;\r
+               q3 = ((k3 * r3)>>16) + k4;\r
+               r4 = ((-b - NyMath.sqrtFixdFloat16(d))<<16) / a;\r
+               p4 = ((k1 * r4)>>16) + k2;\r
+               q4 = ((k3 * r4)>>16) + k4;\r
                if (f == 1) {\r
                        w = q3;q3 = r3;r3 = w;\r
                        w = q4;q4 = r4;r4 = w;\r
@@ -303,19 +585,19 @@ public class NyARFixedFloatRotVector
                        f = 0;\r
                }\r
 \r
-               double e1 = p1 * p3 + q1 * q3 + r1 * r3;\r
+               long e1 = (p1 * p3 + q1 * q3 + r1 * r3)>>16;\r
                if (e1 < 0) {\r
                        e1 = -e1;\r
                }\r
-               double e2 = p1 * p4 + q1 * q4 + r1 * r4;\r
+               long e2 = (p1 * p4 + q1 * q4 + r1 * r4)>>16;\r
                if (e2 < 0) {\r
                        e2 = -e2;\r
                }\r
-               double e3 = p2 * p3 + q2 * q3 + r2 * r3;\r
+               long e3 = (p2 * p3 + q2 * q3 + r2 * r3)>>16;\r
                if (e3 < 0) {\r
                        e3 = -e3;\r
                }\r
-               double e4 = p2 * p4 + q2 * q4 + r2 * r4;\r
+               long e4 = (p2 * p4 + q2 * q4 + r2 * r4)>>16;\r
                if (e4 < 0) {\r
                        e4 = -e4;\r
                }\r
@@ -387,7 +669,7 @@ public class NyARFixedFloatRotVector
                                        io_vec2.v3 = r4;\r
                                }\r
                        }\r
-               }\r
+               }       \r
                return;\r
        }       \r
 }\r
index 33d5c9d..7ab06fa 100644 (file)
@@ -31,9 +31,7 @@
  */\r
 package jp.nyatla.nyartoolkit.sandbox.x2;\r
 \r
-import jp.nyatla.nyartoolkit.core.types.*;\r
-import jp.nyatla.nyartoolkit.core2.types.NyARFixedFloat16Point2d;\r
-import jp.nyatla.nyartoolkit.core2.types.NyARFixedFloat16Point3d;\r
+import jp.nyatla.nyartoolkit.core2.types.*;\r
 \r
 \r
 final public class NyARFixedFloatTransOffset\r
index a199dc8..93b3a64 100644 (file)
@@ -85,13 +85,12 @@ public class NyARSingleDetectMarker_X2
         */\r
        public NyARSingleDetectMarker_X2(NyARParam i_param, NyARCode i_code, double i_marker_width) throws NyARException\r
        {\r
-               final NyARIntSize scr_size=i_param.getScreenSize();             \r
-               final NyARFixedFloatCameraDistortionFactorMap dist_factor_map=new NyARFixedFloatCameraDistortionFactorMap(i_param.getDistortionFactor(),scr_size);\r
+               final NyARIntSize scr_size=i_param.getScreenSize();     \r
+        final NyARFixedFloatObserv2IdealMap dist_map = new NyARFixedFloatObserv2IdealMap(i_param.getDistortionFactor(), scr_size);\r
+               \r
                // 解析オブジェクトを作る\r
-//             this._square_detect = new NyARSquareDetector_X2(dist_factor_map,scr_size);\r
-//             this._transmat = new NyARTransMat_X2(i_param,dist_factor_map);\r
-               this._square_detect = new NyARSquareDetector(i_param.getDistortionFactor(),scr_size);\r
-               this._transmat = new NyARTransMat_X2(i_param,dist_factor_map);\r
+               this._square_detect = new NyARSquareDetector_X2(dist_map,scr_size);\r
+               this._transmat = new NyARTransMat_X2(i_param);\r
                // 比較コードを保存\r
                this._code = i_code;\r
                this._marker_width = i_marker_width;\r
index d9b75e8..53cb4a3 100644 (file)
@@ -61,7 +61,7 @@ public class NyARSquareDetector_X2 implements INyARSquareDetector
        private final NyARLabelingImage _limage;\r
 \r
        private final OverlapChecker _overlap_checker = new OverlapChecker();\r
-       private final NyARFixedFloatCameraDistortionFactorMap _dist_factor_ref;\r
+       private final NyARFixedFloatObserv2IdealMap _dist_factor_ref;\r
 //     private final NyARFixFloatCameraDistortionFactorMap _dist_factor_ref;\r
        private final NyARFixedFloatPca2d _pca;\r
 //     private final INyARPca2d _pca;\r
@@ -71,7 +71,7 @@ public class NyARSquareDetector_X2 implements INyARSquareDetector
         * \r
         * @param i_param\r
         */\r
-       public NyARSquareDetector_X2(NyARFixedFloatCameraDistortionFactorMap i_dist_factor_ref,NyARIntSize i_size) throws NyARException\r
+       public NyARSquareDetector_X2(NyARFixedFloatObserv2IdealMap i_dist_factor_ref,NyARIntSize i_size) throws NyARException\r
        {\r
                this._width = i_size.w;\r
                this._height = i_size.h;\r
index 4f276e7..8102bb7 100644 (file)
@@ -35,10 +35,10 @@ import jp.nyatla.nyartoolkit.NyARException;
 import jp.nyatla.nyartoolkit.core.NyARSquare;\r
 import jp.nyatla.nyartoolkit.core.param.*;\r
 import jp.nyatla.nyartoolkit.core.transmat.*;\r
-import jp.nyatla.nyartoolkit.core.transmat.rotmatrix.NyARRotMatrix;\r
+import jp.nyatla.nyartoolkit.core.transmat.rotmatrix.*;\r
+import jp.nyatla.nyartoolkit.core.transmat.fitveccalc.*;\r
 import jp.nyatla.nyartoolkit.core.types.*;\r
-import jp.nyatla.nyartoolkit.core2.types.NyARFixedFloat16Point2d;\r
-import jp.nyatla.nyartoolkit.core2.types.NyARFixedFloat16Point3d;\r
+import jp.nyatla.nyartoolkit.core2.types.*;\r
 \r
 \r
 /**\r
@@ -54,10 +54,10 @@ public class NyARTransMat_X2 implements INyARTransMat
        private NyARFixedFloatFitVecCalculator _calculator;\r
        private NyARFixedFloatRotTransOptimize_O2 _mat_optimize;\r
 \r
-       public NyARTransMat_X2(NyARParam i_param,NyARFixedFloatCameraDistortionFactorMap i_dist_factor_map) throws NyARException\r
+       public NyARTransMat_X2(NyARParam i_param) throws NyARException\r
        {\r
                final NyARPerspectiveProjectionMatrix pmat=i_param.getPerspectiveProjectionMatrix();\r
-               this._calculator=new NyARFixedFloatFitVecCalculator(pmat,i_dist_factor_map);\r
+               this._calculator=new NyARFixedFloatFitVecCalculator(pmat,i_param.getDistortionFactor());\r
                this._rotmatrix = new NyARFixedFloatRotMatrix(pmat);\r
                this._mat_optimize=new NyARFixedFloatRotTransOptimize_O2(pmat);\r
        }\r
@@ -75,13 +75,17 @@ public class NyARTransMat_X2 implements INyARTransMat
         * @param o_sqvertex_ref\r
         * @param o_liner_ref\r
         */\r
-       private final void initVertexOrder(NyARSquare i_square, int i_direction, NyARDoublePoint2d[] o_sqvertex_ref, NyARLinear[] o_liner_ref)\r
+       private final void initVertexOrder(NyARSquare i_square, int i_direction, NyARFixedFloat16Point2d[] o_sqvertex_ref, NyARLinear[] o_liner_ref)\r
        {\r
                //頂点順序を考慮した矩形の頂点情報\r
-               o_sqvertex_ref[0]= i_square.sqvertex[(4 - i_direction) % 4];\r
-               o_sqvertex_ref[1]= i_square.sqvertex[(5 - i_direction) % 4];\r
-               o_sqvertex_ref[2]= i_square.sqvertex[(6 - i_direction) % 4];\r
-               o_sqvertex_ref[3]= i_square.sqvertex[(7 - i_direction) % 4];    \r
+               o_sqvertex_ref[0].x= (long)(i_square.sqvertex[(4 - i_direction) % 4].x*NyMath.FIXEDFLOAT16_1);\r
+               o_sqvertex_ref[0].y= (long)(i_square.sqvertex[(4 - i_direction) % 4].y*NyMath.FIXEDFLOAT16_1);\r
+               o_sqvertex_ref[1].x= (long)(i_square.sqvertex[(5 - i_direction) % 4].x*NyMath.FIXEDFLOAT16_1);\r
+               o_sqvertex_ref[1].y= (long)(i_square.sqvertex[(5 - i_direction) % 4].y*NyMath.FIXEDFLOAT16_1);\r
+               o_sqvertex_ref[2].x= (long)(i_square.sqvertex[(6 - i_direction) % 4].x*NyMath.FIXEDFLOAT16_1);\r
+               o_sqvertex_ref[2].y= (long)(i_square.sqvertex[(6 - i_direction) % 4].y*NyMath.FIXEDFLOAT16_1);\r
+               o_sqvertex_ref[3].x= (long)(i_square.sqvertex[(7 - i_direction) % 4].x*NyMath.FIXEDFLOAT16_1);  \r
+               o_sqvertex_ref[3].y= (long)(i_square.sqvertex[(7 - i_direction) % 4].y*NyMath.FIXEDFLOAT16_1);  \r
                o_liner_ref[0]=i_square.line[(4 - i_direction) % 4];\r
                o_liner_ref[1]=i_square.line[(5 - i_direction) % 4];\r
                o_liner_ref[2]=i_square.line[(6 - i_direction) % 4];\r
@@ -90,7 +94,7 @@ public class NyARTransMat_X2 implements INyARTransMat
        }\r
 \r
 \r
-       private final NyARDoublePoint2d[] __transMat_sqvertex_ref = new NyARDoublePoint2d[4];\r
+       private final NyARFixedFloat16Point2d[] __transMat_sqvertex_ref = NyARFixedFloat16Point2d.createArray(4);\r
        private final NyARLinear[] __transMat_linear_ref=new NyARLinear[4];\r
        private final NyARFixedFloat16Point3d __transMat_trans=new NyARFixedFloat16Point3d();\r
        /**\r
@@ -105,10 +109,10 @@ public class NyARTransMat_X2 implements INyARTransMat
         */\r
        public void transMat(final NyARSquare i_square, int i_direction, double i_width, NyARTransMatResult o_result_conv) throws NyARException\r
        {\r
-               final NyARDoublePoint2d[] sqvertex_ref = __transMat_sqvertex_ref;\r
+               final NyARFixedFloat16Point2d[] sqvertex_ref = __transMat_sqvertex_ref;\r
                final NyARLinear[] linear_ref=__transMat_linear_ref;\r
                final NyARFixedFloat16Point3d trans=this.__transMat_trans;\r
-               \r
+       \r
                //計算用に頂点情報を初期化(順番調整)\r
                initVertexOrder(i_square, i_direction, sqvertex_ref,linear_ref);\r
                \r
index a487e8c..db5b691 100644 (file)
@@ -3,9 +3,13 @@ package jp.nyatla.nyartoolkit.sandbox.x2;
 public class NyMath\r
 {\r
        public final static long FIXEDFLOAT24_1=0x1000000L;\r
+       public final static long FIXEDFLOAT24_0_25=FIXEDFLOAT24_1/4;\r
        public final static long FIXEDFLOAT16_1=0x10000L;       \r
+       public final static long FIXEDFLOAT8_1=0x100L;  \r
+\r
        private final static int FF16_PI=(int)(Math.PI*FIXEDFLOAT16_1);\r
        private final static int FF16_2PI=(int)(2 *FF16_PI);\r
+       private final static int FF16_05PI=(int)(FF16_PI/2);\r
        private final static int SIN_RESOLUTION=1024;\r
        private final static int ACOS_RESOLUTION=256;\r
        /* sinテーブルは0-2PIを1024分割\r
@@ -56,28 +60,36 @@ public class NyMath
        }\r
        public static int acosFixedFloat16(int i_ff24)\r
        {\r
-               // 0~1を0~256に変換\r
-               int idx = (int)((i_ff24)>>16);//S8\r
-               if (idx < 0) {\r
-                       return acos_table[-idx]+FF16_PI;\r
+/*             int abs_ff24=i_ff24>0?i_ff24:-i_ff24;\r
+               if(abs_ff24<FIXEDFLOAT24_0_25){\r
+                       //0.25までの範囲は、一次の近似式\r
+                       return FF16_05PI-(i_ff24>>8);\r
                }else{\r
-                       return acos_table[idx];\r
+                       // 0~1を0~512に変換\r
+                       int idx = (int)(i_ff24>>16);//S8\r
+                       if (idx < 0) {\r
+                               return FF16_PI-acos_table[-idx];\r
+                       }else{\r
+                               return acos_table[idx];\r
+                       }\r
                }\r
+*/             return (int)(Math.acos((double)i_ff24/0x1000000)*0x10000);\r
        }       \r
        public static int sinFixedFloat24(int i_ff16)\r
        {\r
                // 0~2PIを0~1024に変換\r
-               int rad_index = (int) (i_ff16 * SIN_RESOLUTION / FF16_2PI);\r
+/*             int rad_index = (int) (i_ff16 * SIN_RESOLUTION / FF16_2PI);\r
                rad_index = rad_index % SIN_RESOLUTION;\r
                if (rad_index < 0) {\r
                        rad_index += SIN_RESOLUTION;\r
                }\r
                // ここで0-1024にいる\r
                return sin_table[rad_index];\r
+*/             return (int)(Math.sin((double)i_ff16/0x10000)*0x1000000);\r
        }\r
        public static int cosFixedFloat24(int i_ff16)\r
        {\r
-               // 0~Math.PI/2を 0~256の値空間に変換\r
+/*             // 0~Math.PI/2を 0~256の値空間に変換\r
                int rad_index = (int) (i_ff16* SIN_RESOLUTION / FF16_2PI);\r
                // 90度ずらす\r
                rad_index = (rad_index + SIN_RESOLUTION / 4) % SIN_RESOLUTION;\r
@@ -87,7 +99,7 @@ public class NyMath
                }\r
                // ここで0-1024にいる\r
                return sin_table[rad_index];    \r
-//             return (int)(Math.cos((double)i_ff16/0x10000)*0x1000000);\r
+*/             return (int)(Math.cos((double)i_ff16/0x10000)*0x1000000);\r
        }\r
        public static void initialize()\r
        {\r
index 05158af..4d96f7d 100644 (file)
@@ -60,7 +60,7 @@ public class NyARSquareDetector implements INyARSquareDetector
        private final NyARLabelingImage _limage;\r
 \r
        private final OverlapChecker _overlap_checker = new OverlapChecker();\r
-       private final INyARCameraDistortionFactor _dist_factor;\r
+       private final NyARObserv2IdealMap _dist_factor;\r
        \r
        private final double[] _xpos;\r
        private final double[] _ypos;\r
@@ -76,7 +76,7 @@ public class NyARSquareDetector implements INyARSquareDetector
                this._height = i_size.h;\r
                //歪み計算テーブルを作ると、8*width/height*2の領域を消費します。\r
                //領域を取りたくない場合は、i_dist_factor_refの値をそのまま使ってください。\r
-               this._dist_factor = new NyARCameraDistortionFactorMap(i_dist_factor_ref,i_size);\r
+               this._dist_factor = new NyARObserv2IdealMap(i_dist_factor_ref,i_size);\r
                this._labeling = new NyARLabeling_ARToolKit();\r
                this._limage = new NyARLabelingImage(this._width, this._height);\r
                this._labeling.attachDestination(this._limage);\r
@@ -36,65 +36,12 @@ import jp.nyatla.nyartoolkit.core.types.*;
 /**\r
  * 歪み成分マップを使用するINyARCameraDistortionFactor\r
  */\r
-final public class NyARCameraDistortionFactorMap implements INyARCameraDistortionFactor\r
+final public class NyARObserv2IdealMap\r
 {\r
-       private double[] _factor=new double[4];\r
        private int _stride;\r
        private double[] _mapx;\r
        private double[] _mapy;\r
-       /**\r
-        * int arParamIdeal2Observ( const double dist_factor[4], const double ix,const double iy,double *ox, double *oy ) 関数の代替関数\r
-        * \r
-        * @param i_in\r
-        * @param o_out\r
-        */\r
-       public void ideal2Observ(final NyARDoublePoint2d i_in, NyARDoublePoint2d o_out)\r
-       {\r
-               final double f0=this._factor[0];\r
-               final double f1=this._factor[1];\r
-               final double x = (i_in.x - f0) * this._factor[3];\r
-               final double y = (i_in.y - f1) * this._factor[3];\r
-               if (x == 0.0 && y == 0.0) {\r
-                       o_out.x = f0;\r
-                       o_out.y = f1;\r
-               } else {\r
-                       final double d = 1.0 - this._factor[2] / 100000000.0 * (x * x + y * y);\r
-                       o_out.x = x * d + f0;\r
-                       o_out.y = y * d + f1;\r
-               }\r
-               return;\r
-       }\r
-\r
-       /**\r
-        * ideal2Observをまとめて実行します。\r
-        * @param i_in\r
-        * @param o_out\r
-        */\r
-       public void ideal2ObservBatch(final NyARDoublePoint2d[] i_in, NyARDoublePoint2d[] o_out, int i_size)\r
-       {\r
-               double x, y;\r
-               final double d0 = this._factor[0];\r
-               final double d1 = this._factor[1];\r
-               final double d3 = this._factor[3];\r
-               final double d2_w = this._factor[2] / 100000000.0;\r
-               for (int i = 0; i < i_size; i++) {\r
-                       x = (i_in[i].x - d0) * d3;\r
-                       y = (i_in[i].y - d1) * d3;\r
-                       if (x == 0.0 && y == 0.0) {\r
-                               o_out[i].x = d0;\r
-                               o_out[i].y = d1;\r
-                       } else {\r
-                               final double d = 1.0 - d2_w * (x * x + y * y);\r
-                               o_out[i].x = x * d + d0;\r
-                               o_out[i].y = y * d + d1;\r
-                       }\r
-               }\r
-               return;\r
-       }       \r
-       \r
-       \r
-       \r
-       public NyARCameraDistortionFactorMap(NyARCameraDistortionFactor i_distfactor,NyARIntSize i_screen_size)\r
+       public NyARObserv2IdealMap(NyARCameraDistortionFactor i_distfactor,NyARIntSize i_screen_size)\r
        {\r
                NyARDoublePoint2d opoint=new NyARDoublePoint2d();\r
                this._mapx=new double[i_screen_size.w*i_screen_size.h];\r
@@ -112,7 +59,6 @@ final public class NyARCameraDistortionFactorMap implements INyARCameraDistortio
                                ptr--;\r
                        }\r
                }\r
-               i_distfactor.getValue(this._factor);\r
                return;\r
        }\r
        public void observ2Ideal(double ix, double iy, NyARDoublePoint2d o_point)\r
index 9641a2a..670ad07 100644 (file)
@@ -31,6 +31,8 @@
  */\r
 package jp.nyatla.nyartoolkit.core2.types;\r
 \r
+import jp.nyatla.nyartoolkit.core.types.*;\r
+\r
 public class NyARFixedFloat16Point3d extends NyARI64Point3d\r
 {\r
        /**\r
@@ -47,4 +49,19 @@ public class NyARFixedFloat16Point3d extends NyARI64Point3d
                }\r
                return ret;\r
        }\r
+       public void copyTo(NyARDoublePoint3d i_to)\r
+       {\r
+               i_to.x=(double)this.x/0x10000;\r
+               i_to.y=(double)this.y/0x10000;\r
+               i_to.z=(double)this.z/0x10000;\r
+               return;\r
+       }\r
+       public void copyFrom(NyARDoublePoint3d i_from)\r
+       {\r
+               this.x=(long)(i_from.x*0x10000);\r
+               this.y=(long)(i_from.y*0x10000);\r
+               this.z=(long)(i_from.z*0x10000);\r
+               return;\r
+       }\r
+\r
 }\r
index 67f8069..adc2baf 100644 (file)
@@ -31,7 +31,7 @@
  */\r
 package jp.nyatla.nyartoolkit.core2.types.matrix;\r
 \r
-import jp.nyatla.nyartoolkit.core.types.matrix.NyARDoubleMatrix33;\r
+import jp.nyatla.nyartoolkit.core.types.matrix.*;\r
 \r
 \r
 public class NyARFixedFloat24Matrix33 extends NyARI64Matrix33\r
@@ -49,6 +49,20 @@ public class NyARFixedFloat24Matrix33 extends NyARI64Matrix33
                this.m22=(long)i_matrix.m22*0x1000000;\r
                return;\r
        }\r
+       public void copyTo(NyARDoubleMatrix33 i_to)\r
+       {\r
+               i_to.m00=(double)this.m00/0x1000000;\r
+               i_to.m01=(double)this.m01/0x1000000;\r
+               i_to.m02=(double)this.m02/0x1000000;\r
+               i_to.m10=(double)this.m10/0x1000000;\r
+               i_to.m11=(double)this.m11/0x1000000;\r
+               i_to.m12=(double)this.m12/0x1000000;\r
+               i_to.m20=(double)this.m20/0x1000000;\r
+               i_to.m21=(double)this.m21/0x1000000;\r
+               i_to.m22=(double)this.m22/0x1000000;\r
+               return;\r
+       }\r
+       \r
        public static NyARFixedFloat24Matrix33[] createArray(int i_number)\r
        {\r
                NyARFixedFloat24Matrix33[] ret=new NyARFixedFloat24Matrix33[i_number];\r
@@ -58,4 +72,5 @@ public class NyARFixedFloat24Matrix33 extends NyARI64Matrix33
                }\r
                return ret;\r
        }\r
+\r
 }\r