本文整理汇总了C#中XYZ.CrossProduct方法的典型用法代码示例。如果您正苦于以下问题:C# XYZ.CrossProduct方法的具体用法?C# XYZ.CrossProduct怎么用?C# XYZ.CrossProduct使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类XYZ
的用法示例。
在下文中一共展示了XYZ.CrossProduct方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: CreateLinearDimension
public Dimension CreateLinearDimension(
Document doc)
{
Application app = doc.Application;
// first create two lines
XYZ pt1 = new XYZ( 5, 5, 0 );
XYZ pt2 = new XYZ( 5, 10, 0 );
Line line = Line.CreateBound( pt1, pt2 );
//Plane plane = app.Create.NewPlane( pt1.CrossProduct( pt2 ), pt2 ); // 2016
Plane plane = Plane.CreateByNormalAndOrigin( pt1.CrossProduct( pt2 ), pt2 ); // 2017
//SketchPlane skplane = doc.FamilyCreate.NewSketchPlane( plane ); // 2013
SketchPlane skplane = SketchPlane.Create( doc, plane ); // 2014
ModelCurve modelcurve1 = doc.FamilyCreate
.NewModelCurve( line, skplane );
pt1 = new XYZ( 10, 5, 0 );
pt2 = new XYZ( 10, 10, 0 );
line = Line.CreateBound( pt1, pt2 );
//plane = app.Create.NewPlane( pt1.CrossProduct( pt2 ), pt2 ); // 2016
plane = Plane.CreateByNormalAndOrigin( pt1.CrossProduct( pt2 ), pt2 ); // 2017
//skplane = doc.FamilyCreate.NewSketchPlane( plane ); // 2013
skplane = SketchPlane.Create( doc, plane ); // 2014
ModelCurve modelcurve2 = doc.FamilyCreate
.NewModelCurve( line, skplane );
// now create a linear dimension between them
ReferenceArray ra = new ReferenceArray();
ra.Append( modelcurve1.GeometryCurve.Reference );
ra.Append( modelcurve2.GeometryCurve.Reference );
pt1 = new XYZ( 5, 10, 0 );
pt2 = new XYZ( 10, 10, 0 );
line = Line.CreateBound( pt1, pt2 );
Dimension dim = doc.FamilyCreate
.NewLinearDimension( doc.ActiveView, line, ra );
// create a label for the dimension called "width"
FamilyParameter param = doc.FamilyManager
.AddParameter( "width",
BuiltInParameterGroup.PG_CONSTRAINTS,
ParameterType.Length, false );
//dim.Label = param; // 2013
dim.FamilyLabel = param; // 2014
return dim;
}
示例2: ExportWallBase
//.........这里部分代码省略.........
if (centerCurve != null)
{
Curve baseCurve = GetWallAxisAtBaseHeight(wallElement);
curve = GetWallTrimmedCurve(wallElement, baseCurve);
IFCRange curveBounds;
XYZ oldOrig;
GeometryUtil.GetAxisAndRangeFromCurve(curve, out curveBounds, out localXDir, out oldOrig);
localOrig = oldOrig;
if (baseCurve != null)
{
if (!validRange || (MathUtil.IsAlmostEqual(range.Start, zSpan.Start)))
{
XYZ newOrig = baseCurve.Evaluate(curveBounds.Start, false);
if (!validRange && (zSpan.Start < newOrig[2] - eps))
localOrig = new XYZ(localOrig.X, localOrig.Y, zSpan.Start);
else
localOrig = new XYZ(localOrig.X, localOrig.Y, newOrig[2]);
}
else
{
localOrig = new XYZ(localOrig.X, localOrig.Y, range.Start);
}
}
double dist = localOrig[2] - oldOrig[2];
if (!MathUtil.IsAlmostZero(dist))
{
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);
}
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 ((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);
ExporterIFCUtils.CollectGeometryInfo(exporterIFC, info, curve, XYZ.Zero, true);
IList<IFCAnyHandle> axisItems = info.GetCurves();
示例3: MakeLine
public ModelCurve MakeLine(Document doc, XYZ ptA, XYZ ptB)
{
Autodesk.Revit.ApplicationServices.Application app = doc.Application;
// Create plane by the points
Line line = app.Create.NewLine(ptA, ptB, true);
XYZ norm = ptA.CrossProduct(ptB);
double length = norm.GetLength();
if (length == 0) norm = XYZ.BasisZ;
Plane plane = app.Create.NewPlane(norm, ptB);
SketchPlane skplane = doc.FamilyCreate.NewSketchPlane(plane);
// Create line here
ModelCurve modelcurve = doc.FamilyCreate.NewModelCurve(line, skplane);
return modelcurve;
}
示例4: ExportWallBase
//.........这里部分代码省略.........
bool exportedAsWallWithAxis = false;
bool exportedBodyDirectly = false;
Curve centerCurve = GetWallAxis(wallElement);
XYZ localXDir = new XYZ(1, 0, 0);
XYZ localYDir = new XYZ(0, 1, 0);
XYZ localZDir = new XYZ(0, 0, 1);
XYZ localOrig = new XYZ(0, 0, 0);
double eps = MathUtil.Eps();
if (centerCurve != null)
{
Curve baseCurve = GetWallAxisAtBaseHeight(wallElement);
trimmedCurve = GetWallTrimmedCurve(wallElement, baseCurve);
IFCRange curveBounds;
XYZ oldOrig;
GeometryUtil.GetAxisAndRangeFromCurve(trimmedCurve, out curveBounds, out localXDir, out oldOrig);
// Move the curve to the bottom of the geometry or the bottom of the range, which is higher.
if (baseCurve != null)
localOrig = new XYZ(oldOrig.X, oldOrig.Y, validRange ? Math.Max(range.Start, zSpan.Start) : zSpan.Start);
else
localOrig = oldOrig;
double dist = localOrig[2] - oldOrig[2];
if (!MathUtil.IsAlmostZero(dist))
{
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);
示例5: CreateModelText
private static Autodesk.Revit.DB.ModelText CreateModelText(XYZ normal, XYZ position, XYZ up, string text, ModelTextType mtt,
double depth)
{
Autodesk.Revit.DB.ModelText mt = null;
var xAxis = normal.CrossProduct(up).Normalize();
var yAxis = normal.CrossProduct(xAxis).Normalize();
var plane = new Autodesk.Revit.DB.Plane(xAxis, yAxis, position);
var sp = Autodesk.Revit.DB.SketchPlane.Create(dynRevitSettings.Doc.Document, plane);
mt = dynRevitSettings.Doc.Document.FamilyCreate.NewModelText(text, mtt, sp, position, HorizontalAlign.Left, depth);
return mt;
}
示例6: CreateOpeningForDoorWindow
//.........这里部分代码省略.........
bool cutDirPointingIn = (cutDir.DotProduct(approxMoveDir) < 0.0);
bool centerInsideArc = (centerDist < radius);
if (centerInsideArc == cutDirPointingIn)
{
XYZ moveVec = cutDir * -unScaledDepth;
origCtr += moveVec;
tmpCutLoop = GeometryUtil.MoveCurveLoop(tmpCutLoop, moveVec);
}
// not for windows that are too big ... forget about it. Very rare case.
double depthFactor = openingWidth / (2.0 * radius);
double eps = MathUtil.Eps();
if (depthFactor < 1.0 - eps)
{
double depthFactorSq = depthFactor * depthFactor * 4;
double extraDepth = radius * (1.0 - Math.Sqrt(1.0 - depthFactorSq));
if (extraDepth > eps)
{
XYZ moveVec = cutDir * -extraDepth;
tmpCutLoop = GeometryUtil.MoveCurveLoop(tmpCutLoop, moveVec);
unScaledDepth += extraDepth;
}
}
// extra fudge on the other side of the window opening.
depthFactor = origUnscaledDepth / (2.0 * radius);
if (depthFactor < 1.0 - eps)
{
double extraDepth = radius * (1.0 - Math.Sqrt(1.0 - depthFactor));
if (extraDepth > eps)
unScaledDepth += extraDepth;
}
}
XYZ cutXDir = XYZ.BasisZ;
XYZ cutOrig = XYZ.Zero;
XYZ cutYDir = cutDir.CrossProduct(cutXDir);
plane = new Plane(cutXDir, cutYDir, cutOrig);
// now move to origin in this coordinate system.
// todo: update openingtrf if we are to use it again!
BoundingBoxXYZ tmpBBox = ComputeApproximateCurveLoopBBoxForOpening(tmpCutLoop, plane);
if (tmpBBox != null)
{
relOrig = tmpBBox.Min;
XYZ moveVec = relOrig * -1.0;
tmpCutLoop = GeometryUtil.MoveCurveLoop(tmpCutLoop, moveVec);
}
IList<CurveLoop> oCutLoopList = new List<CurveLoop>();
oCutLoopList.Add(tmpCutLoop);
double depth = UnitUtil.ScaleLength(unScaledDepth);
Element doorWindowElement = doc.GetElement(insertId);
IFCAnyHandle openingRepHnd = RepresentationUtil.CreateExtrudedProductDefShape(exporterIFC, doorWindowElement, catId,
oCutLoopList, plane, cutDir, depth);
if (IFCAnyHandleUtil.IsNullOrHasNoValue(openingRepHnd))
return null;
// care only about first loop.
IFCFile file = exporterIFC.GetFile();
XYZ scaledOrig = UnitUtil.ScaleLength(relOrig);
IFCAnyHandle openingPlacement = ExporterUtil.CreateLocalPlacement(file, hostObjPlacementHnd, scaledOrig, relZ, relX);
string openingObjectType = isRecess ? "Recess": "Opening";
string origOpeningName = NamingUtil.GetIFCNamePlusIndex(doorWindowElement, 1);
string openingName = NamingUtil.GetNameOverride(doorWindowElement, origOpeningName);
IFCAnyHandle openingHnd = IFCInstanceExporter.CreateOpeningElement(file, openingGUID, ownerHistory, openingName, null,
openingObjectType, openingPlacement, openingRepHnd, null);
string openingVoidsGUID = GUIDUtil.CreateSubElementGUID(doorWindowElement, (int)IFCDoorSubElements.DoorOpeningRelVoid);
IFCInstanceExporter.CreateRelVoidsElement(file, openingVoidsGUID, ownerHistory, null, null, hostObjHnd, openingHnd);
if (ExporterCacheManager.ExportOptionsCache.ExportBaseQuantities)
{
using (IFCExtrusionCreationData extraParams = new IFCExtrusionCreationData())
{
double height = 0.0, width = 0.0;
if (ExtrusionExporter.ComputeHeightWidthOfCurveLoop(tmpCutLoop, plane, out height, out width))
{
extraParams.ScaledHeight = UnitUtil.ScaleLength(height);
extraParams.ScaledWidth = UnitUtil.ScaleLength(width);
}
IList<CurveLoop> curveLoops = new List<CurveLoop>();
curveLoops.Add(tmpCutLoop);
double area = ExporterIFCUtils.ComputeAreaOfCurveLoops(curveLoops);
if (area > 0.0)
extraParams.ScaledArea = UnitUtil.ScaleArea(area);
extraParams.ScaledLength = depth;
PropertyUtil.CreateOpeningQuantities(exporterIFC, openingHnd, extraParams);
}
}
return DoorWindowOpeningInfo.Create(openingHnd, openingHeight, openingWidth);
}
示例7: GetValidXVectorFromLoop
private XYZ GetValidXVectorFromLoop(CurveLoop curveLoop, XYZ zVec, XYZ origin)
{
foreach (Curve curve in curveLoop)
{
IList<XYZ> pointsToCheck = new List<XYZ>();
// If unbound, must be cyclic.
if (!curve.IsBound)
{
pointsToCheck.Add(curve.Evaluate(0, false));
pointsToCheck.Add(curve.Evaluate(Math.PI / 2.0, false));
pointsToCheck.Add(curve.Evaluate(Math.PI, false));
}
else
{
pointsToCheck.Add(curve.Evaluate(0, true));
pointsToCheck.Add(curve.Evaluate(1.0, true));
if (curve.IsCyclic)
pointsToCheck.Add(curve.Evaluate(0.5, true));
}
foreach (XYZ pointToCheck in pointsToCheck)
{
XYZ possibleVec = (pointToCheck - origin);
XYZ yVec = zVec.CrossProduct(possibleVec).Normalize();
if (yVec.IsZeroLength())
continue;
return yVec.CrossProduct(zVec);
}
}
return null;
}
示例8: ExportWallBase
//.........这里部分代码省略.........
if (centerCurve != null)
{
Curve baseCurve = GetWallAxisAtBaseHeight(wallElement);
curve = GetWallTrimmedCurve(wallElement, baseCurve);
IFCRange curveBounds;
XYZ oldOrig;
GeometryUtil.GetAxisAndRangeFromCurve(curve, out curveBounds, out localXDir, out oldOrig);
localOrig = oldOrig;
if (baseCurve != null)
{
if (!validRange || (MathUtil.IsAlmostEqual(range.Start, zSpan.Start)))
{
XYZ newOrig = baseCurve.Evaluate(curveBounds.Start, false);
if (!validRange && (zSpan.Start < newOrig[2] - eps))
localOrig = new XYZ(localOrig.X, localOrig.Y, zSpan.Start);
else
localOrig = new XYZ(localOrig.X, localOrig.Y, newOrig[2]);
}
else
{
localOrig = new XYZ(localOrig.X, localOrig.Y, range.Start);
}
}
double dist = localOrig[2] - oldOrig[2];
if (!MathUtil.IsAlmostZero(dist))
{
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);
示例9: GetNormal
/// <summary>
/// Return the normal of a plane
/// spanned by the two given vectors.
/// </summary>
static XYZ GetNormal( XYZ v1, XYZ v2 )
{
return v1
.CrossProduct( v2 )
.Normalize();
}
示例10: Evaluate
public override Value Evaluate(FSharpList<Value> args)
{
View3D view = null;
XYZ eye = (XYZ)((Value.Container)args[0]).Item;
XYZ userUp = (XYZ)((Value.Container)args[1]).Item;
XYZ direction = (XYZ)((Value.Container)args[2]).Item;
XYZ side = new XYZ();
if (direction.IsAlmostEqualTo(userUp) || direction.IsAlmostEqualTo(userUp.Negate()))
side = XYZ.BasisZ.CrossProduct(direction);
else
side = userUp.CrossProduct(direction);
XYZ up = side.CrossProduct(direction);
if (this.Elements.Any())
{
Element e;
if (dynUtils.TryGetElement(this.Elements[0], typeof(View3D), out e))
{
view = e as View3D;
if (!view.ViewDirection.IsAlmostEqualTo(direction))
{
ViewOrientation3D orient = new ViewOrientation3D(eye, up, direction);
view.SetOrientation(orient);
view.SaveOrientationAndLock();
view.SetOrientation(orient);
}
}
else
{
//create a new view
view = Create3DView(eye, up, direction);
Elements[0] = view.Id;
}
}
else
{
view = Create3DView(eye, up, direction);
Elements.Add(view.Id);
}
return Value.NewContainer(view);
}
示例11: GetTransformToZ
Transform GetTransformToZ( XYZ v )
{
Transform t;
double a = XYZ.BasisZ.AngleTo( v );
if( Util.IsZero( a ) )
{
t = Transform.Identity;
}
else
{
XYZ axis = Util.IsEqual( a, Math.PI )
? XYZ.BasisX
: v.CrossProduct( XYZ.BasisZ );
//t = Transform.get_Rotation( XYZ.Zero, axis, a ); // 2013
t = Transform.CreateRotation( axis, a ); // 2014
}
return t;
}
示例12: IsParallel
public static bool IsParallel( XYZ p, XYZ q )
{
return p.CrossProduct( q ).IsZeroLength();
}
示例13: MakeLine
public static ModelCurve MakeLine( UIApplication app, XYZ ptA, XYZ ptB, Document doc )
{
// Create plane by the points
Line line = app.Application.Create.NewLine( ptA, ptB, true );
XYZ norm = ptA.CrossProduct( ptB );
if( norm.GetLength() == 0 ) norm = XYZ.BasisZ;
Plane plane = app.Application.Create.NewPlane( norm, ptB );
SketchPlane skplane = doc.FamilyCreate.NewSketchPlane( plane );
// Create line here
ModelCurve modelcurve = doc.FamilyCreate.NewModelCurve( line, skplane );
return modelcurve;
}
示例14: MakeLine
private ModelCurve MakeLine(Document familyDoc, XYZ ptA, XYZ ptB)
{
try
{
Application app = familyDoc.Application;
Line line = app.Create.NewLine(ptA, ptB, true);
XYZ norm = ptA.CrossProduct(ptB);
if (norm.IsZeroLength()) norm = XYZ.BasisZ;
Plane plane = app.Create.NewPlane(norm, ptB);
SketchPlane skplane = familyDoc.FamilyCreate.NewSketchPlane(plane);
return familyDoc.FamilyCreate.NewModelCurve(line, skplane);
}
catch (Exception ex)
{
TaskDialog.Show("Line Error", ex.Message);
return null;
}
}
示例15: ExportWallBase
//.........这里部分代码省略.........
if (centerCurve != null)
{
Curve baseCurve = GetWallAxisAtBaseHeight(wallElement);
curve = GetWallTrimmedCurve(wallElement, baseCurve);
UV curveBounds;
XYZ oldOrig;
GeometryUtil.GetAxisAndRangeFromCurve(curve, out curveBounds, out localXDir, out oldOrig);
localOrig = oldOrig;
if (baseCurve != null)
{
if (!validRange || (MathUtil.IsAlmostEqual(range[0], zSpan[0])))
{
XYZ newOrig = baseCurve.Evaluate(curveBounds.U, false);
if (validRange && (zSpan[0] < newOrig[2] - eps))
localOrig = new XYZ(localOrig.X, localOrig.Y, zSpan[0]);
else
localOrig = new XYZ(localOrig.X, localOrig.Y, newOrig[2]);
}
else
{
localOrig = new XYZ(localOrig.X, localOrig.Y, range[0]);
}
}
double dist = localOrig[2] - oldOrig[2];
if (!MathUtil.IsAlmostZero(dist))
{
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);
}
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 = new XYZ(0, 0, 1);
// two representations: axis, body.
{
if ((centerCurve != null) && (GeometryUtil.CurveIsLineOrArc(centerCurve)))
{
exportingAxis = true;
IFCLabel identifierOpt = IFCLabel.Create("Axis"); // IFC2x2 convention
IFCLabel representationTypeOpt = IFCLabel.Create("Curve2D"); // IFC2x2 convention
IFCGeometryInfo info = IFCGeometryInfo.CreateCurveGeometryInfo(exporterIFC, plane, projDir, false);
ExporterIFCUtils.CollectGeometryInfo(exporterIFC, info, curve, XYZ.Zero, true);
IList<IFCAnyHandle> axisItems = info.GetCurves();