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


C# Vector3d.CrossProduct方法代码示例

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


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

示例1: btnAlign_Click

        private void btnAlign_Click(object sender, EventArgs e)
        {
            Editor ed = Autodesk.AutoCAD.ApplicationServices.Application.DocumentManager.MdiActiveDocument.Editor;
            using (EditorUserInteraction UI = ed.StartUserInteraction(this))
            {
                PromptEntityOptions opts = new PromptEntityOptions("\nSelect entity: ");
                opts.AllowNone = false;
                opts.SetRejectMessage("\nSelect a LINE, ARC or POLYLINE entity.");
                opts.AddAllowedClass(typeof(Curve), false);
                PromptEntityResult per = ed.GetEntity(opts);
                if (per.Status == PromptStatus.OK)
                {
                    Point3d pt = per.PickedPoint;
                    ObjectId id = per.ObjectId;

                    bool posUp = false;
                    Vector3d dir = new Vector3d(), up = new Vector3d(), normal = new Vector3d();
                    Database db = HostApplicationServices.WorkingDatabase;
                    using (Transaction tr = db.TransactionManager.StartTransaction())
                    {
                        try
                        {
                            RebarPos pos = (RebarPos)tr.GetObject(m_Pos, OpenMode.ForRead);

                            Curve curve = (Curve)tr.GetObject(id, OpenMode.ForRead);
                            pt = curve.GetClosestPointTo(pt, curve.GetPlane().Normal, false);
                            dir = curve.GetFirstDerivative(pt);
                            dir = dir * pos.DirectionVector.Length / dir.Length;
                            normal = pos.NormalVector;
                            normal = normal * pos.DirectionVector.Length / normal.Length;
                            up = dir.CrossProduct(normal);
                            up = up * pos.DirectionVector.Length / up.Length;

                            posUp = (dir.DotProduct(pos.UpVector) > 0);
                        }
                        catch (System.Exception ex)
                        {
                            System.Windows.Forms.MessageBox.Show("Error: " + ex.Message, "RebarPos", System.Windows.Forms.MessageBoxButtons.OK, System.Windows.Forms.MessageBoxIcon.Error);
                        }
                    }

                    double offset = 0.0;
                    double offset1 = -0.75, offset2 = 1.75;
                    if (posUp)
                    {
                        AlignPos(pt + offset1 * up, dir, up, normal);
                        offset = offset2;
                    }
                    else
                    {
                        AlignPos(pt + offset2 * up, dir, up, normal);
                        offset = offset1;
                    }

                    PromptKeywordOptions kopts = new PromptKeywordOptions("\nDiğer tarafa yerleştirilsin mi? [Evet/Hayır] <Hayir>: ", "Yes No");
                    kopts.AllowNone = true;
                    PromptResult kres = ed.GetKeywords(kopts);
                    if (kres.Status == PromptStatus.None || kres.StringResult == "Yes")
                    {
                        AlignPos(pt + offset * up, dir, up, normal);
                        ed.UpdateScreen();
                    }
                }
            }
        }
开发者ID:oozcitak,项目名称:RebarPos,代码行数:65,代码来源:EditPosForm.cs


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