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


C# Plane.Rotate方法代码示例

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


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

示例1: CartesianLerp

        /// <summary>
        /// Quaternion interpolation based on: http://www.grasshopper3d.com/group/lobster/forum/topics/lobster-reloaded
        /// </summary>
        /// <param name="a"></param>
        /// <param name="b"></param>
        /// <param name="t"></param>
        /// <param name="min"></param>
        /// <param name="max"></param>
        /// <returns></returns>
        public virtual Plane CartesianLerp(Plane a, Plane b, double t, double min, double max)
        {
            t = (t - min) / (max - min);
            if (double.IsNaN(t)) t = 0;
            var newOrigin = a.Origin * (1 - t) + b.Origin * t;

            Quaternion q = Quaternion.Rotation(a, b);
            q.GetRotation(out var angle, out var axis);
            angle = (angle > PI) ? angle - 2 * PI : angle;
            a.Rotate(t * angle, axis, a.Origin);

            a.Origin = newOrigin;
            return a;
        }
开发者ID:visose,项目名称:Robots,代码行数:23,代码来源:RobotSystem.cs

示例2: SolveInstance

        protected override void SolveInstance(IGH_DataAccess DA)
        {
            List<DHr> hours = new List<DHr>();
            string alt_key = "solar_altitude";
            Interval alt_ival = new Interval(0, Math.PI / 2);
            string azm_key = "solar_azimuth";
            Interval azm_ival = new Interval(0, Math.PI * 2);
            bool cull_night = true;

            if (DA.GetDataList(0, hours)) {

                this.plot_type = PType.Invalid;
                String p_type_string = "";
                DA.GetData(4, ref p_type_string);
                p_type_string = p_type_string.ToLowerInvariant().Trim();
                if (p_type_string.Contains("stereo")) { this.plot_type = PType.Stereo; }
                if (p_type_string.Contains("ortho")) { this.plot_type = PType.Ortho; }
                if (this.plot_type == PType.Invalid) {
                    this.AddRuntimeMessage(GH_RuntimeMessageLevel.Error, "Plot type not recognized. Choose 'Ortho' or 'Stereo'.");
                    return;
                }

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

                Grasshopper.Kernel.Types.UVInterval ival2d = new Grasshopper.Kernel.Types.UVInterval();
                if (!DA.GetData(2, ref ival2d)) {
                    ival2d.U0 = 0.0;
                    ival2d.U1 = 1.0;
                    ival2d.V0 = 0.0;
                    ival2d.V1 = 1.0;
                }
                double radius_gr = 3.0;
                DA.GetData(3, ref radius_gr);

                DA.GetData(5, ref alt_key);
                DA.GetData(6, ref azm_key);
                DA.GetData(7, ref cull_night);

                List<Point3d> points = new List<Point3d>();

                Plane drawPlane = new Plane(plane);

                if (this.plot_type == PType.Ortho) DA.SetData(5, new Rectangle3d(drawPlane, ival2d.U, ival2d.V)); // set the trimming boundary
                if (this.plot_type == PType.Stereo)
                {
                    drawPlane.Origin = new Point3d(plane.Origin.X, plane.Origin.Y + ival2d.V.Mid, plane.Origin.Z);
                    drawPlane.Rotate(-Math.PI / 2, drawPlane.ZAxis);
                    ival2d.V0 = radius_gr; // sets the radius of stereographic plots
                    ival2d.V1 = 0.0;

                    Circle circ = new Circle(drawPlane, Math.Abs(ival2d.V.Length));
                    DA.SetData(5, circ); // set the trimming boundary
                }

                for (int h = 0; h < hours.Count; h++) {
                    double x = 0;
                    double y = 0;
                    switch (this.plot_type) {
                        case PType.Ortho:
                            x = ival2d.U.ParameterAt(azm_ival.NormalizedParameterAt(hours[h].val(azm_key)));
                            y = ival2d.V.ParameterAt(alt_ival.NormalizedParameterAt(hours[h].val(alt_key)));
                            break;

                        case PType.Stereo:
                            double radius = ival2d.V.ParameterAt(alt_ival.NormalizedParameterAt(hours[h].val(alt_key)));
                            double theta = -hours[h].val(azm_key); // reversed theta to ensure clockwise direction
                            x = radius * Math.Cos(theta);
                            y = radius * Math.Sin(theta);
                            break;
                    }
                    Point3d pt = drawPlane.PointAt(x, y);
                    points.Add(pt);
                    hours[h].pos = pt; // TODO: solar plots currently record the point in world space, switch to graph space
                }

                List<Polyline> plines = new List<Polyline>();
                List<Color> colors = new List<Color>();
                for (int h = 0; h < points.Count; h++)
                {
                    List<Point3d> pts = new List<Point3d>();
                    DHr prev_hr; if (h > 0) prev_hr = hours[h - 1]; else prev_hr = hours[hours.Count - 1];
                    DHr this_hr = hours[h];
                    DHr next_hr; if (h < hours.Count - 1) next_hr = hours[h + 1]; else next_hr = hours[0];

                    switch (this.plot_type) {
                        case PType.Ortho:
                            if ((this_hr.hr - 1 == prev_hr.hr) && (this_hr.pos_x > prev_hr.pos_x)) pts.Add(interp(this_hr.pos, prev_hr.pos, 0.5));
                            pts.Add(this_hr.pos);
                            if ((this_hr.hr + 1 == next_hr.hr) && (this_hr.pos_x < next_hr.pos_x)) pts.Add(interp(this_hr.pos, next_hr.pos, 0.5));
                            break;

                        case PType.Stereo:
                            pts.Add(interp(this_hr.pos, prev_hr.pos, 0.5));
                            pts.Add(this_hr.pos);
                            pts.Add(interp(this_hr.pos, next_hr.pos, 0.5));
                            break;
                    }

                    plines.Add(new Polyline(pts));
//.........这里部分代码省略.........
开发者ID:ksteinfe,项目名称:dyear,代码行数:101,代码来源:Components+Spatializing.cs

示例3: GetNeighborsInVisionAngle

    private ISpatialCollection<IQuelea> GetNeighborsInVisionAngle(ISpatialCollection<IQuelea> neighborsInSphere)
    {
      ISpatialCollection<IQuelea> neighborsInVisionAngle = new SpatialCollectionAsList<IQuelea>();
      Point3d position = agent.Position;
      Vector3d velocity = agent.Velocity;
      Plane pl1 = new Plane(position, velocity);
      pl1.Rotate(-RS.HALF_PI, pl1.YAxis);
      Plane pl2 = pl1;
      pl2.Rotate(-RS.HALF_PI, pl1.XAxis);
      double halfVisionAngle = agent.VisionAngle * visionAngleMultiplier / 2;
      foreach (IQuelea neighbor in neighborsInSphere)
      {
        Vector3d diff = Util.Vector.Vector2Point(position, neighbor.Position);
        double angle1 = Util.Vector.CalcAngle(velocity, diff, pl1);
        double angle2 = Util.Vector.CalcAngle(velocity, diff, pl2);
        if (Util.Number.DefinitelyLessThan(angle1, halfVisionAngle, Constants.AbsoluteTolerance) &&
            Util.Number.DefinitelyLessThan(angle2, halfVisionAngle, Constants.AbsoluteTolerance))
        {
          neighborsInVisionAngle.Add(neighbor);
        }
      }

      return neighborsInVisionAngle;
    }
开发者ID:lxfschr,项目名称:Quelea,代码行数:24,代码来源:NeighborsComponent.cs

示例4: SolveInstance


//.........这里部分代码省略.........
                {
                    PlaneOffsets[StrutIndices[0]] = 0;
                    //PlaneOffsets[StrutIndices[0]] = ND;
                    if (O) StrutSolo[StrutIndices[0]] = true;
                }

                //build base planes, offset them for hulling, and array hull vertices for each strut
                for (int I1 = 0; I1 < StrutIndices.Count; I1++)
                {
                    //build base planes
                    Curve Strut = Struts[StrutIndices[I1]];
                    Plane StrutPlane;

                    //sets the strut plane
                    if (StrutIndices[I1] % 2 == 0) Strut.PerpendicularFrameAt(0, out StrutPlane);
                    else
                    {
                        Curve LookupStrut = Struts[StrutIndices[I1] - 1];
                        LookupStrut.PerpendicularFrameAt(0, out StrutPlane);
                    }

                    //offset planes for hulling
                    StrutPlane.Origin = Strut.PointAtStart + Strut.TangentAtStart * MinOffset;
                    double StrutRadius = StrutRadii[StrutIndices[I1]];

                    //add strut tangent to list of knuckle orientation vectors
                    Knuckles.Add(-Strut.TangentAtStart);

                    //add hulling vertices
                    for (int HV = 0; HV < S; HV++) StrutHullVtc[StrutIndices[I1], HV] = StrutPlane.PointAt(Math.Cos((HV / Sides) * Math.PI * 2) * StrutRadius, Math.Sin((HV / Sides) * Math.PI * 2) * StrutRadius);

                    double OffsetMult = PlaneOffsets[StrutIndices[I1]];
                    if (ND > OffsetMult) OffsetMult = ND;
                    if (StrutIndices[I1] % 2 != 0) StrutPlane.Rotate(Math.PI, StrutPlane.YAxis, StrutPlane.Origin);

                    if (StrutIndices.Count ==1) OffsetMult = 0;

                    StrutPlanes[StrutIndices[I1]] = StrutPlane;
                    StrutPlanes[StrutIndices[I1]].Origin = Strut.PointAtStart + Strut.TangentAtStart * OffsetMult;

                }

                //collect all of the hull points from each strut in a given node for hulling, including knuckle points

                if (StrutIndices.Count > 1)
                {
                    List<Point3d> HullPts = new List<Point3d>();
                    List<int> PlaneIndices = new List<int>();

                    double KnuckleOffset = MinOffset * 0.5;

                    for (int HV = 0; HV < S; HV++)
                    {
                        for (int I1 = 0; I1 < StrutIndices.Count; I1++)
                        {
                            HullPts.Add(StrutHullVtc[StrutIndices[I1], HV]);
                            PlaneIndices.Add(StrutIndices[I1]);
                            if (HV == 0)
                            {
                                HullPts.Add(Nodes[NodeIdx] + (Knuckles[I1] * KnuckleOffset));
                                PlaneIndices.Add(-1);
                            }
                        }
                        double Angle = ((double)HV / S) * (Math.PI * 2);
                    }
开发者ID:nsbcnjsbc,项目名称:Exoskeleton2,代码行数:66,代码来源:ExoWireframe.cs


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