Show / Hide Table of Contents

    Class Vector3Extensions

    Extension methods for Vector3.

    Inheritance
    System.Object
    Vector3Extensions
    Inherited Members
    System.Object.Equals(System.Object)
    System.Object.Equals(System.Object, System.Object)
    System.Object.GetHashCode()
    System.Object.GetType()
    System.Object.MemberwiseClone()
    System.Object.ReferenceEquals(System.Object, System.Object)
    System.Object.ToString()
    Namespace: Elements.Geometry
    Assembly: Hypar.Elements.dll
    Syntax
    public static class Vector3Extensions

    Methods

    AreCollinear(IList<Vector3>)

    Are the provided points along the same line?

    Declaration
    [Obsolete("Use AreCollinearByDistance instead")]
    public static bool AreCollinear(this IList<Vector3> points)
    Parameters
    Type Name Description
    System.Collections.Generic.IList<Vector3> points
    Returns
    Type Description
    System.Boolean

    AreCollinearByDistance(IList<Vector3>, Double)

    Check whether three points are on the same line withing certain distance.

    Declaration
    public static bool AreCollinearByDistance(this IList<Vector3> points, double tolerance = 1E-05)
    Parameters
    Type Name Description
    System.Collections.Generic.IList<Vector3> points

    List of points to check. Order is not important.

    System.Double tolerance

    Distance tolerance.

    Returns
    Type Description
    System.Boolean

    AreCoplanar(IList<Vector3>, Double)

    Are the provided points on the same plane, within tolerance?

    Declaration
    public static bool AreCoplanar(this IList<Vector3> points, double tolerance = 1E-05)
    Parameters
    Type Name Description
    System.Collections.Generic.IList<Vector3> points

    The points to test.

    System.Double tolerance

    Acceptable deviation from the plane while still being considered coplanar.

    Returns
    Type Description
    System.Boolean
    Remarks

    This method uses the first three non-collinear points to define the plane, rather than a best-fit plane. We may return a false negative in the case that there is a different best-fit plane that is within tolerance of all points.

    Average(IEnumerable<Vector3>)

    Find the average of a collection of Vector3.

    Declaration
    public static Vector3 Average(this IEnumerable<Vector3> points)
    Parameters
    Type Name Description
    System.Collections.Generic.IEnumerable<Vector3> points

    The Vector3 collection to average.

    Returns
    Type Description
    Vector3

    A Vector3 representing the average.

    BestFitLine(IList<Vector3>)

    Return an approximate fit line through a set of points using the least squares method.

    Declaration
    public static Line BestFitLine(this IList<Vector3> points)
    Parameters
    Type Name Description
    System.Collections.Generic.IList<Vector3> points

    The points to fit. Should have at least 2 distinct points.

    Returns
    Type Description
    Line

    An approximate fit line through a set of points using the least squares method. If there is less than 2 distinct points, returns null.

    FitLine(IList<Vector3>)

    Return an approximate fit line through a set of points. Not intended for statistical regression purposes. Note that the line is unit length: it shouldn't be expected to span the length of the points.

    Declaration
    public static Line FitLine(this IList<Vector3> points)
    Parameters
    Type Name Description
    System.Collections.Generic.IList<Vector3> points

    The points to fit.

    Returns
    Type Description
    Line

    A line roughly running through the set of points, or null if the points are nearly coincident.

    Shrink(Vector3[], Double)

    Shrink a collection of Vector3 towards their average.

    Declaration
    public static Vector3[] Shrink(this Vector3[] points, double distance)
    Parameters
    Type Name Description
    Vector3[] points

    The collection of Vector3 to shrink.

    System.Double distance

    The distance to shrink along the vector to average.

    Returns
    Type Description
    Vector3[]

    ToArray(IList<Vector3>)

    Convert a collection of Vector3 to a flat array of double.

    Declaration
    public static double[] ToArray(this IList<Vector3> points)
    Parameters
    Type Name Description
    System.Collections.Generic.IList<Vector3> points

    The collection of Vector3 to convert.

    Returns
    Type Description
    System.Double[]

    An array containing x,y,z,x1,y1,z1,x2,y2,z2,...

    ToGraphicsBuffers(IList<Vector3>)

    Convert a list of vertices to a GraphicsBuffers object.

    Declaration
    public static GraphicsBuffers ToGraphicsBuffers(this IList<Vector3> vertices)
    Parameters
    Type Name Description
    System.Collections.Generic.IList<Vector3> vertices

    The vertices to convert.

    Returns
    Type Description
    GraphicsBuffers

    ToTransform(IList<Vector3>)

    Compute a transform with the origin at points[0], with an X axis along points[1]->points[0], and a normal computed using the vectors points[2]->points[1] and points[1]->points[0].

    Declaration
    public static Transform ToTransform(this IList<Vector3> points)
    Parameters
    Type Name Description
    System.Collections.Generic.IList<Vector3> points
    Returns
    Type Description
    Transform

    TryGetThreeNonCollinearPoints(IList<Vector3>, out Int32, out Int32)

    Check if a collection of points has at least three non-collinear points. Returns true if it does, false otherwise. The first two points which form a valid triangle with the first point are returned via out parameters.

    Declaration
    public static bool TryGetThreeNonCollinearPoints(this IList<Vector3> points, out int p1Index, out int p2Index)
    Parameters
    Type Name Description
    System.Collections.Generic.IList<Vector3> points

    The list of points to search.

    System.Int32 p1Index

    The index of the first non-collinear point after index 0.

    System.Int32 p2Index

    The index of the second non-collinear point after index 0.

    Returns
    Type Description
    System.Boolean

    True if there are three non-collinear points.

    UniqueWithinTolerance(IEnumerable<Vector3>, Double)

    De-duplicate a collection of Vectors, such that no two vectors in the result are within tolerance of each other.

    Declaration
    public static IEnumerable<Vector3> UniqueWithinTolerance(this IEnumerable<Vector3> vectors, double tolerance = 1E-05)
    Parameters
    Type Name Description
    System.Collections.Generic.IEnumerable<Vector3> vectors

    List of vectors

    System.Double tolerance

    Distance tolerance

    Returns
    Type Description
    System.Collections.Generic.IEnumerable<Vector3>

    A new collection of vectors with duplicates removed.