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


C# Vector3d.MultiplyBy方法代码示例

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


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

示例1: MoveItem

        public void MoveItem()
        {
            if (!rutaId.IsValid && !movilId.IsValid)
            {
                Lab2.Selector.ObjectId("Selecciona la ruta", "",
                    typeof(Line), out rutaId);
                Lab2.Selector.ObjectId("Selecciona el movil", "",
                    typeof(BlockReference), out movilId);
            }
            if (rutaId.IsValid && movilId.IsValid)
            {
                //Abrimos la geometría de la ruta
                Line ruta = Lab3.DBMan.OpenEnity(rutaId) as Line;
                BlockReference blkRef =
                    Lab3.DBMan.OpenEnity(movilId) as BlockReference;
                Point3d cent =
                    new Point3d((blkRef.GeometricExtents.MinPoint.X +
                                 blkRef.GeometricExtents.MaxPoint.X) / 2,
                                 (blkRef.GeometricExtents.MinPoint.Y +
                                 blkRef.GeometricExtents.MaxPoint.Y) / 2,
                                 0);
                //Vector de movimiento
                Vector3d v = new Vector3d(
                    ruta.EndPoint.X - ruta.StartPoint.X,
                    ruta.EndPoint.Y - ruta.StartPoint.Y, 0);
                //Hago unitario a mi vector
                v = v.MultiplyBy(1 / ruta.Length);
                v = v.MultiplyBy(d);
                //Crear una matriz de transformación
                Matrix3d matrix = Matrix3d.Displacement(v);
                Matrix3d rotMatrix =
                    Matrix3d.Rotation(new Vector2d(v.X, v.Y).Angle, Vector3d.ZAxis, cent);
                //Realizo la transformación del vehiculo
                Lab3.DBMan.Transform(matrix, movilId);

                //Se acomada al segmento regresando la rotación al origen
                //Matrix3d rotMatrixOrigin =
                //    Matrix3d.Rotation(blkRef.Rotation * -1, Vector3d.ZAxis, cent);
                //Lab3.DBMan.Transform(rotMatrixOrigin, movilId);
                //Lab3.DBMan.Transform(rotMatrix, movilId);

                //Modo 2 Rotando el bloque a la dirección del vector de ruta.
                Lab3.DBMan.UpdateBlockRotation(new Vector2d(v.X, v.Y).Angle, movilId);

            }
        }
开发者ID:JOndarza,项目名称:CAD,代码行数:46,代码来源:Commands.cs

示例2: MoveItem2

        public void MoveItem2()
        {
            ObjectId cId, lId;
            if (Lab2.Selector.ObjectId("Selecciona el movil", "", typeof(Circle), out cId) &&
                Lab2.Selector.ObjectId("Selecciona la ruta", "", typeof(Line), out lId))
            {
                Line l = Lab3.DBMan.OpenEnity(lId) as Line;
                Circle c = Lab3.DBMan.OpenEnity(cId) as Circle;
                Vector3d v = new Vector3d(l.EndPoint.X - l.StartPoint.X, l.EndPoint.Y - l.StartPoint.Y, 0);
                v = v.MultiplyBy(d / v.Length);
                Matrix3d m = Matrix3d.Displacement(v);
                Editor ed = Application.DocumentManager.MdiActiveDocument.Editor;
                Database dwg = Application.DocumentManager.MdiActiveDocument.Database;
                using (Transaction tr = dwg.TransactionManager.StartTransaction())
                {
                    try
                    {
                        c = c.Id.GetObject(OpenMode.ForWrite) as Circle;
                        c.TransformBy(m);
                        tr.Commit();
                    }
                    catch (System.Exception exc)
                    {
                        ed.WriteMessage(exc.Message);
                        tr.Abort();
                    }
                }

            }
            d = 50;
        }
开发者ID:JOndarza,项目名称:CAD,代码行数:31,代码来源:Commands.cs

示例3: UpdateDireccion

 public Vector3d UpdateDireccion()
 {
     Vector3d v;
     if (this.ruta.GetBulgeAt(segmentoActualIndex) == 0)
     {
         if (pointActualCurve > 0)
             pointActualCurve = 0;
         v = new Vector3d(
             segmentoActual.EndPoint.X - segmentoActual.StartPoint.X,
             segmentoActual.EndPoint.Y - segmentoActual.StartPoint.Y,
             0);
         v = v.MultiplyBy(1 / this.segmentoActual.Length);
         this.dir = v;
         v = v.MultiplyBy(this.d * this.velocityScale);
     }
     else
     {
         Point3d centroCurva = this.ruta.GetArcSegmentAt(segmentoActualIndex).Center;
         v = new Vector3d(
            this.bloque.Position.X - centroCurva.X,
            this.bloque.Position.Y - centroCurva.Y,
            0);
         PointOnCurve3d[] pts = ruta.GetArcSegmentAt(segmentoActualIndex).GetSamplePoints((int)(this.d * this.dS));
         if (pointActualCurve < (int)(this.d * this.dS) && this.velocityScale >= 1f)
         {
             Lab3.DBMan.UpdateBlockPosition(new Point3d(pts[pointActualCurve].Point.X, pts[pointActualCurve].Point.Y, 0), mobile);
             v = ruta.GetArcSegmentAt(segmentoActualIndex).GetTangent(pts[pointActualCurve].Point).Direction.Negate();
             pointActualCurve++;
         }
         else
             v = ruta.GetArcSegmentAt(segmentoActualIndex).GetTangent(pts[pointActualCurve].Point).Direction.Negate();
         this.dir = v;
         v = v.MultiplyBy(this.d * (1 - (this.dS / 100f)) * this.velocityScale);
     }
     return v;
 }
开发者ID:JOndarza,项目名称:CAD,代码行数:36,代码来源:Movil.cs


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