VectorExtensionMethods

public static class VectorExtensionMethods
Extension methods for Eto.Drawing.SizeF, Vector2d and Vector3d.

Methods

public static bool Angle(this Vector2d a, Vector2d b, out double clockWise, out double anticlockWise)
Compute the clockwise and anti-clockwise angles between two vectors.
a (Vector2d)First vector.
b (Vector2d)Second vector.
clockWise (out double)Clockwise angle from a to b.
anticlockWise (out double)Anti-clockwise angle from a to b.
public static double Angle(this Plane plane, Point3d xyz)
Measure the angle from the plane x-axis to the projection of the xyz point.
plane (Plane)
xyz (Point3d)

Average

#Example
public static Point3d Average(this IEnumerable<Point3d> points)
Compute the average of a collection of points.
points (IEnumerable<Point3d>)Points to average.
Average point.

Average

#Example
public static Point3d Average(this Point3d[] points)
Compute the average of a collection of points.
points (Point3d[])Points to average.
Average point.

ClosestParameter

#Example
public static double ClosestParameter(this Ray3d ray, Point3d point)
Gets the parameter on a semi-finite ray which best approximates a 3D point.
ray (Ray3d)
point (Point3d)

CompareTo

#Example
public static int CompareTo(this Plane plane, Plane other)
Comparison of two planes.
plane (Plane)
other (Plane)

CreatePerpendicular

#Example
public static Vector3d CreatePerpendicular(this Vector3d vector, Vector3d primary, Vector3d secondary)
Create a vector perpendicular to the input vector using custom primary and secondary axes. The length of the perpendicular vector will be identical to the length of the secondary axis, not the input vector.
vector (Vector3d)Input vector.
primary (Vector3d)Custom primary axis direction.
secondary (Vector3d)Custom secondary axis direction. Should be perpendicular to the primary axis./

CreatePerpendicular

#Example
public static Vector3d CreatePerpendicular(this Vector3d vector)
Create a vector perpendicular to the input vector using default primary and secondary axes. The length of the perpendicular vector will be 1.0
vector (Vector3d)

DistanceTo

#Example
public static double DistanceTo(this Ray3d ray, Point3d point)
Gets the smallest distance from a semi-finite ray to a 3D point.
ray (Ray3d)
point (Point3d)

FindMagnitude

#Example
public static bool FindMagnitude(this Field field, double target, Line axis, out double parameter)
Attempt to find a field scalar value along a finite line segment using binary-like searching.
field (Field)Field to sample.
target (double)Target scalar.
axis (Line)Search space.
parameter (out double)Parameter on search space which most closely matches the target scalar.
True if the target magnitude was found on the axis interior, false if otherwise.
public static Vector2d Flip(this Vector2d vector, Vector2d guide)
Flip a vector if the flipped direction better aligns with a guide vector.
vector (Vector2d)Vector to flip.
guide (Vector2d)Guide vector.
Flipped vector (or not).
public static Vector3d Flip(this Vector3d vector, Vector3d guide)
Flip a vector if the flipped direction better aligns with a guide vector.
vector (Vector3d)Vector to flip.
guide (Vector3d)Guide vector.
Flipped vector (or not).

IntersectWithLine

#Example
public static bool IntersectWithLine(this Plane plane, Line line, double domain0, double domain1, out double t)
Intersect a plane with a finite line segment.
plane (Plane)Plane.
line (Line)Line segment.
domain0 (double)Domain at start of line.
domain1 (double)Domain at end of line.
t (out double)Intersection parameter on line domain.
True if intersection happened.

IsSize

#Example
public static bool IsSize(this Matrix matrix, int rowCount, int columnCount)
Test whether a matrix has a specific size.
matrix (Matrix)Matrix.
rowCount (int)Row count.
columnCount (int)ColumnCount.
True if matrix is this exact size.

IsSize

#Example
public static bool IsSize(this Matrix matrix, params (int rows, int columns)[] sizes)
Test whether a matrix has a specific size.
matrix (Matrix)Matrix to test.
sizes (params (int rows, int columns)[])Potential sizes.
True if matrix is this exact size.

LineSpan

#Example
public static Interval LineSpan(this Line line, BoundingBox box)
Get the domain on a line segment which perpendicularly spans an entire box.
line (Line)
box (BoundingBox)

LineSpan

#Example
public static Interval LineSpan(this Line line, Box box)
Get the domain on a line segment which perpendicularly spans an entire box.
line (Line)
box (Box)

LineSpan

#Example
public static Interval LineSpan(this Line line, IEnumerable<Point3d> points)
Get the domain on a line segment which perpendicularly spans an entire box.
line (Line)
points (IEnumerable<Point3d>)Points to span.

LineSpan

#Example
public static Interval LineSpan(this Line line, params Point3d[] points)
Get the domain on a line segment which perpendicularly spans an entire box.
line (Line)
points (params Point3d[])Points to span.

PointAt

#Example
public static Point3d PointAt(this Plane plane, Point2d uv)
Evaluate the plane at a given coordinate.
plane (Plane)
uv (Point2d)

PointAt

#Example
public static Point3d PointAt(this Plane plane, Point3d uvw)
Evaluate the plane at a given coordinate.
plane (Plane)
uvw (Point3d)

ProjectUV

#Example
public static Point2d ProjectUV(this Plane plane, Point3d point)
Rewrite a point in world coordinates in two-dimensional uv coordinates.
plane (Plane)
point (Point3d)
Point in plane UV coordinates.

ProjectUVW

#Example
public static Point3d ProjectUVW(this Plane plane, Point3d point)
Rewrite a point in world coordinates in two-dimensional uv coordinates.
plane (Plane)
point (Point3d)
Point in plane UV coordinates.
public static Vector3d Slerp(this Vector3d vector, Vector3d other, double factor)
Perform slerp interpolation on two vectors.
vector (Vector3d)
other (Vector3d)
factor (double)
public static Vector2d To2d(this SizeF size)
Convert a SizeF into a Point2d.
size (SizeF)Size.
Vector.
public static Vector2d To2d(this Vector3d vector)
Convert a Vector3d into a Vector2d.
vector (Vector3d)Vector.
Vector.
public static Point3d To3d(this Point3f point)
Convert a Point3f into a Point3d.
point (Point3f)
public static Vector3d To3d(this SizeF size)
Convert a SizeF into a Vector3d.
size (SizeF)Size.
Vector.
public static Vector3d To3d(this Vector2d vector)
Convert a Vector2d into a Vector3d.
vector (Vector2d)Vector.
Vector.
public static Vector3d To3d(this Vector3f vector)
vector (Vector3f)
public static Vector3f To3f(this Vector3d vector)
Convert a Vector3d into a Vector2d.
vector (Vector3d)Vector.
Vector.

ToComplex

#Example
public static Complex ToComplex(this Matrix matrix)
Convert a column or row matrix with two cells into a complex number.
matrix (Matrix)
Complex number.

ToMathNetMatrix

#Example
public static Matrix ToMathNetMatrix(this Matrix matrix)
Convert a RhinoCommon matrix into a MathNet matrix.
matrix (Matrix)

ToPoint3d

#Example
public static Point3d ToPoint3d(this Matrix matrix)
Convert a column or row matrix with three cells into a point.
matrix (Matrix)
Point.

ToRhinoCommonMatrix

#Example
public static Matrix ToRhinoCommonMatrix(this Matrix<double> matrix)
Convert a MathNet matrix into a RhinoCommon matrix.
matrix (Matrix<double>)

ToSize

#Example
public static Size ToSize(this SizeF point)
Convert a SizeF into a Size.
point (SizeF)Size to convert.
Size.

ToSizeF

#Example
public static SizeF ToSizeF(this Vector2d vector)
Convert a Vector2d to a SizeF.
vector (Vector2d)Vector.
XY projection of vector.

ToSizeF

#Example
public static SizeF ToSizeF(this Vector3d vector)
Convert a Vector3d to a SizeF.
vector (Vector3d)Vector.
XY projection of vector.

ToTransform

#Example
public static Transform ToTransform(this Matrix matrix)
Convert a 3×3, or 4×3, or 4×4 matrix into a transformation.
matrix (Matrix)Matrix to transform.
Transformation.

ToVector3d

#Example
public static Vector3d ToVector3d(this Matrix matrix)
Convert a column or row matrix with three cells into a vector.
matrix (Matrix)
Vector.

TransformDirection

#Example
public static Vector3d TransformDirection(this Vector3d vector, Transform transform, Point3d anchor)
Transform a vector spatially. This is needed when transforming vectors using shear or taper matrices. This method differs from the standard Vector3d.Transform method in that it retains perpendicularity through taper and shear deformations. This method does not guarantee that the magnitude of the result is anywhere near correct, it is only concerned with the direction.
vector (Vector3d)Vector to transform.
transform (Transform)Transformation.
anchor (Point3d)Anchor point for vector.
Transformed vector.