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


C# XYZ.AngleTo方法代码示例

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


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

示例1: GetBiggestFaceFacingUser

        /// <summary>
        /// Gets the biggest face which faces the user.  Assumes that the element is a wall, or floor, or other "2-sided" element, and that
        /// one of the two biggest faces will be facing roughly towards the viewer.
        /// </summary>
        /// <param name="element">The element.</param>
        /// <param name="viewDirection">The view direction.</param>
        /// <returns>The face.  Face.Reference will also be populated.</returns>
        private static Face GetBiggestFaceFacingUser(Element element, XYZ viewDirection)
        {
            // Holds the faces sorted by area
            SortedDictionary<double, List<Face>> faceAreas = new SortedDictionary<double, List<Face>>();

            // Get the element geometry
            Options options = new Options();
            options.ComputeReferences = true;
            GeometryElement geomElem = element.get_Geometry(options);

            // Look at the faces in each solid
            foreach (GeometryObject geomObj in geomElem.Objects)
            {
                Solid solid = geomObj as Solid;
                if (solid != null)
                {
                    foreach (Face face in solid.Faces)
                    {
                        double area = face.Area;
                        // Save the face to the collection
                        if (faceAreas.ContainsKey(area))
                        {
                            faceAreas[area].Add(face);
                        }
                        else
                        {
                            List<Face> faces = new List<Face>();
                            faces.Add(face);
                            faceAreas.Add(area, faces);
                        }
                    }
                }
            }

            // Get biggest two faces.  There might be two faces in the last item, or one face in the last item.
            int count = faceAreas.Count;
            KeyValuePair<double, List<Face>> faceCollection1 = faceAreas.ElementAt<KeyValuePair<double, List<Face>>>(count - 1);
            KeyValuePair<double, List<Face>> faceCollection2 = faceAreas.ElementAt<KeyValuePair<double, List<Face>>>(count - 2);

            Face face1 = null;
            Face face2 = null;
            // Two or more equal faces.  Use the first two.
            if (faceCollection1.Value.Count > 1)
            {
                face1 = faceCollection1.Value[0];
                face2 = faceCollection1.Value[1];
            }
            // One largest face.  Use the first face from the next item for comparison.
            else
            {
                face1 = faceCollection1.Value[0];
                face2 = faceCollection2.Value[0];
            }

            // Compute face normal
            BoundingBoxUV box = face1.GetBoundingBox();
            UV faceCenter = (box.Max + box.Min) / 2;
            XYZ faceNormal = face1.ComputeNormal(faceCenter).Normalize();

            // Compute angle to the view direction.  If less than 90 degrees, keep this face.
            double angle = viewDirection.AngleTo(faceNormal);

            Face biggestFace = null;
            if (Math.Abs(angle) < Math.PI / 2)
                biggestFace = face1;
            else
                biggestFace = face2;

            return biggestFace;
        }
开发者ID:AMEE,项目名称:revit,代码行数:77,代码来源:MultithreadedCalculation.cs

示例2: ModifyObjects


//.........这里部分代码省略.........
                                    try
                                    {
                                        // Move family
                                        origin = new XYZ(UnitUtils.ConvertToInternalUnits(obj.Origin.X, lengthDUT), UnitUtils.ConvertToInternalUnits(obj.Origin.Y, lengthDUT), UnitUtils.ConvertToInternalUnits(obj.Origin.Z, lengthDUT));
                                        if (fi != null)
                                        {
                                            LocationPoint lp = fi.Location as LocationPoint;
                                            if (lp != null)
                                            {
                                                XYZ oldLoc = lp.Point;
                                                XYZ translation = origin.Subtract(oldLoc);
                                                ElementTransformUtils.MoveElement(doc, fi.Id, translation);
                                            }
                                        }
                                    }
                                    catch (Exception ex)
                                    {
                                        TaskDialog.Show("Error", ex.Message);
                                    }

                                    // Rotate
                                    if (obj.Orientation != null)
                                    {
                                        if (Math.Round(Math.Abs(obj.Orientation.Z - 0), 10) < double.Epsilon)
                                        {
                                            XYZ orientation = fi.FacingOrientation;
                                            orientation = orientation.Multiply(-1);
                                            XYZ incomingOrientation = new XYZ(obj.Orientation.X, obj.Orientation.Y, obj.Orientation.Z);
                                            XYZ normalVector = new XYZ(0, -1, 0);

                                            double currentAngle = 0;
                                            if (orientation.X < 0 && orientation.Y < 0)
                                            {
                                                currentAngle = (2 * Math.PI) - normalVector.AngleTo(orientation);
                                            }
                                            else if (orientation.Y == 0 && orientation.X < 0)
                                            {
                                                currentAngle = 1.5 * Math.PI;
                                            }
                                            else if (orientation.X < 0)
                                            {
                                                currentAngle = (Math.PI - normalVector.AngleTo(orientation)) + Math.PI;
                                            }
                                            else
                                            {
                                                currentAngle = normalVector.AngleTo(orientation);
                                            }

                                            double incomingAngle = 0;
                                            if (incomingOrientation.X < 0 && incomingOrientation.Y < 0)
                                            {
                                                incomingAngle = (2 * Math.PI) - normalVector.AngleTo(incomingOrientation);
                                            }
                                            else if (incomingOrientation.Y == 0 && incomingOrientation.X < 0)
                                            {
                                                incomingAngle = 1.5 * Math.PI;
                                            }
                                            else if (incomingOrientation.X < 0)
                                            {
                                                incomingAngle = (Math.PI - normalVector.AngleTo(incomingOrientation)) + Math.PI;
                                            }
                                            else
                                            {
                                                incomingAngle = normalVector.AngleTo(incomingOrientation);
                                            }
                                            double angle = incomingAngle - currentAngle;
开发者ID:samuto,项目名称:Lyrebird,代码行数:67,代码来源:LyrebirdService.cs

示例3: XyzParallel

 /// <summary>
 /// Check whether two vectors are parallel
 /// </summary>
 static bool XyzParallel( XYZ a, XYZ b )
 {
     double angle = a.AngleTo( b );
       return _eps > angle
     || DoubleEqual( angle, Math.PI );
 }
开发者ID:JesseMom,项目名称:the_building_coder_samples,代码行数:9,代码来源:CmdWallDimensions.cs

示例4: CreateObjects


//.........这里部分代码省略.........
                                                double topElev = ((Level)doc.GetElement(fi.get_Parameter(BuiltInParameter.FAMILY_TOP_LEVEL_PARAM).AsElementId())).Elevation;
                                                if (lvl.Elevation + (origin.Z - lvl.Elevation) > topElev)
                                                {
                                                    fi.get_Parameter(BuiltInParameter.FAMILY_TOP_LEVEL_OFFSET_PARAM).Set((lvl.Elevation + (origin.Z - lvl.Elevation)) - topElev + 10.0);
                                                }
                                            }
                                            else
                                            {
                                                TaskDialog.Show("error", "Null level");
                                            }
                                        }
                                        else
                                        {
                                            // All Else
                                            fi = doc.Create.NewFamilyInstance(origin, symbol, lvl, Autodesk.Revit.DB.Structure.StructuralType.NonStructural);
                                        }
                                    }
                                    catch (Exception ex)
                                    {
                                        TaskDialog.Show("Error", ex.Message);
                                    }

                                    // Rotate
                                    if (obj.Orientation != null)
                                    {
                                        if (Math.Round(Math.Abs(obj.Orientation.Z - 0), 10) < double.Epsilon)
                                        {
                                            Line axis = Line.CreateBound(origin, origin + XYZ.BasisZ);
                                            XYZ normalVector = new XYZ(0, -1, 0);
                                            XYZ orient = new XYZ(obj.Orientation.X, obj.Orientation.Y, obj.Orientation.Z);
                                            double angle = 0;
                                            if (orient.X < 0 && orient.Y < 0)
                                            {
                                                angle = (2 * Math.PI) - normalVector.AngleTo(orient);
                                            }
                                            else if (orient.X < 0)
                                            {
                                                angle = (Math.PI - normalVector.AngleTo(orient)) + Math.PI;
                                            }
                                            else if (orient.Y == 0)
                                            {
                                                angle = 1.5 * Math.PI;
                                            }
                                            else
                                            {
                                                angle = normalVector.AngleTo(orient);
                                            }
                                            ElementTransformUtils.RotateElement(doc, fi.Id, axis, angle);
                                        }
                                    }

                                    // Assign the parameters
                                    SetParameters(fi, obj.Parameters, doc);

                                    // Assign the GH InstanceGuid
                                    AssignGuid(fi, uniqueId, instanceSchema, runId, nickName);

                                    x++;
                                }
                            }
                            else
                            {
                                foreach (RevitObject obj in revitObjects)
                                {
                                    origin = new XYZ(UnitUtils.ConvertToInternalUnits(obj.Origin.X, lengthDUT), UnitUtils.ConvertToInternalUnits(obj.Origin.Y, lengthDUT), UnitUtils.ConvertToInternalUnits(obj.Origin.Z, lengthDUT));
                                    
开发者ID:samuto,项目名称:Lyrebird,代码行数:66,代码来源:LyrebirdService.cs

示例5: IsSouthFacing

        /// <summary>
        /// Identifies if a particular direction is "south-facing".  This means within a range of -45 degrees to 45 degrees 
        /// to the south vector (the negative Y axis).
        /// </summary>
        /// <param name="direction">The normalized direction to test.</param>
        /// <returns>True if the vector is in the designated range.</returns>
        protected bool IsSouthFacing(XYZ direction)
        {
            double angleToSouth = direction.AngleTo(-XYZ.BasisY);

            return Math.Abs(angleToSouth) < Math.PI / 4;
        }
开发者ID:AMEE,项目名称:revit,代码行数:12,代码来源:FindSouthFacing.cs


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