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


C# Curve.PerpendicularFrameAt方法代码示例

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


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

示例1: Edge_Curved

        public Edge_Curved(ref IEnumerable<Hare.Geometry.Point> SPT, ref IEnumerable<Hare.Geometry.Point> RPT, Environment.Medium_Properties Env_Props, Brep[] B, int[] Brep_Index, Curve i)
            : base(B, i)
        {
            //if (i.IsLinear()) throw new Exception("Curved Edge object called for straight edge.");
            //Rhino.RhinoDoc.ActiveDoc.Objects.AddCurve(i);
            ParentBreps = Brep_Index;
            
            //Get the open wedge angle. This needs the source location, and occlusion info...
            //Assuming tangent angles are always correctly oriented...
            //Vector Z_Dir = PointA - PointB;
            //double length = Z_Dir.Length();
            //Z_Dir.Normalize();
            //double MinAngle = double.PositiveInfinity;
            //Hare.Geometry.Point[] Dpt = new Hare.Geometry.Point[0];

            //Find the secondary source spacing DeltaZ
            /// 1/4 wavelength substituted for now...
            double fs = 88200; //Hz.
            //double DeltaZ = speed_of_sound / (fs * Math.Cos(MinAngle));//TODO: Adjust depending on distance from source to receiver... (nearest, farthest?
           
            /////
            //double El_Ct = Math.Ceiling(i.GetLength() / DeltaZ);
            //DeltaZ = i.GetLength() / El_Ct;
            //List<Point3d> Pts;
            double length = Env_Props.Sound_Speed(i.PointAtStart)/ (8 * fs);
            double total_length = i.GetLength();
            double t;
            
            //for (int j = 1; j < Pts.Length; j++)
            while (true)
            {
                if (!i.LengthParameter(length, out t)) break;
                Plane P;
                i.PerpendicularFrameAt(t, out P);
                Curve[] Csects1, Csects2;
                Point3d[] Psects;

                //double DeltaZ = Env_Props.Sound_Speed(Point3d.Origin) / (4 * fs);
                Rhino.Geometry.Intersect.Intersection.BrepPlane(B[0], P, 0.001, out Csects1, out Psects);
                Rhino.Geometry.Intersect.Intersection.BrepPlane(B[1], P, 0.001, out Csects2, out Psects);
                Vector3d[] Tangents = new Vector3d[2];
                ///Control Start Point of curve
                if ((Csects1[0].PointAtStart.X * P.Origin.X + Csects1[0].PointAtStart.Y * P.Origin.Y + Csects1[0].PointAtStart.Z * P.Origin.Z) < 0.00001) Csects1[0].Reverse();
                if ((Csects2[0].PointAtStart.X * P.Origin.X + Csects2[0].PointAtStart.Y * P.Origin.Y + Csects2[0].PointAtStart.Z * P.Origin.Z) < 0.00001) Csects2[0].Reverse();
                ///Get Tangent Vector
                Tangents[0] = (Csects1[0].PointAtNormalizedLength(0.05) - P.Origin);
                Tangents[0].Unitize();
                Tangents[1] = (Csects2[0].PointAtNormalizedLength(0.05) - P.Origin);
                Tangents[1].Unitize();
                Hare.Geometry.Vector[] HTangents = new Hare.Geometry.Vector[2] { new Hare.Geometry.Vector(Tangents[0].X, Tangents[0].Y, Tangents[0].Z), new Hare.Geometry.Vector(Tangents[1].X, Tangents[1].Y, Tangents[1].Z) };
                ///Get Normal
                double up, vp;
                ComponentIndex CI;
                Point3d outPt;
                Vector3d[] Normals = new Vector3d[2];
                //Point3d CPT = Utilities.PachTools.HPttoRPt(Z_mid);
                B[0].ClosestPoint(P.Origin, out outPt, out CI, out up, out vp, 0.01, out Normals[0]);
                B[1].ClosestPoint(P.Origin, out outPt, out CI, out up, out vp, 0.01, out Normals[1]);
                Hare.Geometry.Vector[] HNormals = new Hare.Geometry.Vector[2] { new Hare.Geometry.Vector(Normals[0].X, Normals[0].Y, Normals[0].Z), new Hare.Geometry.Vector(Normals[1].X, Normals[1].Y, Normals[1].Z) };
                //// Get Vector Tangents.
                //Hare.Geometry.Point Pt1 = new Hare.Geometry.Point(Pts[j-1].X, Pts[j-1].Y, Pts[j-1].Z);
                //Hare.Geometry.Point Pt2 = new Hare.Geometry.Point(Pts[j].X, Pts[j].Y, Pts[j].Z);
                double Delta_Z = Env_Props.Sound_Speed(P.Origin) / (4 * fs);//TODO: Adjust depending on distance from source to receiver... (nearest, farthest?)
                Sources.Add(new EdgeSource(Edge.Rigid, Utilities.PachTools.RPttoHPt(P.Origin), Delta_Z, HTangents));

                length += Delta_Z;
            }
        }
开发者ID:MengdiGuo,项目名称:PachydermAcoustic_Rhinoceros,代码行数:68,代码来源:Classes_Edges.cs

示例2: MeshSweep1

        public Mesh MeshSweep1(Curve l, Polyline ls, Plane SectionPos, int Count)
        {
            List<Polyline> ps = new List<Polyline>();
            Mesh mesh = new Mesh();
            double[] div = l.DivideByCount(Count, true);

            for (int i = 0; i < div.Length; i++)
            {
                Polyline l1 = new Polyline(ls);
                Plane plane;
                if (l.PerpendicularFrameAt(div[i], out plane))
                {
                    l1.Transform(Transform.PlaneToPlane(SectionPos, plane));
                    ps.Add(l1);
                }
            }
            mesh.Append(MeshLoft(ps, false, false));
            return mesh;
        }
开发者ID:panhao4812,项目名称:MeshClassLibrary,代码行数:19,代码来源:MeshCreation.cs

示例3: Edge_Straight

        public Edge_Straight(ref IEnumerable<Hare.Geometry.Point> SPT, ref IEnumerable<Hare.Geometry.Point> RPT, Environment.Medium_Properties Att_Props, Rhino.Geometry.Brep[] Brep, int[] Brep_Index, Curve Be)
            : base(Brep, Be)
        {
            //Rhino.RhinoDoc.ActiveDoc.Objects.Add(Brep[0]);
            //Rhino.RhinoDoc.ActiveDoc.Objects.Add(Brep[1]);
            ParentBreps = Brep_Index;
            //Rhino.RhinoDoc.ActiveDoc.Objects.AddCurve(Be);

            //if (!Brep.Edges[edge_id].IsLinear()) throw new Exception("Straight_Edge object called for curved edge.");
            Rhino.Geometry.Point3d PA = Be.PointAtStart;
            Rhino.Geometry.Point3d PB = Be.PointAtEnd;
            PointA = Utilities.PachTools.RPttoHPt(PA);
            PointB = Utilities.PachTools.RPttoHPt(PB);

            //Get the open wedge angle. This needs the source location, and occlusion info...
            //Assuming tangent angles are always correctly oriented...
            Vector Z_Dir = PointA - PointB;
            double length = Z_Dir.Length();
            Z_Dir.Normalize();
            double MinAngle = double.PositiveInfinity;
            List<Hare.Geometry.Point> Dpt = new List<Hare.Geometry.Point>();

            //Find the secondary source spacing DeltaZ
            Dpt.AddRange(RPT);
            Dpt.AddRange(SPT);

            for (int j = 0; j < Dpt.Count; j++)
            {
                double angle = Math.Abs(Hare_math.Dot(PointA - Dpt[j], Z_Dir));
                if (angle < MinAngle) MinAngle = angle;
                angle = Math.Abs(Hare_math.Dot(PointB - Dpt[j], Z_Dir));
                if (angle < MinAngle) MinAngle = angle;
            }
            double fs = 176400; //Hz.
            double DeltaZ = Att_Props.Sound_Speed(this.PointA) / (fs * MinAngle);//TODO: Adjust depending on distance from source to receiver... (nearest, farthest?)
            
            double El_Ct = Math.Ceiling(length / DeltaZ);
            DeltaZ = length / El_Ct;

            Random r = new Random();

            Plane P;
            Curve[] Csects1;
            Curve[] Csects2;
            Point3d[] Psects;

            //for (;;)
            //{
                double t = r.NextDouble() * (Be.Domain.Max - Be.Domain.Min) + Be.Domain.Min;

                Be.PerpendicularFrameAt(t, out P);

                Rhino.Geometry.Intersect.Intersection.BrepPlane(Brep[0], P, 0.1, out Csects1, out Psects);
                Rhino.Geometry.Intersect.Intersection.BrepPlane(Brep[1], P, 0.1, out Csects2, out Psects);

                //if (Csects1 != null && Csects2 != null && Csects1.Length > 0 && Csects2.Length > 0) break;

                //Rhino.RhinoDoc.ActiveDoc.Objects.Add(Csects1[0]);
                //Rhino.RhinoDoc.ActiveDoc.Objects.Add(Csects2[0]);
            //}

            Vector3d[] Tangents = new Vector3d[2];
            ///Control Start Point of curve
            if ((Csects1[0].PointAtStart.X * P.Origin.X + Csects1[0].PointAtStart.Y * P.Origin.Y + Csects1[0].PointAtStart.Z * P.Origin.Z) < 0.00001) Csects1[0].Reverse();
            if ((Csects2[0].PointAtStart.X * P.Origin.X + Csects2[0].PointAtStart.Y * P.Origin.Y + Csects2[0].PointAtStart.Z * P.Origin.Z) < 0.00001) Csects2[0].Reverse();
            ///Get Tangent Vector
            Tangents[0] = (Csects1[0].PointAtNormalizedLength(0.05) - P.Origin);
            Tangents[0].Unitize();
            Tangents[1] = (Csects2[0].PointAtNormalizedLength(0.05) - P.Origin);
            Tangents[1].Unitize();
            Hare.Geometry.Vector[] HTangents = new Hare.Geometry.Vector[2] { new Hare.Geometry.Vector(Tangents[0].X, Tangents[0].Y, Tangents[0].Z), new Hare.Geometry.Vector(Tangents[1].X, Tangents[1].Y, Tangents[1].Z) };
            ///Get Normal
            double up, vp;
            ComponentIndex CI;
            Point3d outPt;
            Vector3d[] Normals = new Vector3d[2];
            Brep[0].ClosestPoint(P.Origin, out outPt, out CI, out up, out vp, 0.01, out Normals[0]);
            Brep[1].ClosestPoint(P.Origin, out outPt, out CI, out up, out vp, 0.01, out Normals[1]);
            Hare.Geometry.Vector[] HNormals = new Hare.Geometry.Vector[2] { new Hare.Geometry.Vector(Normals[0].X, Normals[0].Y, Normals[0].Z), new Hare.Geometry.Vector(Normals[1].X, Normals[1].Y, Normals[1].Z) };
            Hare.Geometry.Point Pt1 = new Hare.Geometry.Point(PointA.x, PointA.y, PointA.z);

            //TODO - Modify DeltaZ per change in velocity.
            for (int i = 1; i < El_Ct; i++)
            {
                Hare.Geometry.Point Pt2 = PointA - i * Z_Dir * DeltaZ;
                Sources.Add(new EdgeSource(Edge.Rigid, Pt1, Pt2, HTangents));
                //HTangents[1]*= -1;
                //Sources.Add(new EdgeSource(Edge.Rigid, Pt1, Pt2, HTangents));
                Pt1 = Pt2;
            }
        }
开发者ID:MengdiGuo,项目名称:PachydermAcoustic_Rhinoceros,代码行数:91,代码来源:Classes_Edges.cs


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