src/Elements/Geometry/Polyline.cs
/// <summary>
/// Get a point on the polygon at parameter u.
/// </summary>
/// <param name="u">A value between 0.0 and 1.0.</param>
/// <param name="segmentIndex">The index of the segment containing parameter u.</param>
/// <returns>Returns a Vector3 indicating a point along the Polygon length from its start vertex.</returns>
Get a point on the polygon at parameter u.
Get a point on the polygon at parameter u .
private Vector3 PointAtInternal(double u, out int segmentIndex)
        {
            if (u < 0.0 || u > 1.0)
            {
                throw new Exception($"The value of u ({u}) must be between 0.0 and 1.0.");
            }
            var d = this.Length() * u;
            var totalLength = 0.0;
            for (var i = 0; i < this.Vertices.Count - 1; i++)
            {
                var a = this.Vertices[i];
                var b = this.Vertices[i + 1];
                var currLength = a.DistanceTo(b);
                var currVec = (b - a);
                if (totalLength <= d && totalLength + currLength >= d)
                {
                    segmentIndex = i;
                    return a + currVec * ((d - totalLength) / currLength);
                }
                totalLength += currLength;
            }
            segmentIndex = this.Vertices.Count - 1;
            return this.End;
        }
private Vector3 PointAtInternal ( double u , out int segmentIndex ) { if ( u < 0.0 || u > 1.0 ) { throw new Exception ( $" The value of u ( { u } ) must be between 0.0 and 1.0. " ) ; } var d = this . Length ( ) * u ; var totalLength = 0.0 ; for ( var i = 0 ; i < this . Vertices . Count - 1 ; i ++ ) { var a = this . Vertices [ i ] ; var b = this . Vertices [ i + 1 ] ; var currLength = a . DistanceTo ( b ) ; var currVec = ( b - a ) ; if ( totalLength <= d && totalLength + currLength >= d ) { segmentIndex = i ; return a + currVec * ( ( d - totalLength ) / currLength ) ; } totalLength += currLength ; } segmentIndex = this . Vertices . Count - 1 ; return this . End ; }
Get a point on the polygon at parameter u.
Get a point on the polygon at parameter u .
Returns a Vector3 indicating a point along the Polygon length from its start vertex.
Returns a Vector3 indicating a point along the Polygon length from its start vertex .
u
double
None
int
out
segmentIndex
The index of the segment containing parameter u.
The index of the segment containing parameter u .