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


C# XYZ.IsAlmostEqualTo方法代码示例

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


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

示例1: FindParallelGrids

 /// <summary>
 /// Find the list of parallel linear grids via the given direction.
 /// </summary>
 /// <param name="linearGrids">The set of linear grids.</param>
 /// <param name="baseDirection">The given direction.</param>
 /// <returns>The list of parallel grids, containing the anti direction grids.</returns>
 private static List<Grid> FindParallelGrids(IDictionary<XYZ, List<Grid>> linearGrids, XYZ baseDirection)
 {
     List<XYZ> directionList = linearGrids.Keys.ToList();
     List<Grid> parallelGrids = linearGrids[baseDirection];
     foreach (XYZ direction in directionList)
     {
         if (baseDirection.IsAlmostEqualTo(direction))
             continue;
         double dotProduct = direction.DotProduct(baseDirection);
         if (MathUtil.IsAlmostEqual(dotProduct, -1.0))
         {
             parallelGrids = parallelGrids.Union<Grid>(linearGrids[direction]).ToList();
             return parallelGrids;
         }
     }
     return parallelGrids;
 }
开发者ID:whztt07,项目名称:RevitIFC,代码行数:23,代码来源:GridExporter.cs

示例2: makeParticleFromXYZ

        public Particle makeParticleFromXYZ(ElementId eid, double mass, XYZ position, bool fix)
        {
            bool found = false;
            for (int i = 0; i < particles.Count(); ++i)
            {
                if (eid != null && (particles[i].getElementID() != null)&& position!=null)
                {
                    if (position.IsAlmostEqualTo(particles[i].getPosition()))
                    {
                        found = true;
                        particles[i].setPosition(position);
                        return particles[i];

                    }
                }
            }
            if (found == false)//if we did not find one make a new one
            {
                Particle part = new Particle(partID++, eid, mass, position, fix);
                particles.Add(part);
                return part;
            }

            return null;
        }
开发者ID:Tadwork,项目名称:Dynamo,代码行数:25,代码来源:dynParticleSystem.cs

示例3: CreateModelLine

 public void CreateModelLine( XYZ p, XYZ q )
 {
     if( p.IsAlmostEqualTo( q ) )
       {
     throw new ArgumentException(
       "Expected two different points." );
       }
       Line line = Line.CreateBound( p, q );
       if( null == line )
       {
     throw new Exception(
       "Geometry line creation failed." );
       }
       _credoc.NewModelCurve( line,
     NewSketchPlanePassLine( line ) );
 }
开发者ID:JesseMom,项目名称:the_building_coder_samples,代码行数:16,代码来源:Creator.cs

示例4: Evaluate

        public override Value Evaluate(FSharpList<Value> args)
        {
            var symbol = (FamilySymbol)((Value.Container)args[0]).Item;
            var curves = ((Value.List) args[1]).Item;

            IEnumerable<Tuple<Curve, XYZ>> data;
            if (args[2].IsList)
            {
                var targets = ((Value.List)args[2]).Item;

                if (curves.Count() != targets.Count())
                    throw new Exception("The number of curves and the number of up vectors must be the same.");

                //if we get a list of up vectors, then pair each
                //curve with a corresponding up vector
                data = curves.Zip(targets,
                    (first, second) =>
                        new Tuple<Curve, XYZ>((Curve) ((Value.Container) first).Item,
                            (XYZ) ((Value.Container) second).Item));
            }
            else
            {
                //if we get a single up vector, then pair each
                //curve with that up vector
                data = curves.Select(x=>new Tuple<Curve, XYZ>((Curve)((Value.Container)x).Item,
                            (XYZ)((Value.Container)args[2]).Item));
            }

            var instData = new List<FamilyInstanceCreationData>();

            int count = 0;

            foreach (var pair in data)
            {
                var curve = pair.Item1;
                var target = pair.Item2;

                //calculate the desired rotation
                //we do this by finding the angle between the z axis
                //and vector between the start of the beam and the target point
                //both projected onto the start plane of the beam.

                XYZ zAxis = new XYZ(0, 0, 1);
                XYZ yAxis = new XYZ(0, 1, 0);

                //flatten the beam line onto the XZ plane
                //using the start's z coordinate
                XYZ start = curve.get_EndPoint(0);
                XYZ end = curve.get_EndPoint(1);
                XYZ newEnd = new XYZ(end.X, end.Y, start.Z); //drop end point to plane

                ////use the x axis of the curve's transform
                ////as the normal of the start plane
                //XYZ planeNormal = (curve.get_EndPoint(0) - curve.get_EndPoint(1)).Normalize();

                //catch the case where the end is directly above
                //the start, creating a normal with zero length
                //in that case, use the Z axis
                XYZ planeNormal = newEnd.IsAlmostEqualTo(start) ? zAxis : (newEnd - start).Normalize();

                XYZ target_project = target - target.DotProduct(planeNormal)*planeNormal;
                XYZ z_project = zAxis - zAxis.DotProduct(planeNormal)*planeNormal;

                //double gamma = target_project.AngleTo(z_project);
                double gamma = target.AngleOnPlaneTo(zAxis.IsAlmostEqualTo(planeNormal) ? yAxis : zAxis, planeNormal);

                FamilyInstance instance = null;
                if (this.Elements.Count > count)
                {
                    if (dynUtils.TryGetElement(this.Elements[count], out instance))
                    {
                        if (instance.Symbol != symbol)
                            instance.Symbol = symbol;

                        //update the curve
                        var locCurve = instance.Location as LocationCurve;
                        locCurve.Curve = curve;
                    }
                    else
                    {
                        var beamData = new FamilyInstanceCreationData(curve, symbol, dynRevitSettings.DefaultLevel, StructuralType.Beam)
                            {
                                RotateAngle = gamma
                            };
                        instData.Add(beamData);
                    }
                }
                else
                {
                    var beamData = new FamilyInstanceCreationData(curve, symbol, dynRevitSettings.DefaultLevel, StructuralType.Beam)
                        {
                            RotateAngle = gamma
                        };
                    instData.Add(beamData);
                }

                count++;
            }

            //trim the elements collection
//.........这里部分代码省略.........
开发者ID:kscalvin,项目名称:Dynamo,代码行数:101,代码来源:StructuralFraming.cs

示例5: getParticleByXYZ

        public Particle getParticleByXYZ(XYZ xyz)
        {
            for (int i = 0; i < particles.Count(); ++i)
            {
                if (xyz != null && particles.Count > 0 && (particles[i].getElementID() != null))
                {
                    if (xyz.IsAlmostEqualTo(particles[i].getPosition()))
                    {
                        return particles[i];

                    }

                }

            }

            return null;
        }
开发者ID:Tadwork,项目名称:Dynamo,代码行数:18,代码来源:dynParticleSystem.cs

示例6: CylinderByAxisOriginRadiusHeight

        public static Solid CylinderByAxisOriginRadiusHeight(XYZ axis, XYZ origin, double radius, double height)
        {
            // get axis that is perp to axis by first generating random vector
            var zaxis = axis.Normalize();
            var randXyz = new XYZ(1, 0, 0);
            if (axis.IsAlmostEqualTo(randXyz)) randXyz = new XYZ(0, 1, 0);
            var yaxis = zaxis.CrossProduct(randXyz).Normalize();

            // get second axis that is perp to axis
            var xaxis = yaxis.CrossProduct(zaxis);

            // create circle (this is ridiculous, but curve loop doesn't work with a circle - you need two arcs)
            var arc1 = dynRevitSettings.Doc.Application.Application.Create.NewEllipse(origin, radius, radius, xaxis, yaxis, 0, Circle.RevitPI);
            var arc2 = dynRevitSettings.Doc.Application.Application.Create.NewEllipse(origin, radius, radius, xaxis, yaxis, Circle.RevitPI, 2 * Circle.RevitPI);

            // create curve loop from cirle
            var circleLoop = Autodesk.Revit.DB.CurveLoop.Create(new List<Curve>() { arc1, arc2 });

            // extrude the curve and return
            return GeometryCreationUtilities.CreateExtrusionGeometry(new List<Autodesk.Revit.DB.CurveLoop>() { circleLoop }, zaxis, height);
        }
开发者ID:Balamaheshwaran,项目名称:Dynamo,代码行数:21,代码来源:Solid.cs

示例7: GetCreationData

        private static FamilyInstanceCreationData GetCreationData(Autodesk.Revit.DB.Curve curve, Autodesk.Revit.DB.XYZ upVector, Autodesk.Revit.DB.Level level, Autodesk.Revit.DB.Structure.StructuralType structuralType, Autodesk.Revit.DB.FamilySymbol symbol)
        {

            //calculate the desired rotation
            //we do this by finding the angle between the z axis
            //and vector between the start of the beam and the target point
            //both projected onto the start plane of the beam.
            var zAxis = new XYZ(0, 0, 1);
            var yAxis = new XYZ(0, 1, 0);

            //flatten the beam line onto the XZ plane
            //using the start's z coordinate
            var start = curve.GetEndPoint(0);
            var end = curve.GetEndPoint(1);
            var newEnd = new XYZ(end.X, end.Y, start.Z); //drop end point to plane

            //catch the case where the end is directly above
            //the start, creating a normal with zero length
            //in that case, use the Z axis
            XYZ planeNormal = newEnd.IsAlmostEqualTo(start) ? zAxis : (newEnd - start).Normalize();

            double gamma = upVector.AngleOnPlaneTo(zAxis.IsAlmostEqualTo(planeNormal) ? yAxis : zAxis, planeNormal);

            return new FamilyInstanceCreationData(curve, symbol, level, structuralType)
            {
                RotateAngle = gamma
            };

        }
开发者ID:whztt07,项目名称:Dynamo,代码行数:29,代码来源:StucturalFraming.cs

示例8: VectorsAreOrthogonal

        /// <summary>
        /// Checks if two vectors are orthogonal or not.
        /// </summary>
        /// <param name="a">The one vector.</param>
        /// <param name="b">The other vector.</param>
        /// <returns>True if they are orthogonal, false if not.</returns>
        public static bool VectorsAreOrthogonal(XYZ a, XYZ b)
        {
            if (a == null || b == null)
                return false;

            if (a.IsAlmostEqualTo(XYZ.Zero) || b.IsAlmostEqualTo(XYZ.Zero))
                return true;

            double ab = a.DotProduct(b);
            double aa = a.DotProduct(a);
            double bb = b.DotProduct(b);

            return (ab * ab < aa * AngleEps() * bb * AngleEps()) ? true : false;
        }
开发者ID:whztt07,项目名称:RevitCustomIFCexporter,代码行数:20,代码来源:MathUtil.cs

示例9: ExportBodyAsAdvancedBrep

        /// <summary>
        /// Returns a handle for creation of an AdvancedBrep with AdvancedFace and assigns it to the file
        /// </summary>
        /// <param name="exporterIFC">exporter IFC</param>
        /// <param name="element">the element</param>
        /// <param name="options">exporter option</param>
        /// <param name="geomObject">the geometry object</param>
        /// <returns>the handle</returns>
        public static IFCAnyHandle ExportBodyAsAdvancedBrep(ExporterIFC exporterIFC, Element element, BodyExporterOptions options,
            GeometryObject geomObject)
        {
            IFCFile file = exporterIFC.GetFile();
            Document document = element.Document;

            IFCAnyHandle advancedBrep = null;

            try
            {
                if (geomObject is Solid)
                {
                    IList<IFCAnyHandle> edgeLoopList = new List<IFCAnyHandle>();
                    HashSet<IFCAnyHandle> cfsFaces = new HashSet<IFCAnyHandle>();
                    Solid geomSolid = geomObject as Solid;
                    FaceArray faces = geomSolid.Faces;
                    foreach (Face face in faces)
                    {
                        IList<IFCAnyHandle> orientedEdgeList = new List<IFCAnyHandle>();
                        IFCAnyHandle surface = null;

                        // Use SortCurveLoops to collect the outerbound(s) with its list of innerbounds
                        IList<IList<CurveLoop>> curveloopList = ExporterIFCUtils.SortCurveLoops(GetEdgesAsCurveLoops(face));
                        IList<HashSet<IFCAnyHandle>> boundsCollection = new List<HashSet<IFCAnyHandle>>();

                        // loop for each outerloop (and its list of innerloops
                        foreach (IList<CurveLoop> curveloops in curveloopList)
                        {
                            foreach (CurveLoop curveloop in curveloops)
                            {
                                CurveLoopIterator curveloopIter = curveloop.GetCurveLoopIterator();
                                XYZ lastPoint = new XYZ();
                                bool first = true;
                                bool unbounded = false;
                                while (curveloopIter.MoveNext())
                                {
                                    IFCAnyHandle edgeCurve = null;
                                    bool orientation = true;
                                    bool sameSense = true;
                                    Curve currCurve = curveloopIter.Current;
                                    IFCAnyHandle edgeStart = null;
                                    IFCAnyHandle edgeEnd = null;

                                    if (currCurve.IsBound)
                                    {
                                        IFCAnyHandle edgeStartCP = XYZtoIfcCartesianPoint(exporterIFC, currCurve.GetEndPoint(0), true);
                                        edgeStart = IFCInstanceExporter.CreateVertexPoint(file, edgeStartCP);
                                        IFCAnyHandle edgeEndCP = XYZtoIfcCartesianPoint(exporterIFC, currCurve.GetEndPoint(1), true);
                                        edgeEnd = IFCInstanceExporter.CreateVertexPoint(file, edgeEndCP);
                                    }
                                    else
                                    {
                                        unbounded = true;
                                    }

                                    // Detect the sense direction by the continuity of the last point in the previous curve to the first point of the current curve
                                    if (!unbounded)
                                    {
                                        if (first)
                                        {
                                            lastPoint = currCurve.GetEndPoint(1);
                                            sameSense = true;
                                            first = false;
                                        }
                                        else
                                        {
                                            if (lastPoint.IsAlmostEqualTo(currCurve.GetEndPoint(1)))
                                            {
                                                sameSense = false;
                                                lastPoint = currCurve.GetEndPoint(0);
                                            }
                                            else
                                            {
                                                sameSense = true;
                                                lastPoint = currCurve.GetEndPoint(1);
                                            }
                                        }
                                    }

                                    // if the Curve is a line, do the following
                                    edgeCurve = CreateEdgeCurveFromCurve(file, exporterIFC, currCurve, edgeStart, edgeEnd, sameSense);
                                    if (IFCAnyHandleUtil.IsNullOrHasNoValue(edgeCurve))
                                        continue;

                                    IFCAnyHandle orientedEdge = IFCInstanceExporter.CreateOrientedEdge(file, edgeCurve, orientation);
                                    orientedEdgeList.Add(orientedEdge);
                                }

                                IFCAnyHandle edgeLoop = IFCInstanceExporter.CreateEdgeLoop(file, orientedEdgeList);
                                edgeLoopList.Add(edgeLoop);     // The list may contain outer edges and inner edges
                            }
                       
//.........这里部分代码省略.........
开发者ID:whztt07,项目名称:RevitCustomIFCexporter,代码行数:101,代码来源:BodyExporter.cs

示例10: IsLoopValid

 private static bool IsLoopValid(//double minOpeningValue,
     Face f, XYZ faceNormal,
     XYZ loopNormal, double loopArea)
 {
   return loopArea < f.Area &&
       //loopArea < (minOpeningValue) &&
       (loopNormal.IsAlmostEqualTo(faceNormal)
       || loopNormal.Negate().IsAlmostEqualTo(faceNormal));
 }
开发者ID:augustogoncalves,项目名称:PIOTM-WallOpeningArea,代码行数:9,代码来源:WallAreaFunctions.cs


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