本文整理汇总了C#中XYZ.Select方法的典型用法代码示例。如果您正苦于以下问题:C# XYZ.Select方法的具体用法?C# XYZ.Select怎么用?C# XYZ.Select使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类XYZ
的用法示例。
在下文中一共展示了XYZ.Select方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: GetNurbsPoints
/// <summary>
/// Obtain the Nurbs control points from a Hermite Spline
/// </summary>
/// <param name="curve"></param>
/// <param name="nurbsKnots"></param>
/// <returns></returns>
internal static Autodesk.DesignScript.Geometry.Point[] GetNurbsPoints(Autodesk.Revit.DB.HermiteSpline curve, double[] nurbsKnots)
{
int numKnots = nurbsKnots.Length;
int numPoints = numKnots - 4;
var pPoints = new XYZ[numPoints];
var factorial = new double[] { 1, 1, 2, 6 };
var power = new double[] { 1, -1, 1, -1 };
for (int ii = 0; ii < numPoints; ii++)
{
double t = 0.5 * (nurbsKnots[ii] + nurbsKnots[ii + 1]);
var del = new double[4];
for (int jj = 1; jj <= 3; jj++)
{
del[jj] = nurbsKnots[ii + jj] - t;
}
var s = Symmetric(del);
var psi = new double[4];
for (int k = 0; k <= 3; k++)
{
double top = power[k] * factorial[k] * s[3 - k];
psi[k] = top / factorial[3];
}
pPoints[ii] = XYZ.Zero;
var derivTransform = curve.ComputeDerivatives(t, false);
// this is the expected rep
var derivs = new[]
{
derivTransform.Origin,
derivTransform.BasisX, // 1st deriv
derivTransform.BasisY, // 2nd deriv
null
};
// calculate 3-th derivative
int low = 0;
int high = numPoints + 1;
int mid = (low + high) / 2;
while (t < nurbsKnots[mid] || t >= nurbsKnots[mid + 1])
{
if (t < nurbsKnots[mid])
high = mid;
else
low = mid;
mid = (low + high) / 2;
}
// find the span containing t
double p1 = nurbsKnots[mid];
double p2 = nurbsKnots[mid + 1];
// evaluate the point and tangent at the two end points of the span
var P1R1 = curve.ComputeDerivatives(p1, false);
var P1 = P1R1.Origin;
var R1 = P1R1.BasisX;
var P4R4 = curve.ComputeDerivatives(p2, false);
var P4 = P4R4.Origin;
var R4 = P4R4.BasisX;
// the chord vector from p1 to p2
var P14 = P1 - P4;
var R14 = R1 + R4;
// the span of the region is tk
double tk = p2 - p1;
if (tk < 1e-13)
tk = 1.0;
// an approximation of the third derivative
derivs[3] = P14 * (12.0 / (tk * tk * tk)) + R14 * (6.0 / (tk * tk));
for (int r = 0; r <= 3; r++)
{
int codegree = 3 - r;
double mul = power[codegree] * psi[codegree];
pPoints[ii] = pPoints[ii] + mul * derivs[r];
}
}
return pPoints.Select(x => x.ToPoint(false)).ToArray();
}