src/Elements/Geometry/Polyline.cs
/// <summary>
/// Get the Transform at the specified parameter along the Polygon.
/// </summary>
/// <param name="u">The parameter on the Polygon between 0.0 and 1.0.</param>
/// <returns>A Transform with its Z axis aligned trangent to the Polygon.</returns>
Get the Transform at the specified parameter along the Polygon.
Get the Transform at the specified parameter along the Polygon .
public override Transform TransformAt(double u)
        {
            if (u < 0.0 || u > 1.0)
            {
                throw new ArgumentOutOfRangeException($"The provided value for u ({u}) must be between 0.0 and 1.0.");
            }
            var segmentIndex = 0;
            var o = PointAtInternal(u, out segmentIndex);
            var up = Vector3.ZAxis;
            Vector3 x = Vector3.XAxis; 
            Vector3 a = new Vector3();
            var isEqualToVertex = false;
            foreach (var v in this.Vertices)
            {
                if (v.Equals(o))
                {
                    isEqualToVertex = true;
                    a = v;
                }
            }
            if (isEqualToVertex)
            {
                var idx = this.Vertices.IndexOf(a);
                if (idx == 0 || idx == this.Vertices.Count - 1)
                {
                    return CreateOthogonalTransform(idx, a);
                }
                else
                {
                    return CreateMiterTransform(idx, a);
                }
            }
            else
            {
                var d = this.Length() * u;
                var totalLength = 0.0;
                var segments = Segments();
                for (var i = 0; i < segments.Length; i++)
                {
                    var s = segments[i];
                    var currLength = s.Length();
                    if (totalLength <= d && totalLength + currLength >= d)
                    {
                        o = s.PointAt((d - totalLength) / currLength);
                        x = s.Direction().Cross(up);
                        break;
                    }
                    totalLength += currLength;
                }
            }
            return new Transform(o, x, up);
        }
public override Transform TransformAt ( double u ) { if ( u < 0.0 || u > 1.0 ) { throw new ArgumentOutOfRangeException ( $" The provided value for u ( { u } ) must be between 0.0 and 1.0. " ) ; } var segmentIndex = 0 ; var o = PointAtInternal ( u , out segmentIndex ) ; var up = Vector3 . ZAxis ; Vector3 x = Vector3 . XAxis ; Vector3 a = new Vector3 ( ) ; var isEqualToVertex = false ; foreach ( var v in this . Vertices ) { if ( v . Equals ( o ) ) { isEqualToVertex = true ; a = v ; } } if ( isEqualToVertex ) { var idx = this . Vertices . IndexOf ( a ) ; if ( idx == 0 || idx == this . Vertices . Count - 1 ) { return CreateOthogonalTransform ( idx , a ) ; } else { return CreateMiterTransform ( idx , a ) ; } } else { var d = this . Length ( ) * u ; var totalLength = 0.0 ; var segments = Segments ( ) ; for ( var i = 0 ; i < segments . Length ; i ++ ) { var s = segments [ i ] ; var currLength = s . Length ( ) ; if ( totalLength <= d && totalLength + currLength >= d ) { o = s . PointAt ( ( d - totalLength ) / currLength ) ; x = s . Direction ( ) . Cross ( up ) ; break ; } totalLength += currLength ; } } return new Transform ( o , x , up ) ; }
Get the Transform at the specified parameter along the Polygon.
Get the Transform at the specified parameter along the Polygon .
// Vector3: Convert to XAxis // Check if the provided parameter is equal // to one of the vertices.
A Transform with its Z axis aligned trangent to the Polygon.
A Transform with its Z axis aligned trangent to the Polygon .
u
double
The parameter on the Polygon between 0.0 and 1.0.
The parameter on the Polygon between 0 . 0 and 1 . 0 .