本文整理汇总了C#中jp.nyatla.nyartoolkit.cs.core.NyARDoublePoint2d类的典型用法代码示例。如果您正苦于以下问题:C# NyARDoublePoint2d类的具体用法?C# NyARDoublePoint2d怎么用?C# NyARDoublePoint2d使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
NyARDoublePoint2d类属于jp.nyatla.nyartoolkit.cs.core命名空间,在下文中一共展示了NyARDoublePoint2d类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: sqNorm
/**
* p2-p1ベクトルのsquare normを計算する。
* @param i_p1
* @param i_p2
* @return
*/
public static double sqNorm(NyARDoublePoint2d i_p1, NyARDoublePoint2d i_p2)
{
double x, y;
x = i_p2.x - i_p1.x;
y = i_p2.y - i_p1.y;
return x * x + y * y;
}
示例2: setAreaRect
/**
* この関数は、頂点集合を包括する矩形を計算して、インスタンスにセットします。
* @param i_vertex
* 頂点集合を格納した配列
* @param i_num_of_vertex
* 計算対象とする要素の数
*/
public void setAreaRect(NyARDoublePoint2d[] i_vertex, int i_num_of_vertex)
{
//エリアを求める。
int xmax, xmin, ymax, ymin;
xmin = xmax = (int)i_vertex[i_num_of_vertex - 1].x;
ymin = ymax = (int)i_vertex[i_num_of_vertex - 1].y;
for (int i = i_num_of_vertex - 2; i >= 0; i--)
{
if (i_vertex[i].x < xmin)
{
xmin = (int)i_vertex[i].x;
}
else if (i_vertex[i].x > xmax)
{
xmax = (int)i_vertex[i].x;
}
if (i_vertex[i].y < ymin)
{
ymin = (int)i_vertex[i].y;
}
else if (i_vertex[i].y > ymax)
{
ymax = (int)i_vertex[i].y;
}
}
this.h = ymax - ymin + 1;
this.x = xmin;
this.w = xmax - xmin + 1;
this.y = ymin;
}
示例3: initRotBySquare
public override void initRotBySquare(NyARLinear[] i_linear,NyARDoublePoint2d[] i_sqvertex)
{
base.initRotBySquare(i_linear,i_sqvertex);
//Matrixからangleをロード
this.updateAngleFromMatrix();
return;
}
示例4: observ2Ideal
public void observ2Ideal(int ix, int iy, NyARDoublePoint2d o_point)
{
int idx = ix + iy * this._stride;
o_point.x = this._mapx[idx];
o_point.y = this._mapy[idx];
return;
}
示例5: makeMatAtB
private static NyARMat makeMatAtB(NyARDoublePoint2d[] screenCoord, NyARDoublePoint3d[] worldCoord, int i_num, NyARMat o_matAtB)
{
double v0, v1, v2, v3, v4, v5, v6, v7;
v0 = v1 = v2 = v3 = v4 = v5 = v6 = v7 = 0;
for (int i = 0; i < i_num; i++)
{
double wx = worldCoord[i].x;
double wy = worldCoord[i].y;
double sx = screenCoord[i].x;
double sy = screenCoord[i].y;
v0 += wx * sx;
v1 += wy * sx;
v2 += sx;
v3 += wx * sy;
v4 += wy * sy;
v5 += sy;
v6 += -wx * sx * sx - wx * sy * sy;
v7 += -wy * sx * sx - wy * sy * sy;
}
double[][] t = o_matAtB.getArray();
t[0][0] = v0;
t[1][0] = v1;
t[2][0] = v2;
t[3][0] = v3;
t[4][0] = v4;
t[5][0] = v5;
t[6][0] = v6;
t[7][0] = v7;
return o_matAtB;
}
示例6: pickFromRaster
/**
* この関数は、ラスタドライバから画像を読み出します。
* @param i_pix_drv
* @param i_size
* @param i_vertex
* @param o_data
* @param o_param
* @return
* @
*/
public bool pickFromRaster(INyARGsPixelDriver i_pix_drv, NyARDoublePoint2d[] i_vertex, NyIdMarkerPattern o_data, NyIdMarkerParam o_param)
{
if (!this._perspective_reader.setSourceSquare(i_vertex))
{
return false;
}
return this._pickFromRaster(i_pix_drv, o_data, o_param);
}
示例7: createArray
/**
* 配列ファクトリ
* @param i_number
* @return
*/
public static NyARDoublePoint2d[] createArray(int i_number)
{
NyARDoublePoint2d[] ret = new NyARDoublePoint2d[i_number];
for (int i = 0; i < i_number; i++)
{
ret[i] = new NyARDoublePoint2d();
}
return ret;
}
示例8: initRotBySquare
//override
public sealed override bool initRotBySquare(NyARLinear[] i_linear, NyARDoublePoint2d[] i_sqvertex)
{
bool ret = base.initRotBySquare(i_linear, i_sqvertex);
if (ret)
{
//Matrixからangleをロード
this.updateAngleFromMatrix();
}
return ret;
}
示例9: optimizeParamX
/*
* 射影変換式 基本式 ox=(cosc * cosb - sinc * sina * sinb)*ix+(-sinc * cosa)*iy+(cosc * sinb + sinc * sina * cosb)*iz+i_trans.x; oy=(sinc * cosb + cosc * sina *
* sinb)*ix+(cosc * cosa)*iy+(sinc * sinb - cosc * sina * cosb)*iz+i_trans.y; oz=(-cosa * sinb)*ix+(sina)*iy+(cosb * cosa)*iz+i_trans.z;
*
* double ox=(cosc * cosb)*ix+(-sinc * sina * sinb)*ix+(-sinc * cosa)*iy+(cosc * sinb)*iz + (sinc * sina * cosb)*iz+i_trans.x; double oy=(sinc * cosb)*ix
* +(cosc * sina * sinb)*ix+(cosc * cosa)*iy+(sinc * sinb)*iz+(- cosc * sina * cosb)*iz+i_trans.y; double oz=(-cosa * sinb)*ix+(sina)*iy+(cosb *
* cosa)*iz+i_trans.z;
*
* sina,cosaについて解く cx=(cp00*(-sinc*sinb*ix+sinc*cosb*iz)+cp01*(cosc*sinb*ix-cosc*cosb*iz)+cp02*(iy))*sina
* +(cp00*(-sinc*iy)+cp01*((cosc*iy))+cp02*(-sinb*ix+cosb*iz))*cosa
* +(cp00*(i_trans.x+cosc*cosb*ix+cosc*sinb*iz)+cp01*((i_trans.y+sinc*cosb*ix+sinc*sinb*iz))+cp02*(i_trans.z));
* cy=(cp11*(cosc*sinb*ix-cosc*cosb*iz)+cp12*(iy))*sina +(cp11*((cosc*iy))+cp12*(-sinb*ix+cosb*iz))*cosa
* +(cp11*((i_trans.y+sinc*cosb*ix+sinc*sinb*iz))+cp12*(i_trans.z)); ch=(iy)*sina +(-sinb*ix+cosb*iz)*cosa +i_trans.z; sinb,cosb hx=(cp00*(-sinc *
* sina*ix+cosc*iz)+cp01*(cosc * sina*ix+sinc*iz)+cp02*(-cosa*ix))*sinb +(cp01*(sinc*ix-cosc * sina*iz)+cp00*(cosc*ix+sinc * sina*iz)+cp02*(cosa*iz))*cosb
* +(cp00*(i_trans.x+(-sinc*cosa)*iy)+cp01*(i_trans.y+(cosc * cosa)*iy)+cp02*(i_trans.z+(sina)*iy)); double hy=(cp11*(cosc *
* sina*ix+sinc*iz)+cp12*(-cosa*ix))*sinb +(cp11*(sinc*ix-cosc * sina*iz)+cp12*(cosa*iz))*cosb +(cp11*(i_trans.y+(cosc *
* cosa)*iy)+cp12*(i_trans.z+(sina)*iy)); double h =((-cosa*ix)*sinb +(cosa*iz)*cosb +i_trans.z+(sina)*iy); パラメータ返還式 L=2*Σ(d[n]*e[n]+a[n]*b[n])
* J=2*Σ(d[n]*f[n]+a[n]*c[n])/L K=2*Σ(-e[n]*f[n]+b[n]*c[n])/L M=Σ(-e[n]^2+d[n]^2-b[n]^2+a[n]^2)/L 偏微分式 +J*cos(x) +K*sin(x) -sin(x)^2 +cos(x)^2
* +2*M*cos(x)*sin(x)
*/
private double optimizeParamX(double sinb, double cosb, double sinc, double cosc, NyARDoublePoint3d i_trans, NyARDoublePoint3d[] i_vertex3d, NyARDoublePoint2d[] i_vertex2d, int i_number_of_vertex, double i_hint_angle)
{
NyARPerspectiveProjectionMatrix cp = this._projection_mat_ref;
double L, J, K, M, N, O;
L = J = K = M = N = O = 0;
double cp00 = cp.m00;
double cp01 = cp.m01;
double cp02 = cp.m02;
double cp11 = cp.m11;
double cp12 = cp.m12;
for (int i = 0; i < i_number_of_vertex; i++)
{
double ix, iy, iz;
ix = i_vertex3d[i].x;
iy = i_vertex3d[i].y;
iz = i_vertex3d[i].z;
double X0 = (cp00 * (-sinc * sinb * ix + sinc * cosb * iz) + cp01 * (cosc * sinb * ix - cosc * cosb * iz) + cp02 * (iy));
double X1 = (cp00 * (-sinc * iy) + cp01 * ((cosc * iy)) + cp02 * (-sinb * ix + cosb * iz));
double X2 = (cp00 * (i_trans.x + cosc * cosb * ix + cosc * sinb * iz) + cp01 * ((i_trans.y + sinc * cosb * ix + sinc * sinb * iz)) + cp02 * (i_trans.z));
double Y0 = (cp11 * (cosc * sinb * ix - cosc * cosb * iz) + cp12 * (iy));
double Y1 = (cp11 * ((cosc * iy)) + cp12 * (-sinb * ix + cosb * iz));
double Y2 = (cp11 * ((i_trans.y + sinc * cosb * ix + sinc * sinb * iz)) + cp12 * (i_trans.z));
double H0 = (iy);
double H1 = (-sinb * ix + cosb * iz);
double H2 = i_trans.z;
double VX = i_vertex2d[i].x;
double VY = i_vertex2d[i].y;
double a, b, c, d, e, f;
a = (VX * H0 - X0);
b = (VX * H1 - X1);
c = (VX * H2 - X2);
d = (VY * H0 - Y0);
e = (VY * H1 - Y1);
f = (VY * H2 - Y2);
L += d * e + a * b;
N += d * d + a * a;
J += d * f + a * c;
M += e * e + b * b;
K += e * f + b * c;
O += f * f + c * c;
}
L *= 2;
J *= 2;
K *= 2;
return getMinimumErrorAngleFromParam(L, J, K, M, N, O, i_hint_angle);
}
开发者ID:mlakhal,项目名称:CollaborativeAugmentedRealityEnvironment,代码行数:75,代码来源:NyARPartialDifferentiationOptimize.cs
示例10: makeErrThreshold
/**
* 頂点情報を元に、エラー閾値を計算します。
* @param i_vertex
*/
private double makeErrThreshold(NyARDoublePoint2d[] i_vertex)
{
double a, b, l1, l2;
a = i_vertex[0].x - i_vertex[2].x;
b = i_vertex[0].y - i_vertex[2].y;
l1 = a * a + b * b;
a = i_vertex[1].x - i_vertex[3].x;
b = i_vertex[1].y - i_vertex[3].y;
l2 = a * a + b * b;
return (Math.Sqrt(l1 > l2 ? l1 : l2)) / 200;
}
示例11: makeMatAtA
private static NyARMat makeMatAtA(NyARDoublePoint2d[] screenCoord, NyARDoublePoint3d[] worldCoord, int i_num, NyARMat o_matAtA)
{
o_matAtA.loadZero();
double[][] t = o_matAtA.getArray();
for (int i = 0; i < i_num; i++)
{
//0
double wx = worldCoord[i].x;
double wy = worldCoord[i].y;
double sx = screenCoord[i].x;
double sy = screenCoord[i].y;
double wxwx = wx * wx;
double wywy = wy * wy;
double wxwy = wx * wy;
t[0][0] += wxwx;
t[0][1] += wxwy;
t[0][2] += wx;
t[1][2] += wy;
t[0][6] += (-wxwx) * (sx);
t[0][7] += (-wxwy) * (sx);
t[1][1] += wywy;
t[1][7] += (-wywy) * (sx);
t[2][6] += (-wx) * (sx);
t[2][7] += (-wy) * (sx);
t[3][6] += (-wxwx) * (sy);
t[3][7] += (-wxwy) * (sy);
t[4][7] += (-wywy) * (sy);
t[5][6] += (-wx) * (sy);
t[5][7] += (-wy) * (sy);
t[6][6] += (wxwx) * (sx) * (sx) + (wxwx) * (sy) * (sy);
t[6][7] += (wxwy) * (sx) * (sx) + (wxwy) * (sy) * (sy);
t[7][7] += (wywy) * (sx) * (sx) + (wywy) * (sy) * (sy);
}
t[1][0] = t[3][4] = t[4][3] = t[0][1];
t[2][0] = t[3][5] = t[5][3] = t[0][2];
t[2][1] = t[5][4] = t[4][5] = t[1][2];
t[7][0] = t[6][1] = t[1][6] = t[0][7];
t[4][6] = t[6][4] = t[7][3] = t[3][7];
t[2][2] = t[5][5] = i_num;
t[3][3] = t[0][0];
t[4][4] = t[1][1];
t[6][0] = t[0][6];
t[6][2] = t[2][6];
t[6][3] = t[3][6];
t[6][5] = t[5][6];
t[7][1] = t[1][7];
t[7][2] = t[2][7];
t[7][4] = t[4][7];
t[7][5] = t[5][7];
t[7][6] = t[6][7];
//先頭でゼロクリアしない場合。
//t[0][3]=t[0][4]=t[0][5]=t[1][3]=t[1][4]=t[1][5]=t[2][3]=t[2][4]=t[2][5]=t[3][0]=t[3][1]=t[3][2]=t[4][0]=t[4][1]=t[4][2]=t[5][0]=t[5][1]=t[5][2]=0;
return o_matAtA;
}
示例12: crossPos
/**
* この関数は、直線との交点を求めます。
* @param i_vector1
* 交点を求める直線
* @param o_point
* 交点座標を得るオブジェクト。
* @return
* 交点が求まると、trueを返します。
*/
public bool crossPos(NyARVecLinear2d i_vector1, NyARDoublePoint2d o_point)
{
double a1 = i_vector1.dy;
double b1 = -i_vector1.dx;
double c1 = (i_vector1.dx * i_vector1.y - i_vector1.dy * i_vector1.x);
double a2 = this.dy;
double b2 = -this.dx;
double c2 = (this.dx * this.y - this.dy * this.x);
double w1 = a1 * b2 - a2 * b1;
if (w1 == 0.0)
{
return false;
}
o_point.x = (b1 * c2 - b2 * c1) / w1;
o_point.y = (a2 * c1 - a1 * c2) / w1;
return true;
}
示例13: NyARObserv2IdealMap
public NyARObserv2IdealMap(NyARCameraDistortionFactor i_distfactor, NyARIntSize i_screen_size)
{
NyARDoublePoint2d opoint = new NyARDoublePoint2d();
this._mapx = new double[i_screen_size.w * i_screen_size.h];
this._mapy = new double[i_screen_size.w * i_screen_size.h];
this._stride = i_screen_size.w;
int ptr = i_screen_size.h * i_screen_size.w - 1;
//歪みマップを構築
for (int i = i_screen_size.h - 1; i >= 0; i--)
{
for (int i2 = i_screen_size.w - 1; i2 >= 0; i2--)
{
i_distfactor.observ2Ideal(i2, i, opoint);
this._mapx[ptr] = opoint.x;
this._mapy[ptr] = opoint.y;
ptr--;
}
}
return;
}
示例14: NyARFixedFloatObserv2IdealMap
public NyARFixedFloatObserv2IdealMap(NyARCameraDistortionFactor i_distfactor, NyARIntSize i_screen_size)
{
NyARDoublePoint2d opoint = new NyARDoublePoint2d();
this._mapx = new int[i_screen_size.w * i_screen_size.h];
this._mapy = new int[i_screen_size.w * i_screen_size.h];
this._stride = i_screen_size.w;
int ptr = i_screen_size.h * i_screen_size.w - 1;
//歪みマップを構築
for (int i = i_screen_size.h - 1; i >= 0; i--)
{
for (int i2 = i_screen_size.w - 1; i2 >= 0; i2--)
{
i_distfactor.observ2Ideal(i2, i, opoint);
this._mapx[ptr] = (int)(opoint.x * 65536);
this._mapy[ptr] = (int)(opoint.y * 65536);
ptr--;
}
}
i_distfactor.getValue(this._factor);
return;
}
示例15: ideal2ObservBatch
public void ideal2ObservBatch(NyARDoublePoint2d[] i_in, NyARFixedFloat16Point2d[] o_out, int i_size)
{
double x, y;
double d0 = this._factor[0];
double d1 = this._factor[1];
double d3 = this._factor[3];
double d2_w = this._factor[2] / 100000000.0;
for (int i = 0; i < i_size; i++) {
x = (i_in[i].x - d0) * d3;
y = (i_in[i].y - d1) * d3;
if (x == 0.0 && y == 0.0) {
o_out[i].x = (long)(d0*NyMath.FIXEDFLOAT16_1);
o_out[i].y = (long)(d1*NyMath.FIXEDFLOAT16_1);
} else {
double d = 1.0 - d2_w * (x * x + y * y);
o_out[i].x = (long)((x * d + d0)*NyMath.FIXEDFLOAT16_1);
o_out[i].y = (long)((y * d + d1)*NyMath.FIXEDFLOAT16_1);
}
}
return;
}