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


C# Vector3d.Mag方法代码示例

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


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

示例1: CalculatePlaneEquation

        void CalculatePlaneEquation()
        {
            double           len;
                int             i;
                Vector3d          ref1, norm, v1, v2;
                Point3d          vert1, vert2;
                ref1 = new Vector3d();
                norm = new Vector3d();
                v1 = new Vector3d();
                v2 = new Vector3d();

                for(i=0; i < m_points.Length; i++)
                {
                        vert1 = m_points[i];
                        vert2 = m_points[(i+1) % m_points.Length];

                        v1.x = vert1.x;
                        v1.y = vert1.y;
                        v1.z = vert1.z;

                        v2.x = vert2.x;
                        v2.y = vert2.y;
                        v2.z = vert2.z;

                        norm.x += (v1.y - v2.y)*(v1.z + v2.z);
                        norm.y += (v1.z - v2.z)*(v1.x + v2.x);
                        norm.z += (v1.x - v2.x)*(v1.y + v2.y);
                        ref1.x += v1.x;
                        ref1.y += v1.y;
                        ref1.z += v1.z;
                }

                len = norm.Mag();
                plane.a = norm.x / len;
                plane.b = norm.y / len;
                plane.c = norm.z / len;
                len *= m_points.Length;
                plane.d = -ref1.Dot(norm) / len;
        }
开发者ID:rotteman2,项目名称:UVDLPSlicerController,代码行数:39,代码来源:Polygon.cs

示例2: IntersectSphere

        public static bool IntersectSphere(Point3d start,Point3d end,ref Point3d intersect, Point3d center,double radius)
        {
            bool retval = false;
            double EO;//EO is distance from start of ray to center of sphere
            double d,disc,v;//v is length of direction ray
            Vector3d V,temp;//V is unit vector of the ray
            temp =new Vector3d();
            V = new Vector3d();

            temp.Set(center.x - start.x,center.y - start.y,	center.z - start.z,0);

            EO = temp.Mag(); // unnormalized length
            V.Set(end.x - start.x,end.y - start.y,end.z - start.z,0);
            v = V.Mag();// magnitude of direction vector
            V.Normalize();// normalize the direction vector
            disc = (radius*radius) - ((EO*EO) - (v*v));
            if(disc < 0.0f)
            {
                retval = false;// no intersection
            }
            else
            { // compute the intersection point
                retval = true;
                d = Math.Sqrt(disc);
                intersect.x = start.x + ((v-d)*V.x);
                intersect.y = start.y + ((v-d)*V.y);
                intersect.z = start.z + ((v-d)*V.z);
            }
            return retval;
        }
开发者ID:rotteman2,项目名称:UVDLPSlicerController,代码行数:30,代码来源:RTUtils.cs

示例3: CalcRadius

 public void CalcRadius()
 {
     Vector3d newlen = new Vector3d();
     newlen.Set(0, 0, 0, 0);
     for (int c = 0; c < m_points.Length; c++)
     {
         newlen.x = m_center.x - m_points[c].x;
         newlen.y = m_center.y - m_points[c].y;
         newlen.z = m_center.z - m_points[c].z;
         if(newlen.Mag() >= m_radius)
         {
             m_radius = newlen.Mag();
         }
     }
 }
开发者ID:rotteman2,项目名称:UVDLPSlicerController,代码行数:15,代码来源:Polygon.cs

示例4: SplitEdge

        // split edge v1-v2. v3 is the last corner in the triangle and is used for computing normals
        int SplitEdge(int v1, int v2, Vector3d norm1, Vector3d norm2, out Vector3d norm12)
        {
            EdgeAmf edge = m_pointList[v1].FindEdge(v2);
            if (edge == null)
            {
                edge = m_pointList[v2].FindEdge(v1);
                if (edge != null)
                {
                    // swap verteces to match edge
                    int tv = v1;
                    v1 = v2;
                    v2 = tv;
                    Vector3d tnorm = norm1;
                    norm1 = norm2;
                    norm2 = tnorm;
                }
            }

            Vector3d t1, t2;
            PointAmf pamf1 = m_pointList[v1];
            PointAmf pamf2 = m_pointList[v2];
            Point3d pt1 = pamf1.pt;
            Point3d pt2 = pamf2.pt;
            PointAmf pamf;
            float x, y, z;

            // calculate edge vector
            x = pt2.x - pt1.x;
            y = pt2.y - pt1.y;
            z = pt2.z - pt1.z;
            Vector3d edgeDir = new Vector3d(x, y, z);

            // first see if we have an edge for this segment
            if (edge != null)
            {
                // if this edge was already split, return result
                if (edge.v12 >= 0)
                {
                    norm12 = CalcCenterNormal(norm1, norm2, edge.t12);
                    return edge.v12;
                }
                t1 = edge.t1;
                t2 = edge.t2;
            }
             else
            {
                t1 = GetTangetFromNormal(norm1, edgeDir);
                t2 = GetTangetFromNormal(norm2, edgeDir);
            }

            float d = edgeDir.Mag();

            // calculate mid point using Hermite interpolation
            x = 0.5f * pt1.x + 0.125f * t1.x * d + 0.5f * pt2.x - 0.125f * t2.x * d;
            y = 0.5f * pt1.y + 0.125f * t1.y * d + 0.5f * pt2.y - 0.125f * t2.y * d;
            z = 0.5f * pt1.z + 0.125f * t1.z * d + 0.5f * pt2.z - 0.125f * t2.z * d;

            pamf = new PointAmf();
            pamf.pt = new Point3d(x, y, z);
            int v = m_pointList.Count;
            m_pointList.Add(pamf);

            // calculate new tanget and new normal
            x = -1.5f * pt1.x - 0.25f * t1.x * d + 1.5f * pt2.x - 0.25f * t2.x * d;
            y = -1.5f * pt1.y - 0.25f * t1.y * d + 1.5f * pt2.y - 0.25f * t2.y * d;
            z = -1.5f * pt1.z - 0.25f * t1.z * d + 1.5f * pt2.z - 0.25f * t2.z * d;
            Vector3d tanget = new Vector3d(x, y, z);
            tanget.Normalize();

            norm12 = CalcCenterNormal(norm1, norm2, tanget);
            
            if (edge == null)
            {
                //pamf.normal = GetNormalFromTanget(norm1, tanget);
                // create an edge for this segment
                edge = new EdgeAmf();
                edge.v1 = v1;
                edge.v2 = v2;
                edge.t1 = t1;
                edge.t2 = t2;
                pamf1.AddEdge(edge);
            }
            edge.t12 = tanget;
            edge.v12 = m_pointList.Count - 1; // saves double computation 

            //tanget.Normalize();
            // save 2 split edges
            EdgeAmf edge1 = new EdgeAmf();
            edge1.v1 = v1;
            edge1.v2 = v;
            edge1.t1 = t1;
            edge1.t2 = tanget;
            pamf1.AddEdge(edge1);

            EdgeAmf edge2 = new EdgeAmf();
            edge2.v1 = v;
            edge2.v2 = v2;
            edge2.t1 = tanget;
            edge2.t2 = t2;
//.........这里部分代码省略.........
开发者ID:Biseny,项目名称:UVDLPSlicerController,代码行数:101,代码来源:ModelLoaderAmf.cs


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