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


C# Interval.NormalizedParameterAt方法代码示例

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


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

示例1: SolveInstance

        protected override void SolveInstance(IGH_DataAccess DA)
        {
            List<DHr> hours = new List<DHr>();
            String key_r = "";
            String key_a = "";
            if (DA.GetDataList(0, hours) && DA.GetData(1, ref key_r) && DA.GetData(2, ref key_a)) {

                Interval ival_r = new Interval();
                Interval ival_a = new Interval();
                float[] vals_r = new float[0];
                float[] vals_a = new float[0];

                if (!(DA.GetData(3, ref ival_r))) DHr.get_domain(key_r, hours.ToArray(), ref vals_r, ref ival_r);
                else {
                    ival_r = new Interval(hours[0].val(key_r), hours[0].val(key_r));

                    vals_r = new float[hours.Count];
                    for (int h = 0; h < hours.Count; h++) {
                        vals_r[h] = hours[h].val(key_r);
                        if (vals_r[h] < ival_r.T0) ival_r.T0 = vals_r[h];
                        if (vals_r[h] > ival_r.T1) ival_r.T1 = vals_r[h];
                    }
                }

                DHr.get_domain(key_a, hours.ToArray(), ref vals_a, ref ival_a);
                DA.GetData(4, ref ival_a);

                Plane plane = new Plane(new Point3d(0, 0, 0), new Vector3d(0, 0, 1));
                DA.GetData(5, ref plane);

                Interval ival_gr = new Interval();
                Interval ival_ga = new Interval(0, Math.PI * 2);
                DA.GetData(6, ref ival_gr);

                Interval subdivs = new Interval();
                DA.GetData(7, ref subdivs);
                int subdivs_r = (int)Math.Floor(subdivs.T0);
                int subdivs_a = (int)Math.Floor(subdivs.T1);

                List<Point3d> points = new List<Point3d>();
                for (int h = 0; h < hours.Count; h++) {
                    double radius = ival_gr.ParameterAt(ival_r.NormalizedParameterAt(vals_r[h]));
                    double theta = ival_a.NormalizedParameterAt(vals_a[h]) * Math.PI * 2;
                    Point3d gpt = PointByCylCoords(radius, theta); // a point in graph coordinates
                    hours[h].pos = gpt; // the hour records the point in graph coordinates

                    Point3d wpt = plane.PointAt(gpt.X, gpt.Y);
                    points.Add(wpt);  // adds this point in world coordinates
                }

                Grasshopper.Kernel.Data.GH_Structure<Grasshopper.Kernel.Types.GH_Curve> regions = new Grasshopper.Kernel.Data.GH_Structure<Grasshopper.Kernel.Types.GH_Curve>();

                int segments_in_whole_circle = 36;
                //double step_r = ival_r.Length / subdivs_r;
                //double step_a = Math.PI*2 / subdivs_a;

                for (int r = 0; r < subdivs_r; r++)
                    for (int a = 0; a < subdivs_a; a++) {
                        Interval rad = new Interval(ival_gr.ParameterAt(r / (float)subdivs_r), ival_gr.ParameterAt((r + 1) / (float)subdivs_r));
                        Interval ang = new Interval(ival_ga.ParameterAt(a / (float)subdivs_a), ival_ga.ParameterAt((a + 1) / (float)subdivs_a));

                        int cnt = (int)Math.Ceiling(segments_in_whole_circle * ang.Length / Math.PI * 2);
                        Polyline pcrv = new Polyline();
                        pcrv.AddRange(FakeArc(plane, rad.T0, ang.T0, ang.T1, cnt));
                        pcrv.AddRange(FakeArc(plane, rad.T1, ang.T1, ang.T0, cnt));
                        pcrv.Add(pcrv[0]);

                        Grasshopper.Kernel.Types.GH_Curve gh_curve = new Grasshopper.Kernel.Types.GH_Curve();
                        Grasshopper.Kernel.GH_Convert.ToGHCurve(pcrv, GH_Conversion.Both, ref gh_curve);
                        regions.Append(gh_curve, new Grasshopper.Kernel.Data.GH_Path(new int[] { r, a }));
                    }

                DA.SetDataList(0, hours);
                DA.SetDataList(1, points);
                DA.SetDataTree(2, regions);

            }
        }
开发者ID:ksteinfe,项目名称:dyear,代码行数:78,代码来源:Components+Spatializing.cs

示例2: GraphPoint

 private Point3d GraphPoint(int hour_of_year, float value, Plane plane, Interval ival_y, Grasshopper.Kernel.Types.UVInterval ival2d)
 {
     // returns a point in graph coordinates, ready to be plotted on a given plane
     double x = ival2d.U.ParameterAt((hour_of_year + 0.5) / 8760.0);
     double y = ival2d.V.ParameterAt(ival_y.NormalizedParameterAt(value));
     Point3d pt = new Point3d(x, y, 0);
     return pt;
 }
开发者ID:ksteinfe,项目名称:dyear,代码行数:8,代码来源:Components+Spatializing.cs

示例3: SolveInstance

        protected override void SolveInstance(IGH_DataAccess DA)
        {
            List<DHr> hours = new List<DHr>();
            string key_a = "";
            string key_b = "";
            Color c11 = new Color();
            Color c10 = new Color();
            Color c01 = new Color();
            Color c00 = new Color();
            Interval domain_a = new Interval();
            Interval domain_b = new Interval();
            if ((DA.GetDataList(0, hours)) && (DA.GetData(1, ref key_a)) && (DA.GetData(3, ref key_b)) && (DA.GetData(5, ref c11)) && (DA.GetData(6, ref c10)) && (DA.GetData(7, ref c01)) && (DA.GetData(8, ref c00))   ) {
                float[] vals_a = new float[0];
                if (!(DA.GetData(2, ref domain_a))) DHr.get_domain(key_a, hours.ToArray(), ref vals_a, ref domain_a);
                else {
                    vals_a = new float[hours.Count];
                    for (int h = 0; h < hours.Count; h++) vals_a[h] = hours[h].val(key_a);
                }
                float[] vals_b = new float[0];
                if (!(DA.GetData(4, ref domain_b))) DHr.get_domain(key_b, hours.ToArray(), ref vals_b, ref domain_b);
                else {
                    vals_b = new float[hours.Count];
                    for (int h = 0; h < hours.Count; h++) vals_b[h] = hours[h].val(key_b);
                }

                List<Color> colors = new List<Color>();
                for (int h = 0; h < hours.Count; h++) {
                    double ta = domain_a.NormalizedParameterAt(vals_a[h]);
                    if (ta < 0) { this.AddRuntimeMessage(GH_RuntimeMessageLevel.Warning, "Value for key A falls below minimum of specified domain at index" + h); continue; }
                    if (ta > 1) { this.AddRuntimeMessage(GH_RuntimeMessageLevel.Warning, "Value for key A falls above maximum of specified domain at index" + h); continue; }

                    double tb = domain_b.NormalizedParameterAt(vals_b[h]);
                    if (tb < 0) { this.AddRuntimeMessage(GH_RuntimeMessageLevel.Warning, "Value for key B falls below minimum of specified domain at index" + h); continue; }
                    if (tb > 1) { this.AddRuntimeMessage(GH_RuntimeMessageLevel.Warning, "Value for key B falls above maximum of specified domain at index" + h); continue; }

                    Color c0 = Util.InterpolateColor(c00, c10, ta);
                    Color c1 = Util.InterpolateColor(c01, c11, ta);
                    Color c = Util.InterpolateColor(c0, c1, tb);
                    colors.Add(c);
                    hours[h].color = c;
                }

                DA.SetDataList(0, hours);
                DA.SetDataList(1, colors);
            }
        }
开发者ID:ksteinfe,项目名称:dyear,代码行数:46,代码来源:Components+Decorating.cs


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