本文整理汇总了C#中XYZ.Normalize方法的典型用法代码示例。如果您正苦于以下问题:C# XYZ.Normalize方法的具体用法?C# XYZ.Normalize怎么用?C# XYZ.Normalize使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类XYZ
的用法示例。
在下文中一共展示了XYZ.Normalize方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: ExportWallBase
//.........这里部分代码省略.........
XYZ moveVec = new XYZ(0, 0, dist);
trimmedCurve = GeometryUtil.MoveCurve(trimmedCurve, moveVec);
}
localYDir = localZDir.CrossProduct(localXDir);
// ensure that X and Z axes are orthogonal.
double xzDot = localZDir.DotProduct(localXDir);
if (!MathUtil.IsAlmostZero(xzDot))
localXDir = localYDir.CrossProduct(localZDir);
}
else
{
BoundingBoxXYZ boundingBox = element.get_BoundingBox(null);
if (boundingBox != null)
{
XYZ bBoxMin = boundingBox.Min;
XYZ bBoxMax = boundingBox.Max;
if (validRange)
localOrig = new XYZ(bBoxMin.X, bBoxMin.Y, range.Start);
else
localOrig = boundingBox.Min;
XYZ localXDirMax = null;
Transform bTrf = boundingBox.Transform;
XYZ localXDirMax1 = new XYZ(bBoxMax.X, localOrig.Y, localOrig.Z);
localXDirMax1 = bTrf.OfPoint(localXDirMax1);
XYZ localXDirMax2 = new XYZ(localOrig.X, bBoxMax.Y, localOrig.Z);
localXDirMax2 = bTrf.OfPoint(localXDirMax2);
if (localXDirMax1.DistanceTo(localOrig) >= localXDirMax2.DistanceTo(localOrig))
localXDirMax = localXDirMax1;
else
localXDirMax = localXDirMax2;
localXDir = localXDirMax.Subtract(localOrig);
localXDir = localXDir.Normalize();
localYDir = localZDir.CrossProduct(localXDir);
// ensure that X and Z axes are orthogonal.
double xzDot = localZDir.DotProduct(localXDir);
if (!MathUtil.IsAlmostZero(xzDot))
localXDir = localYDir.CrossProduct(localZDir);
}
}
IFCAnyHandle ownerHistory = exporterIFC.GetOwnerHistoryHandle();
Transform orientationTrf = Transform.Identity;
orientationTrf.BasisX = localXDir;
orientationTrf.BasisY = localYDir;
orientationTrf.BasisZ = localZDir;
orientationTrf.Origin = localOrig;
double scaledFootprintArea = 0;
double scaledLength = 0;
using (PlacementSetter setter = PlacementSetter.Create(exporterIFC, element, null, orientationTrf, overrideLevelId))
{
IFCAnyHandle localPlacement = setter.LocalPlacement;
// The local coordinate system of the wall as defined by IFC for IfcWallStandardCase.
Plane wallLCS = new Plane(localXDir, localYDir, localOrig); // project curve to XY plane.
XYZ projDir = XYZ.BasisZ;
// two representations: axis, body.
{
if (!exportParts && (centerCurve != null) && (GeometryUtil.CurveIsLineOrArc(centerCurve)))
{
示例2: 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);
}
示例3: TorusByAxisOriginRadiusCrossSectionRadius
public static Solid TorusByAxisOriginRadiusCrossSectionRadius(XYZ zAxis, XYZ center, double radius, double sectionRadius)
{
// get axis that is perp to axis by first generating random vector
var zaxis = zAxis.Normalize();
var randXyz = new XYZ(1, 0, 0);
if (zaxis.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);
// form origin of the arc
var origin = center + xaxis * radius;
// create circle (this is ridiculous but curve loop doesn't work with a circle
var arc1 = dynRevitSettings.Doc.Application.Application.Create.NewEllipse(origin, sectionRadius, sectionRadius, xaxis, zaxis, 0, Circle.RevitPI);
var arc2 = dynRevitSettings.Doc.Application.Application.Create.NewEllipse(origin, sectionRadius, sectionRadius, xaxis, zaxis, 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.CreateRevolvedGeometry(
new Autodesk.Revit.DB.Frame(center, xaxis, yaxis, zaxis), new List<Autodesk.Revit.DB.CurveLoop>() { circleLoop }, 0,
2 * Circle.RevitPI);
}
示例4: ExportWallBase
//.........这里部分代码省略.........
XYZ moveVec = new XYZ(0, 0, dist);
curve = GeometryUtil.MoveCurve(curve, moveVec);
}
localYDir = localZDir.CrossProduct(localXDir);
// ensure that X and Z axes are orthogonal.
double xzDot = localZDir.DotProduct(localXDir);
if (!MathUtil.IsAlmostZero(xzDot))
localXDir = localYDir.CrossProduct(localZDir);
}
else
{
BoundingBoxXYZ boundingBox = element.get_BoundingBox(null);
if (boundingBox != null)
{
XYZ bBoxMin = boundingBox.Min;
XYZ bBoxMax = boundingBox.Max;
if (validRange)
localOrig = new XYZ(bBoxMin.X, bBoxMin.Y, range.Start);
else
localOrig = boundingBox.Min;
XYZ localXDirMax = null;
Transform bTrf = boundingBox.Transform;
XYZ localXDirMax1 = new XYZ(bBoxMax.X, localOrig.Y, localOrig.Z);
localXDirMax1 = bTrf.OfPoint(localXDirMax1);
XYZ localXDirMax2 = new XYZ(localOrig.X, bBoxMax.Y, localOrig.Z);
localXDirMax2 = bTrf.OfPoint(localXDirMax2);
if (localXDirMax1.DistanceTo(localOrig) >= localXDirMax2.DistanceTo(localOrig))
localXDirMax = localXDirMax1;
else
localXDirMax = localXDirMax2;
localXDir = localXDirMax.Subtract(localOrig);
localXDir = localXDir.Normalize();
localYDir = localZDir.CrossProduct(localXDir);
// ensure that X and Z axes are orthogonal.
double xzDot = localZDir.DotProduct(localXDir);
if (!MathUtil.IsAlmostZero(xzDot))
localXDir = localYDir.CrossProduct(localZDir);
}
}
Transform orientationTrf = Transform.Identity;
orientationTrf.BasisX = localXDir;
orientationTrf.BasisY = localYDir;
orientationTrf.BasisZ = localZDir;
orientationTrf.Origin = localOrig;
using (IFCPlacementSetter setter = IFCPlacementSetter.Create(exporterIFC, element, null, orientationTrf, overrideLevelId))
{
IFCAnyHandle localPlacement = setter.GetPlacement();
Plane plane = new Plane(localXDir, localYDir, localOrig); // project curve to XY plane.
XYZ projDir = XYZ.BasisZ;
// two representations: axis, body.
{
if (!exportParts && (centerCurve != null) && (GeometryUtil.CurveIsLineOrArc(centerCurve)))
{
exportingAxis = true;
string identifierOpt = "Axis"; // IFC2x2 convention
string representationTypeOpt = "Curve2D"; // IFC2x2 convention
IFCGeometryInfo info = IFCGeometryInfo.CreateCurveGeometryInfo(exporterIFC, plane, projDir, false);