本文整理汇总了C#中XYZ.IsZeroLength方法的典型用法代码示例。如果您正苦于以下问题:C# XYZ.IsZeroLength方法的具体用法?C# XYZ.IsZeroLength怎么用?C# XYZ.IsZeroLength使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类XYZ
的用法示例。
在下文中一共展示了XYZ.IsZeroLength方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: OffsetArc
/// <summary>
/// Offsets an arc along the offset direction from the point on the arc.
/// </summary>
/// <param name="arc">The arc.</param>
/// <param name="offsetPntOnArc">The point on the arc.</param>
/// <param name="offset">The offset vector.</param>
/// <returns>The offset Arc.</returns>
private static Arc OffsetArc(Arc arc, XYZ offsetPntOnArc, XYZ offset)
{
if (arc == null || offset == null)
throw new ArgumentNullException();
if (offset.IsZeroLength())
return arc;
XYZ axis = arc.Normal.Normalize();
XYZ offsetAlongAxis = axis.Multiply(offset.DotProduct(axis));
XYZ offsetOrthAxis = offset - offsetAlongAxis;
XYZ offsetPntToCenter = (arc.Center - offsetPntOnArc).Normalize();
double signedOffsetLengthTowardCenter = offsetOrthAxis.DotProduct(offsetPntToCenter);
double newRadius = arc.Radius - signedOffsetLengthTowardCenter; // signedOffsetLengthTowardCenter > 0, minus, < 0, add
Arc offsetArc = Arc.Create(arc.Center, newRadius, arc.GetEndParameter(0), arc.GetEndParameter(1), arc.XDirection, arc.YDirection);
offsetArc = GeometryUtil.MoveCurve(offsetArc, offsetAlongAxis) as Arc;
return offsetArc;
}
示例2: GetClosestPt
/// <summary>
/// given an array of pts, find the closest
/// pt to a given pt
/// </summary>
/// <param name="pt"></param>
/// <param name="pts"></param>
/// <returns></returns>
public static XYZ GetClosestPt(XYZ pt, System.Collections.Generic.IList<XYZ> pts)
{
XYZ closestPt = new XYZ();
Double closestDist = 0.0;
foreach( XYZ ptTemp in pts )
{
/// don't consider the pt itself
if (pt.Equals(ptTemp))
continue;
Double dist = Math.Sqrt(Math.Pow((pt.X - ptTemp.X), 2.0) +
Math.Pow((pt.Y - ptTemp.Y), 2.0) +
Math.Pow((pt.Z - ptTemp.Z), 2.0));
if (closestPt.IsZeroLength()) {
closestDist = dist;
closestPt = ptTemp;
}
else {
if (dist < closestDist) {
closestDist = dist;
closestPt = ptTemp;
}
}
}
return closestPt;
}