本文整理汇总了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;
}
示例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;
}
示例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 ) );
}
示例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
//.........这里部分代码省略.........
示例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;
}
示例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);
}
示例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
};
}
示例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;
}
示例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
}
//.........这里部分代码省略.........
示例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));
}