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


C# Vector3d.Unitize方法代码示例

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


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

示例1: Generate

            public override Mesh Generate(Point3d P, Vector3d V)
            {
                Vector3d diffx;
                Vector3d diffy;
                Vector3d diffz = new Vector3d(V);
                double proj;
                diffx = new Vector3d(0, 0, 1);
                proj = System.Math.Abs(Vector3d.Multiply(diffz, diffx));

                if (0.99 < proj && 1.01 > proj) diffx = new Vector3d(1, 0, 0);
                diffy = diffz;
                diffy = Vector3d.CrossProduct(diffy, diffx);
                diffx = Vector3d.CrossProduct(diffy, diffz);
                diffx.Unitize();
                diffy.Unitize();
                diffz.Unitize();

                Mesh M = new Mesh();
                M.Vertices.SetVertex(0, P + diffz * 0.25);
                M.Vertices.SetVertex(1, P + (diffx * 0.7072 + diffy * -.5 + diffz * -.5) * 0.25);
                M.Vertices.SetVertex(2, P + (diffy + diffz * -.5) * 0.25);
                M.Vertices.SetVertex(3, P + (diffx * -0.7072 + diffy * -.5 + diffz * -.5) * 0.25);

                M.Faces.SetFace(0, 0, 1, 2);
                M.Faces.SetFace(1, 0, 2, 3);
                M.Faces.SetFace(2, 0, 3, 1);
                M.Faces.SetFace(3, 3, 2, 1);
                M.FaceNormals.ComputeFaceNormals();
                //M.ComputeVertexNormals();

                return M;
            }
开发者ID:MengdiGuo,项目名称:PachydermAcoustic_Rhinoceros,代码行数:32,代码来源:Classes_Particles.cs

示例2: calcNodalWindLoads

        //Methods

        List<Vector3d> calcNodalWindLoads(List<Vector3d> vertexNormals, Vector3d wind, bool scale)
        {
            List<Vector3d> windload = new List<Vector3d>();

            double w = wind.Length;                                 //kN/m2
            Vector3d wDir = new Vector3d(wind);
            wDir.Unitize();

            for(int i=0; i<vertexNormals.Count; i++)
            {
                //Calculate projection onto wind direction
                Vector3d vN = vertexNormals[i];
                double vertexArea = vN.Length;                      //m2
                vN.Unitize();

                double dotProduct = Vector3d.Multiply(vN, wDir);

                //Calculate wind force
                Vector3d force = vN * vertexArea * w * 1e3;         //N

                if(dotProduct < 0.0)
                {
                    force.Reverse();
                }

                if (scale)
                {
                    force *= Math.Abs(dotProduct);
                }

                windload.Add(force);
            }

            return windload;
        }
开发者ID:CecilieBrandt,项目名称:K2Engineering,代码行数:37,代码来源:MeshWindLoad.cs

示例3: CalculateDesiredVelocity

    protected override Vector3d CalculateDesiredVelocity()
    {
      Vector3d desired = new Vector3d();
      int count = 0;

      foreach (IQuelea neighbor in neighbors)
      {
        Point3d neighborPosition2D = agent.Environment.Wrap ? wrappedPositions[count] : neighbor.Position;
        double d = agent.Position.DistanceTo(neighborPosition2D);
        if (!(d > 0)) continue;
        //double d = Vector3d.Subtract(agent.RefPosition, other.RefPosition).Length;
        //if we are not comparing the seeker to iteself and it is at least
        //desired separation away:
        Vector3d diff = Util.Vector.Vector2Point(neighborPosition2D, agent.Position);
        diff.Unitize();

        //Weight the magnitude by distance to other
        diff = Vector3d.Divide(diff, d);

        desired = Vector3d.Add(desired, diff);

        //For an average, we need to keep track of how many boids
        //are in our vision.
        count++;
      }

      if (count > 0)
      {
        desired = Vector3d.Divide(desired, count);
        desired.Unitize();
        desired = Vector3d.Multiply(desired, agent.MaxSpeed);
      }
      //Seek the average position of our neighbors.
      return desired;
    }
开发者ID:lxfschr,项目名称:Quelea,代码行数:35,代码来源:SeparateForceComponent.cs

示例4: CreateSectionSweeps

        public static List<Brep> CreateSectionSweeps(WR_Elem3dRcp er)
        {
            List<Curve> crvs;
            List<Brep> eSBreps = new List<Brep>();

            // Start and end caps
            List<Curve> sCap = new List<Curve>();
            List<Curve> eCap = new List<Curve>();

            if (CrossSectionCasts.GetSectionPropertyCrvs(er.GetSectionString(), out crvs))
            {
                // Get x vector
                Point3d sPos = er.GetStartPos().ConvertToRhinoPoint();
                Point3d ePos = er.GetEndPos().ConvertToRhinoPoint();
                Vector3d elX = new Vector3d(ePos.X - sPos.X, ePos.Y - sPos.Y, ePos.Z - sPos.Z);
                double elLength = elX.Length;
                elX.Unitize();
                Vector3d move = elX * elLength;

                // Get normal (z vector)
                WR_Vector elWrZ = er.GetElementNormal();
                Vector3d elZ = new Vector3d(elWrZ.X, elWrZ.Y, elWrZ.Z);

                // Get y vector
                Vector3d elY = Vector3d.CrossProduct(elZ, elX);

                // Rotation to local coordinates
                Transform rotTrans = Transform.Rotation(Vector3d.XAxis, Vector3d.YAxis, Vector3d.ZAxis, elX, elY, elZ);

                // Add start and end point to a list
                List<Point3d> endPts = new List<Point3d> { sPos, ePos };

                foreach (Curve crv in crvs)
                {
                    // Rotate to local coordinates
                    crv.Transform(rotTrans);
                    crv.Translate((Vector3d)sPos);

                    // Create and add extrusion
                    Brep extrusion = Extrusion.CreateExtrusion(crv, move).ToBrep();
                    eSBreps.Add(extrusion);

                    // Add curve to cap list
                    sCap.Add(crv);

                    // Move to end and add
                    Curve eCrv = (Curve)crv.Duplicate();
                    eCrv.Translate(move);
                    eCap.Add(eCrv);
                }

                // Cap sections
                eSBreps.Add(CapSections(sCap));
                eSBreps.Add(CapSections(eCap));

            }

            return eSBreps;
        }
开发者ID:IsakNaslund,项目名称:MasterThesis,代码行数:59,代码来源:Utilities.cs

示例5: Face

 public Face(int tIndex, List<Vertex> tFaceVerts, Vector3f tNormal, Point3f tFaceCentre, WingedMesh tMesh)
     //add something which stops you ever sending in only 1 or 2 verts?
 {
     index = tIndex;
     faceVerts = tFaceVerts;
     faceNormal = tNormal;
     faceNormal.Unitize();
     faceCentre = tFaceCentre;
     faceEdges = new List<Edge>();
     refMesh = tMesh;
     initialiseEdges();
 }
开发者ID:formateng,项目名称:giraffe,代码行数:12,代码来源:Face.cs

示例6: ComputeWeight

 public double[] ComputeWeight(Point3d p1, Point3d p2, Point3d p3, Vector3d v)
 {
     Vector3d N = new Plane(p1, p2, p3).Normal;
     if (N.IsParallelTo(v) == -1)
     {
         double[] ds = new Double[3]; return ds;
     }
     Vector3d y2 = Vector3d.CrossProduct(v, N);
     v = Vector3d.CrossProduct(y2, N);
     double t = p1.DistanceTo(p2) + p2.DistanceTo(p3) + p3.DistanceTo(p1);
     v.Unitize(); v *= t;
     Point3d cen = (p1 + p2 + p3) / 3;
     Line l1 = new Line(cen - v, cen + v);
     Point3d P1 = l1.ClosestPoint(p1, true);
     Point3d P2 = l1.ClosestPoint(p2, true);
     Point3d P3 = l1.ClosestPoint(p3, true);
     double t1 = (P1.DistanceTo(l1.From)) / l1.Length;
     double t2 = (P2.DistanceTo(l1.From)) / l1.Length;
     double t3 = (P3.DistanceTo(l1.From)) / l1.Length;
     if ((t1 < t2) && (t2 < t3))
     {
         double[] ds = { 0, (t2 - t1) / (t3 - t1), 1 }; return ds;
     }
     else if (t1 < t3 && t3 < t2)
     {
         double[] ds = { 0, 1, (t3 - t1) / (t2 - t1) }; return ds;
     }
     ////
     else if (t2 < t1 && t1 < t3)
     {
         double[] ds = { (t1 - t2) / (t3 - t2), 0, 1 }; return ds;
     }
     else if (t2 < t3 && t3 < t1)
     {
         double[] ds = { 1, 0, (t3 - t2) / (t1 - t2) }; return ds;
     }
     ////
     else if (t3 < t1 && t1 < t2)
     {
         double[] ds = { (t1 - t3) / (t2 - t3), 1, 0 }; return ds;
     }
     else if (t3 < t2 && t2 < t1)
     {
         double[] ds = { 1, (t2 - t3) / (t1 - t3), 0 }; return ds;
     }
     else
     {
         double[] ds = new Double[3]; return ds;
     }
 }
开发者ID:panhao4812,项目名称:MeshClassLibrary,代码行数:50,代码来源:MeshCreation.cs

示例7: CalculateDesiredVelocity

    protected override Vector3d CalculateDesiredVelocity()
    {
      Vector3d desired = new Vector3d();
      int count = 0;

      foreach (IQuelea neighbor in neighbors)
      {
        //Add up all the velocities and divide by the total to calculate
        //the average velocity.
        desired = desired + neighbor.Velocity;
        //For an average, we need to keep track of how many boids
        //are in our vision.
        count++;
      }

      if (count > 0)
      {
        desired = desired / count;
        desired.Unitize();
        desired = desired * agent.MaxSpeed;
      }
      //Seek the average location of our neighbors.
      return desired;
    }
开发者ID:lxfschr,项目名称:Quelea,代码行数:24,代码来源:AlignForceComponent.cs

示例8: Calculate

            public override void Calculate(List<KangarooSolver.Particle> p)
            {
                Point3d ptStart = p[PIndex[0]].Position;             //get the current position of the particle at the start of the line
                Point3d ptEnd = p[PIndex[1]].Position;             //get the current position of the particle at the end of the line

                //Calculate force direction
                Vector3d forceDir = new Vector3d(ptEnd - ptStart);  //force direction pointing from start of line to end
                double currentLength = forceDir.Length;
                forceDir.Unitize();

                //Calculate extension
                double extension = currentLength - restLenght;

                if (extension > 0.0)
                {
                    isCompressionMember = false;
                }
                else if (extension < 0.0)
                {
                    isCompressionMember = true;
                }

                //Set vector direction and magnitude
                Move[0] = forceDir * (extension / 2);                 //has to point to exact point according to Hooke's Law. Divide by 2 as the bar is extended in both directions with the same amount
                Move[1] = -forceDir * (extension / 2);
            }
开发者ID:CecilieBrandt,项目名称:K2Engineering,代码行数:26,代码来源:Bar.cs

示例9: SolveInstance

        /// <summary>
        /// This is the method that actually does the work.
        /// </summary>
        /// <param name="DA">The DA object is used to retrieve from inputs and store in outputs.</param>
        protected override void SolveInstance(IGH_DataAccess DA)
        {
            //Input
            List<Plane> planes = new List<Plane>();
            if (!DA.GetDataList(0, planes)) { return; }

            List<double> stresses = new List<double>();
            if (!DA.GetDataList(1, stresses)) { return; }

            double scale = 1.0;
            DA.GetData(2, ref scale);


            //Remap stress values to colours and lines
            colours = new List<Color>();
            lines = new List<Line>();

            double colourMax = 4 * 255.0;
            double colourMin = 0.0;
            double lengthMax = 1.0 * scale;
            double lengthMin = 0.1 * scale;

            double minStress = stresses.Min();
            double maxStress = stresses.Max();
            double stressRange = maxStress - minStress;

            //if the min stress is zero then the smallest length is zero
            if (Math.Round(minStress, 1) == 0.0)
            {
                lengthMin = 0.0;
            }


            for (int i = 0; i < stresses.Count; i++)
            {
                //in case of constant stress (not equal to zero)
                int tMapColour = Convert.ToInt32(colourMax / 2.0);
                double tMapLength = lengthMax / 2.0;

                //If both max and min stress equals zero then the length is constant zero
                if (Math.Round(maxStress, 1) == 0.0 && Math.Round(minStress, 1) == 0.0)
                {
                    tMapLength = 0.0;
                }

                else if (Math.Round(stressRange, 1) != 0.0)
                {
                    double t = (stresses[i] - minStress) / stressRange;
                    tMapColour = Convert.ToInt32(t * (colourMax - colourMin) + colourMin);
                    tMapLength = t * (lengthMax - lengthMin) + lengthMin;
                }

                Color c = new Color();
                if (tMapColour <= 1 * 255)
                {
                    c = Color.FromArgb(0, tMapColour, 255);
                }
                else if (tMapColour > 1 * 255 && tMapColour <= 2 * 255)
                {
                    c = Color.FromArgb(0, 255, 255 - (tMapColour - (1 * 255)));
                }
                else if (tMapColour > 2 * 255 && tMapColour <= 3 * 255)
                {
                    c = Color.FromArgb(tMapColour - (2 * 255), 255, 0);
                }
                else
                {
                    c = Color.FromArgb(255, 255 - (tMapColour - (3 * 255)), 0);
                }

                Vector3d dir = new Vector3d(planes[i].YAxis);
                dir.Unitize();
                dir *= tMapLength;
                Line l = new Line(planes[i].Origin, planes[i].Origin + dir);

                colours.Add(c);
                lines.Add(l);
            }
        }
开发者ID:CecilieBrandt,项目名称:K2Engineering,代码行数:83,代码来源:BendingVisualisation.cs

示例10: coplanarmesh

 private bool coplanarmesh(Rhino.Geometry.Mesh M)
 {
     Vector3d meanN = new Vector3d();
     if (M.FaceNormals.Count == 0) M.FaceNormals.ComputeFaceNormals();
     meanN = M.FaceNormals[0];
     meanN.Unitize();
     double total = 0;
     foreach (Vector3d n in M.FaceNormals) total += Math.Sqrt(meanN.X * n.X + meanN.Y * n.Y + meanN.Z * n.Z);
     return total == 0;
 }
开发者ID:MengdiGuo,项目名称:PachydermAcoustic_Rhinoceros,代码行数:10,代码来源:Classes_Scenes.cs

示例11: RenderParticles

            private void RenderParticles(ParticleRays[] Rays, double total_Frames, Pachyderm_Acoustic.Visualization.Phonon P)
            {
                List<Guid> Particle_IDS = new List<Guid>();
                double Increment = CutOffLength() / (double)(Frame_Rate.Value * Seconds.Value);
                Point3d Point = default(Point3d);
                double PMin = (double)this.Param_Min.Value;
                double PMax = (double)this.Param_Max.Value;
                double PRange = PMax - PMin;

                for (int q = 0; q < (int)total_Frames; q++)
                {
                    for (int i = 0; i < Rays.Length; i++)
                    {
                        for (int p = 0; p < Rays[i].Count(); p++)
                        {
                            Point3d N;
                            double energy;
                            if (Rays[i].RayPt(p, Increment * q, 4, out energy, out N, out Point))
                            {
                                Vector3d V = new Vector3d(N - Point);
                                V.Unitize();
                                double SPL = AcousticalMath.SPL_Intensity(energy);
                                System.Drawing.Color C = scale.GetValue(SPL, PMin, PMax);
                                Mesh M = P.Generate(Point, V);
                                M.Scale((SPL - PMin) / PRange);
                                System.Guid PG = Rhino.RhinoDoc.ActiveDoc.Objects.AddMesh(M);
                                Rhino.RhinoDoc.ActiveDoc.Objects.Find(PG).Attributes.ObjectColor = C;
                                Particle_IDS.Add(PG);
                            }
                        }
                    }

                    string number;
                    if (q < 100)
                    {
                        if (q < 10) number = "00" + q.ToString();
                        else number = "0" + q.ToString();
                    }
                    else number = q.ToString();
                    Rhino.RhinoApp.RunScript("-ViewCaptureToFile " + Folder_Status.Text + "\\"[0] + "frame" + number + ".jpg Width=1280 Height=720 DrawGrid=No Enter", true);

                    //Clean Up Model
                    Rhino.RhinoDoc.ActiveDoc.Objects.Delete(Particle_IDS, true);
                    Particle_IDS.Clear();
                }
            }
开发者ID:MengdiGuo,项目名称:PachydermAcoustic_Rhinoceros,代码行数:46,代码来源:Pach_Visual_Control.cs

示例12: Joint

 Mesh Joint(Polyline pl1, Polyline pl2, double u, double v, double w)
 {
     Mesh mesh = new Mesh();
     Vector3d v11 = new Vector3d(pl1[2] - pl1[0]);
     v11.Unitize(); v11 *= (Math.Sqrt(2) * u) / 2;
     Line l12 = new Line(pl1[0] - v11, pl1[0] + v11);
     Line l11 = new Line(l12.From, l12.To);
     Line l13 = new Line(l12.From, l12.To);
     Vector3d v12 = pl1[1] - pl1[0];
     v12.Unitize(); v12 *= w;
     Vector3d v13 = pl1[3] - pl1[0];
     v13.Unitize(); v13 *= w;
     l13.Transform(Transform.Translation(v12));
     l11.Transform(Transform.Translation(v13));
     l11.Transform(Transform.Translation(new Vector3d(0, 0, v / 2)));
     l12.Transform(Transform.Translation(new Vector3d(0, 0, v / 2)));
     l13.Transform(Transform.Translation(new Vector3d(0, 0, v / 2)));
     mesh.Append(MT.MeshLoft(l11, l12));
     mesh.Append(MT.MeshLoft(l12, l13));
     Vector3d v21 = new Vector3d(pl2[2] - pl2[0]);
     v21.Unitize(); v21 *= (Math.Sqrt(2) * u) / 2;
     Line l22 = new Line(pl2[0] - v21, pl2[0] + v21);
     Line l21 = new Line(l22.From, l22.To);
     Line l23 = new Line(l22.From, l22.To);
     Vector3d v22 = pl2[1] - pl2[0];
     v22.Unitize(); v22 *= w;
     Vector3d v23 = pl2[3] - pl2[0];
     v23.Unitize(); v23 *= w;
     l23.Transform(Transform.Translation(v22));
     l21.Transform(Transform.Translation(v23));
     l21.Transform(Transform.Translation(new Vector3d(0, 0, -v / 2)));
     l22.Transform(Transform.Translation(new Vector3d(0, 0, -v / 2)));
     l23.Transform(Transform.Translation(new Vector3d(0, 0, -v / 2)));
     mesh.Append(MT.MeshLoft(l21, l22));
     mesh.Append(MT.MeshLoft(l22, l23));
     mesh.Append(MT.MeshLoft(l12, l22));
     return mesh;
 }
开发者ID:panhao4812,项目名称:Fincler,代码行数:38,代码来源:Class1.cs

示例13: SolveInstance

        protected override void SolveInstance(IGH_DataAccess DA)
        {
            PlanktonMesh P1 = null;
            if (!DA.GetData(0, ref P1)) return;
            List<double> RL = new List<double>() ;
            if (!DA.GetDataList(1, RL)) { return; }
            bool D = false;
            if (!DA.GetData(2, ref D)) { return; }

            if (D)
            {
                P1 = P1.Dual();
            }
            PlanktonMesh P2 = new PlanktonMesh();
            int vcount = P1.Vertices.Count;
            List<Vector3d> Normals = new List<Vector3d>();
            List<int> Outer = new List<int>();
            List<int> Inner = new List<int>();
            List<int> Elbow = new List<int>();

            for (int i = 0; i < vcount; i++)
            {
                Point3d Vertex = P1.Vertices[i].ToPoint3d();
                Vector3d Normal = new Vector3d();
                double AvgAngle = 0;

                double R = 0;
                if (RL.Count == 1)
                { R = RL[0]; }
                else
                { R = RL[i]; }

                int[] OutEdges = P1.Vertices.GetHalfedges(i);
                int[] Neighbours = P1.Vertices.GetVertexNeighbours(i);
                Vector3d[] OutVectors = new Vector3d[Neighbours.Length];
                int Valence = P1.Vertices.GetValence(i);

                for (int j = 0; j < Valence; j++)
                {
                    Vector3d OutVector = P1.Vertices[Neighbours[j]].ToPoint3d() - Vertex;
                    OutVector.Unitize();
                    OutVectors[j] = OutVector;
                }

                for (int j = 0; j < Valence; j++)
                {
                    if (P1.Halfedges[OutEdges[(j + 1) % Valence]].AdjacentFace != -1)
                    {Normal += (Vector3d.CrossProduct(OutVectors[(j + 1) % Valence], OutVectors[j]));}
                }

                Normal.Unitize();
                Normals.Add(Normal);

                for (int j = 0; j < Valence; j++)
                {
                    AvgAngle += Vector3d.VectorAngle(Normal, OutVectors[j]);
                }
                AvgAngle = AvgAngle * (1.0 / Valence);

                double Offset = R / (Math.Sin(AvgAngle));

                Outer.Add(P2.Vertices.Add(Vertex + (Normal * Offset))); //this adds the actual point to the mesh, as well as its index to Outer
                Inner.Add(P2.Vertices.Add(Vertex - (Normal * Offset)));
            }

            for (int i = 0; i < P1.Halfedges.Count; i++)
            {
                //get the 3 points of the angle
                int Prev = P1.Halfedges[i].PrevHalfedge;
                int Next = P1.Halfedges[i].NextHalfedge;
                int PrevV = P1.Halfedges[Prev].StartVertex;
                int NextV = P1.Halfedges[Next].StartVertex;
                int ThisV = P1.Halfedges[i].StartVertex;

                double R = 0;
                if (RL.Count == 1)
                { R = RL[0]; }
                else
                { R = RL[ThisV]; }

                Point3d PrevPt = P1.Vertices[PrevV].ToPoint3d();
                Point3d NextPt = P1.Vertices[NextV].ToPoint3d();
                Point3d ThisPt = P1.Vertices[ThisV].ToPoint3d();
                //construct the point at the inside of the 'elbow'
                Vector3d Arm1 = PrevPt - ThisPt;
                Vector3d Arm2 = NextPt - ThisPt;
                Arm1.Unitize(); Arm2.Unitize();
                double alpha = Vector3d.VectorAngle(Arm1, Arm2);
                Point3d ThisElbow;

                Vector3d Bisect = new Vector3d();
                if (P1.Halfedges[i].AdjacentFace == -1)
                {Bisect = Vector3d.CrossProduct(Normals[ThisV], -1.0 * Arm1) + Vector3d.CrossProduct(Normals[ThisV], Arm2);}
                else
                {Bisect = Arm1 + Arm2;}

                Bisect.Unitize();
                ThisElbow = ThisPt + Bisect * (R / Math.Sin(alpha * 0.5));
                Elbow.Add(P2.Vertices.Add(ThisElbow));
            }
//.........这里部分代码省略.........
开发者ID:nsbcnjsbc,项目名称:Exoskeleton2,代码行数:101,代码来源:Cytoskeleton.cs

示例14: AxisAngleToPlane

        public static Plane AxisAngleToPlane(double x, double y, double z, double vx, double vy, double vz)
        {
            var matrix = Transform.Identity;
            var vector = new Vector3d(vx, vy, vz);
            double angle = vector.Length;
            vector.Unitize();

            double c = Cos(angle);
            double s = Cos(angle);
            double t = 1.0 - c;

            matrix.M00 = c + vector.X * vector.X * t;
            matrix.M11 = c + vector.Y * vector.Y * t;
            matrix.M22 = c + vector.Z * vector.Z * t;

            double tmp1 = vector.X * vector.Y * t;
            double tmp2 = vector.Z * s;
            matrix.M10 = tmp1 + tmp2;
            matrix.M01 = tmp1 - tmp2;
            tmp1 = vector.X * vector.Z * t;
            tmp2 = vector.Y * s;
            matrix.M20 = tmp1 - tmp2;
            matrix.M02 = tmp1 + tmp2; tmp1 = vector.Y * vector.Z * t;
            tmp2 = vector.X * s;
            matrix.M21 = tmp1 + tmp2;
            matrix.M12 = tmp1 - tmp2;

            Plane plane = Plane.WorldXY;
            plane.Transform(matrix);
            plane.Origin = new Point3d(x, y, z);
            return plane;
        }
开发者ID:visose,项目名称:Robots,代码行数:32,代码来源:RobotCellUR.cs

示例15: Get_Directional_Map

            /// <summary>
            /// Plot energy directions based on the time range specified.
            /// </summary>
            /// <param name="SPL_Bounds">The boundaries of SPL domain to be used.</param>
            /// <param name="T_Bounds">The boundaries of time domain to be used.</param>
            /// <param name="S_OFFSET">S value offset (HSV Color system.)</param>
            /// <param name="S_BREADTH">S value breadth (HSV Color system.)</param>
            /// <param name="V_OFFSET">V value offset (HSV Color system.)</param>
            /// <param name="V_BREADTH">V value breadth (HSV Color system.)</param>
            /// <param name="Octave">The octave band to plot...</param>
            /// <returns>On Mesh with color assignments matching the input parameters and output variables.</returns>
            public static void Get_Directional_Map(PachMapReceiver[] Rec_List, double[] T_Bounds, int Octave, List<int> SrcID)
            {
                //T in ms.
                //Calculate SPL values...
                int T_Max = (int)Math.Floor((T_Bounds[0]));// / (double)ms_per_bin);
                int T_Min = (int)Math.Floor((T_Bounds[1]));// / (double)ms_per_bin);
                
                for (int i = 0; i < Rec_List[0].Rec_List.Length; i++)
                {
                    Vector3d V = new Vector3d();
                    foreach (int S_ID in SrcID)
                    {
                        double[] Hist = Rec_List[S_ID].GetEnergyHistogram(Octave, i);
                        for (int t = T_Min; t < T_Max; t++)
                        {
                            V.X += Rec_List[S_ID].Directions_Pos(Octave, t, i).x;
                            V.Y += Rec_List[S_ID].Directions_Pos(Octave, t, i).y;
                            V.Z += Rec_List[S_ID].Directions_Pos(Octave, t, i).z;
                            V.X += Rec_List[S_ID].Directions_Neg(Octave, t, i).x;
                            V.Y += Rec_List[S_ID].Directions_Neg(Octave, t, i).y;
                            V.Z += Rec_List[S_ID].Directions_Neg(Octave, t, i).z;
                        }
                    }
                    V.Unitize();

                    foreach (int S_ID in SrcID)
                    {
                        Rhino.RhinoDoc.ActiveDoc.Objects.AddCurve(new LineCurve(new Point3d(Rec_List[S_ID].Rec_List[i].H_Origin.x, Rec_List[S_ID].Rec_List[i].H_Origin.y, Rec_List[S_ID].Rec_List[i].H_Origin.z), new Point3d(Rec_List[S_ID].Rec_List[i].H_Origin.x + V.X, Rec_List[S_ID].Rec_List[i].H_Origin.y + V.Y, Rec_List[S_ID].Rec_List[i].H_Origin.z + V.Z)));
                    }
                }
            }
开发者ID:MengdiGuo,项目名称:PachydermAcoustic_Rhinoceros,代码行数:42,代码来源:Pach_Map_Receiver.cs


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