本文整理汇总了C#中CurveLoop.HasPlane方法的典型用法代码示例。如果您正苦于以下问题:C# CurveLoop.HasPlane方法的具体用法?C# CurveLoop.HasPlane怎么用?C# CurveLoop.HasPlane使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CurveLoop
的用法示例。
在下文中一共展示了CurveLoop.HasPlane方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: GetPlaneFromCurve
public static Plane GetPlaneFromCurve(Curve c, bool planarOnly)
{
//find the plane of the curve and generate a sketch plane
double period = c.IsBound ? 0.0 : (c.IsCyclic ? c.Period : 1.0);
var p0 = c.IsBound ? c.Evaluate(0.0, true) : c.Evaluate(0.0, false);
var p1 = c.IsBound ? c.Evaluate(0.5, true) : c.Evaluate(0.25 * period, false);
var p2 = c.IsBound ? c.Evaluate(1.0, true) : c.Evaluate(0.5 * period, false);
if (IsLineLike(c))
{
XYZ norm = null;
//keep old plane computations
if (System.Math.Abs(p0.Z - p2.Z) < Tolerance)
{
norm = XYZ.BasisZ;
}
else
{
var v1 = p1 - p0;
var v2 = p2 - p0;
var p3 = new XYZ(p2.X, p2.Y, p0.Z);
var v3 = p3 - p0;
norm = v1.CrossProduct(v3);
if (norm.IsZeroLength())
{
norm = v2.CrossProduct(XYZ.BasisY);
}
norm = norm.Normalize();
}
return new Plane(norm, p0);
}
var cLoop = new CurveLoop();
cLoop.Append(c.Clone());
if (cLoop.HasPlane())
{
return cLoop.GetPlane();
}
if (planarOnly)
return null;
// Get best fit plane using tesselation
var points = c.Tessellate().Select(x => x.ToPoint(false));
var bestFitPlane =
Autodesk.DesignScript.Geometry.Plane.ByBestFitThroughPoints(points);
return bestFitPlane.ToPlane(false);
}