当前位置: 首页>>代码示例>>C#>>正文


C# ISurface.xCvt方法代码示例

本文整理汇总了C#中ISurface.xCvt方法的典型用法代码示例。如果您正苦于以下问题:C# ISurface.xCvt方法的具体用法?C# ISurface.xCvt怎么用?C# ISurface.xCvt使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在ISurface的用法示例。


在下文中一共展示了ISurface.xCvt方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: xRad

        //static public void GetFittingMesh(ISurface s, double vMid, out List<Vect2> uv, out List<Vect3> xyz)
        //{
        //    FixedPoint[] fits = new FixedPoint[2];
        //    fits[0] = new FixedPoint(0, vMid);
        //    fits[1] = new FixedPoint(1, vMid);
        //    SurfaceCurve midcur = new SurfaceCurve("MidCur", s, fits);
        //}
        public static void xRad(ISurface s, Vect2 uv, ref Vect3 xyz, ref double k)
        {
            Vect3 dxu = new Vect3(), dxv = new Vect3(), ddxu = new Vect3(), ddxv = new Vect3(), dduv = new Vect3(), xnor = new Vect3();
            s.xCvt(uv, ref xyz, ref dxu, ref dxv, ref ddxu, ref ddxv, ref dduv);
            s.xNor(uv, ref xyz, ref xnor);

            //calculate first fundamental form
            double E = dxu.Norm;
            double F = dxu.Dot(dxv);
            double G = dxv.Norm;
            //double E = BLAS.dot(dxu, dxu);
            //double F = BLAS.dot(dxu, dxv);
            //double G = BLAS.dot(dxv, dxv);
            double detI = E * G - F * F;
            //calculate second fundamental form
            double e = xnor.Dot(ddxu);
            double f = xnor.Dot(dduv);
            double g = xnor.Dot(ddxv);
            //double e = BLAS.dot(ddxu, xnor);
            //double f = BLAS.dot(dduv, xnor);
            //double g = BLAS.dot(ddxv, xnor);
            double detII = e * g - f * f;

            k = detII / detI;
        }
开发者ID:GabeTesta,项目名称:Warps,代码行数:32,代码来源:ISurface.cs

示例2: xClosest

        public static bool xClosest(ISurface s, ref Vect2 uv, ref Vect3 xyzTarget, ref double dist, double tol)
        {
            Vect3 x = new Vect3(xyzTarget);
            Vect3 dxu = new Vect3(), dxv = new Vect3();
            Vect3 ddxu = new Vect3(), ddxv = new Vect3(), dduv = new Vect3();

            Vect3 h = new Vect3();
            Vect2 c = new Vect2();
            Vect2 res = new Vect2();
            Vect2 a = new Vect2(), b = new Vect2();
            double det, r;
            Vect2 d = new Vect2();

            int loop = 0, max_loops = 150;
            while (loop++ < max_loops)
            {
                s.xCvt(uv, ref x, ref dxu, ref dxv, ref ddxu, ref ddxv, ref dduv);

                h = x - xyzTarget;
                //h = BLAS.subtract(x, xyzTarget);
                dist = h.Magnitude;

                //e[0] = s;
                c[0] = h.Dot(dxu);// BLAS.dot(h, dxu); // error, dot product is 0 at pi/2
                c[1] = h.Dot(dxv);// BLAS.dot(h, dxv); // error, dot product is 0 at pi/2

                if (Math.Abs(c[0]) < tol && Math.Abs(c[1]) < tol) // error is less than the tolerance
                {
                    xyzTarget.Set(x);// return point to caller
                    return true;
                }

                a[0] = dxu.Norm + h.Dot(ddxu);
                a[1] = b[0] = dxu.Dot(dxv) + h.Dot(dduv);
                b[1] = dxv.Norm + h.Dot(ddxv);

                //a[0] = BLAS.dot(dxu, dxu) + BLAS.dot(h, ddxu);
                //a[1] = BLAS.dot(dxu, dxv) + BLAS.dot(h, dduv);
                //b[0] = a[1];
                //b[1] = BLAS.dot(dxv, dxv) + BLAS.dot(h, ddxv);

                det = a.Cross(b);
                //det = BLAS.cross2d(a, b);

                d[0] = c.Cross(b) / det;
                d[1] = a.Cross(c) / det;
                //d[0] = BLAS.cross2d(c, b) / det;
                //d[1] = BLAS.cross2d(a, c) / det;

                c[0] = 0.01 > Math.Abs(d[0]) ? 1 : 0.01 / Math.Abs(d[0]);
                c[1] = 0.01 > Math.Abs(d[1]) ? 1 : 0.01 / Math.Abs(d[1]);
                //enforce maximum increment
                r = Math.Min(c[0], c[1]);

                //increment uv by scaled residuals
                //uv = BLAS.subtract(uv, BLAS.scale(d, r));
                uv = uv - d * r;
                //logger.write_format_line("%.5g\t%.5g\t%.5g\t%.5g\t%.5g\t", x[ox], x[oy], e[ox], e[oy], dist);
            }
            //s = s0;
            return false;
        }
开发者ID:GabeTesta,项目名称:Warps,代码行数:62,代码来源:ISurface.cs


注:本文中的ISurface.xCvt方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。