Table of Contents

Class Ext

Namespace
SearchAThing.Sci
Assembly
netcore-sci.dll

netcore-sci extension methods

public static class Ext
Inheritance
Ext
Inherited Members

Methods

Abs(Vector3)

return abs of given Vector3

public static Vector3 Abs(this Vector3 v)

Parameters

v Vector3

Returns

Vector3

AddEntities(DxfObject, IEnumerable<EntityObject>, Layer?)

add entity to the given dxf object ( it can be Dxfdocument or Block ) optionally set layer

public static void AddEntities(this DxfObject dxfObj, IEnumerable<EntityObject> ents, Layer? layer = null)

Parameters

dxfObj DxfObject
ents IEnumerable<EntityObject>
layer Layer

AddEntity(DxfObject, EntityObject, Layer?)

add entity to the given dxf object ( it can be Dxfdocument or Block ) optionally set layer

public static EntityObject AddEntity(this DxfObject dxfObj, EntityObject eo, Layer? layer = null)

Parameters

dxfObj DxfObject
eo EntityObject
layer Layer

Returns

EntityObject

Angle(double, double, bool)

retrieve angle between from and to given; angles will subjected to normalization [0,2pi) and angle from can be greather than to

public static double Angle(this double angleFrom, double angleTo, bool normalizeAngles = true)

Parameters

angleFrom double

angle from

angleTo double

angle to

normalizeAngles bool

actuate [0,2PI) angle normalization

Returns

double

AngleInRange(double, double, double, double)

states if given angle is contained in from, to angle range; multiturn angles are supported because test will normalize to [0,2pi) automatically.

public static bool AngleInRange(this double pt_angle, double angle_from, double angle_to, double radTol = 1E-10)

Parameters

pt_angle double

angle(rad) to test

angle_from double

angle(rad) from

angle_to double

angle(rad) to

radTol double

optional rad tolerance

Returns

bool

AutoIntersect(IEnumerable<Line3D>, double, bool, IEnumerable<Vector3D>?)

autointersect given list of segments ( duplicates and overlapping are removed )

TODO: dummy function, optimize

public static IReadOnlyList<Line3D> AutoIntersect(this IEnumerable<Line3D> _segs, double tol, bool mergeColinearSegments = true, IEnumerable<Vector3D>? addictionalSplitPoints = null)

Parameters

_segs IEnumerable<Line3D>
tol double
mergeColinearSegments bool
addictionalSplitPoints IEnumerable<Vector3D>

Returns

IReadOnlyList<Line3D>

AutoTrimExtends(IEnumerable<Edge>, double)

automatically trim or extends consecutive edges intersections

public static IEnumerable<Edge> AutoTrimExtends(this IEnumerable<Edge> edges, double tol)

Parameters

edges IEnumerable<Edge>
tol double

Returns

IEnumerable<Edge>

AutoZoom(DxfDocument, BBox3D)

tries to zoom dxf viewport on the given bbox

public static void AutoZoom(this DxfDocument dxf, BBox3D bbox)

Parameters

dxf DxfDocument
bbox BBox3D

BBox(IEnumerable<Geometry>, double)

bbox that cover all given geometries

public static BBox3D BBox(this IEnumerable<Geometry> geometry_block, double tol)

Parameters

geometry_block IEnumerable<Geometry>
tol double

length tolerance

Returns

BBox3D

BBox(IEnumerable<Vector3D>)

construct a bbox from given enumerable set of points

public static BBox3D BBox(this IEnumerable<Vector3D> pts)

Parameters

pts IEnumerable<Vector3D>

points to build bbox

Returns

BBox3D

bbox from given enumerable set of points

BBox(IEnumerable<EntityObject>, double)

construct a bbox from given set of dxf entity objects

public static BBox3D BBox(this IEnumerable<EntityObject> ents, double tol)

Parameters

ents IEnumerable<EntityObject>

enumerable of dxf entity object

tol double

tolerance for comparision length tests

Returns

BBox3D

new bbox containing given set of dxf entity objects

BBox(EntityObject, double)

construct a bbox from given dxf EntityObject

public static BBox3D BBox(this EntityObject eo, double tol)

Parameters

eo EntityObject

dxf entity object

tol double

tolerance for comparision length tests

Returns

BBox3D

new bbox that contains given dxf entity object

Remarks

Currently Text, MText width not evaluated ( only insertion point is considered ). Arc is considered only From, MidPoint, To. Circle is considered only 4 points on circumference.

BBox3D(DxfDocument)

public static BBox3D BBox3D(this DxfDocument dxf)

Parameters

dxf DxfDocument

Returns

BBox3D

BestFittingPlane(IEnumerable<Line3D>, double)

detect best fitting plane from the set of given lines. precondition: lines must coplanar

public static Plane3D BestFittingPlane(this IEnumerable<Line3D> lines, double tol)

Parameters

lines IEnumerable<Line3D>
tol double

Returns

Plane3D

BestFittingPlane(IEnumerable<Vector3D>, double)

detect best fitting plane for given set of coplanar points

public static Plane3D BestFittingPlane(this IEnumerable<Vector3D> pts, double tol)

Parameters

pts IEnumerable<Vector3D>
tol double

Returns

Plane3D

Boolean(IEnumerable<Vector3D>, double, IEnumerable<Vector3D>, ClipType, bool)

can generate a Int64MapExceptionRange exception if double values can't fit into a In64 representation. In that case try with tolerances not too small. It is suggested to use a lenTol/10 to avoid lost of precision during domain conversions. Altenatively use Loop to find exact intersection between planar poly supporting lines and arcs. ( this implementation uses Int64Map and clipper library )

public static IEnumerable<IEnumerable<Vector3D>> Boolean(this IEnumerable<Vector3D> polyA, double tol, IEnumerable<Vector3D> polyB, ClipType type, bool selfCheckInt64MapTolerance = true)

Parameters

polyA IEnumerable<Vector3D>
tol double
polyB IEnumerable<Vector3D>
type ClipType
selfCheckInt64MapTolerance bool

Returns

IEnumerable<IEnumerable<Vector3D>>

CS(EntityObject)

public static CoordinateSystem3D CS(this EntityObject eo)

Parameters

eo EntityObject

Returns

CoordinateSystem3D

CadScript(Face3D)

public static string CadScript(this Face3D face)

Parameters

face Face3D

Returns

string

CadScriptPoint(IEnumerable<Vector3D>)

create script that draw a point foreach of point set

public static string CadScriptPoint(this IEnumerable<Vector3D> points)

Parameters

points IEnumerable<Vector3D>

points

Returns

string

cadscript

CadScriptPolyline(IEnumerable<Vector3D>)

create a 3dpolyline cadscript from given set of points

public static string CadScriptPolyline(this IEnumerable<Vector3D> points)

Parameters

points IEnumerable<Vector3D>

point set

Returns

string

cad script

CheckSense(IEnumerable<Edge>, double)

From given set of edges returns the same set eventually toggling sense of edges to make them glue so that SGeomTo of previous equals SGeomFrom of current. It can raise exception if there isn't availability to glue edges regardless toggling their sense. first element will toggled to match second one, then other elements will follow the sense matching established.

public static IEnumerable<Edge> CheckSense(this IEnumerable<Edge> edges, double tol)

Parameters

edges IEnumerable<Edge>

input edges list

tol double

length tolerance

Returns

IEnumerable<Edge>

CheckSort(IEnumerable<Edge>, double)

Allow to sort edges when a not consequential set is given to allow subsequent CheckSense. It can raise exception if there isn't a possible sequence continuity between given edges.

public static IEnumerable<Edge> CheckSort(this IEnumerable<Edge> edges, double tol)

Parameters

edges IEnumerable<Edge>

input edges list

tol double

length tolerance

Returns

IEnumerable<Edge>

edges in sequence ( sense not yet checked )

CircleBy3Points(IEnumerable<Vector3D>)

build circle3d by given set of 3 points

public static Circle3D CircleBy3Points(this IEnumerable<Vector3D> _pts)

Parameters

_pts IEnumerable<Vector3D>

Returns

Circle3D

Clamp(Vector3, Vector3, Vector3)

return clamped Vector3 between [min,max] interval

public static Vector3 Clamp(this Vector3 v, Vector3 min, Vector3 max)

Parameters

v Vector3

xyz vector

min Vector3

min value admissible

max Vector3

max value admissible

Returns

Vector3

given vector with xyz components clamped to corresponding min,max components

CompareToTol(double, double, double)

compare a, b using given tol

public static int CompareToTol(this double a, double tol, double b)

Parameters

a double

first term

tol double

equals tolerance

b double

second term

Returns

int

-1 if a less than b ; 0 if a equals tol b ; +1 if a greather than b

ContainsPoint(IEnumerable<Vector3D>, double, Vector3D, LoopContainsPointMode)

states if given point is in polygon

public static bool ContainsPoint(this IEnumerable<Vector3D> _pts, double tol, Vector3D pt, LoopContainsPointMode mode = LoopContainsPointMode.InsideOrPerimeter)

Parameters

_pts IEnumerable<Vector3D>

polygon point ( must ordered )

tol double

length tolerance

pt Vector3D

point to test

mode LoopContainsPointMode

allow to specify contains test type

Returns

bool

ConvexHull2D(IEnumerable<Vector3D>)

compute convex hull using LoycCore https://github.com/qwertie/LoycCore

public static IEnumerable<Vector3D> ConvexHull2D(this IEnumerable<Vector3D> pts)

Parameters

pts IEnumerable<Vector3D>

Returns

IEnumerable<Vector3D>

CoordTransform(DxfDocument, Func<Vector3D, Vector3D>)

public static IEnumerable<EntityObject> CoordTransform(this DxfDocument dxf, Func<Vector3D, Vector3D> transform)

Parameters

dxf DxfDocument
transform Func<Vector3D, Vector3D>

Returns

IEnumerable<EntityObject>

CoordTransform(EntityObject, Func<Vector3D, Vector3D>, Vector3D?)

build a clone of the given entity with coord transformed accordingly given function.

public static EntityObject CoordTransform(this EntityObject eo, Func<Vector3D, Vector3D> transform, Vector3D? origin = null)

Parameters

eo EntityObject
transform Func<Vector3D, Vector3D>
origin Vector3D

Returns

EntityObject

Debug(Vector3, string)

debug to console with optional prefix

public static Vector3 Debug(this Vector3 v, string prefix = "")

Parameters

v Vector3

vector

prefix string

optional prefix

Returns

Vector3

vector

Debug(Vector4, string)

debug to console with optional prefix

public static Vector4 Debug(this Vector4 v, string prefix = "")

Parameters

v Vector4

vector

prefix string

optional prefix

Returns

Vector4

vector

Decompose(Matrix4x4)

decompose given 4x4 matrix into scale, rotation, translation

public static (Vector3 translation, Quaternion rotation, Vector3 scale, bool success) Decompose(this Matrix4x4 m)

Parameters

m Matrix4x4

Returns

(Vector3 translation, Quaternion rotation, Vector3 scale, bool success)

DetectPlane(IEnumerable<Edge>, double)

public static Plane3D DetectPlane(this IEnumerable<Edge> edges, double tol)

Parameters

edges IEnumerable<Edge>
tol double

Returns

Plane3D

DistinctKeepOrder(IEnumerable<Vector3D>, Vector3DEqualityComparer)

retrieve distinct of given vector set ensuring to maintain given order

public static IEnumerable<Vector3D> DistinctKeepOrder(this IEnumerable<Vector3D> vectors, Vector3DEqualityComparer cmp)

Parameters

vectors IEnumerable<Vector3D>
cmp Vector3DEqualityComparer

Returns

IEnumerable<Vector3D>

DrawCube(DxfObject, Vector3D, double, Layer?)

Creates and add dxf entities for a 6 faces of a cube

public static IEnumerable<EntityObject> DrawCube(this DxfObject dxfObj, Vector3D center, double L, Layer? layer = null)

Parameters

dxfObj DxfObject
center Vector3D
L double
layer Layer

Returns

IEnumerable<EntityObject>

DrawCuboid(DxfObject, Vector3D, Vector3D, Layer?)

Creates and add dxf entities for 6 faces of a cuboid

public static IEnumerable<EntityObject> DrawCuboid(this DxfObject dxfObj, Vector3D center, Vector3D size, Layer? layer = null)

Parameters

dxfObj DxfObject
center Vector3D
size Vector3D
layer Layer

Returns

IEnumerable<EntityObject>

DrawStar(DxfObject, Vector3D, double, Layer?)

Creates and add dxf entities for a 3 axis of given length centered in given center point.

public static IEnumerable<EntityObject> DrawStar(this DxfObject dxfObj, Vector3D center, double L, Layer? layer = null)

Parameters

dxfObj DxfObject
center Vector3D
L double
layer Layer

Returns

IEnumerable<EntityObject>

DrawTimeline(DxfObject, List<(DateTime from, DateTime to)>, double, double, double, double, Func<DateTime, string>?)

public static IEnumerable<EntityObject> DrawTimeline(this DxfObject dxf, List<(DateTime from, DateTime to)> timeline, double textHeight = 2, double circleRadius = 1.5, double maxWidth = 180, double stopDays = 60, Func<DateTime, string>? dtStr = null)

Parameters

dxf DxfObject
timeline List<(DateTime from, DateTime to)>
textHeight double
circleRadius double
maxWidth double
stopDays double
dtStr Func<DateTime, string>

Returns

IEnumerable<EntityObject>

Entities(DxfDocument)

public static IEnumerable<EntityObject> Entities(this DxfDocument dxf)

Parameters

dxf DxfDocument

Returns

IEnumerable<EntityObject>

EqualsTol(IEnumerable<Vector3D>, double, IEnumerable<Vector3D>)

checks two list of vectors are equals and with same order of elements

public static bool EqualsTol(this IEnumerable<Vector3D> lst, double tol, IEnumerable<Vector3D> other)

Parameters

lst IEnumerable<Vector3D>
tol double
other IEnumerable<Vector3D>

Returns

bool

EqualsTol(IEnumerable<(double, double)>, IEnumerable<(double, double)>, double, double)

compares two list tuples

public static bool EqualsTol(this IEnumerable<(double, double)> tuple_list1, IEnumerable<(double, double)> tuple_list2, double tol1, double tol2)

Parameters

tuple_list1 IEnumerable<(double, double)>
tuple_list2 IEnumerable<(double, double)>
tol1 double
tol2 double

Returns

bool

EqualsTol(Vector3, double, Vector3)

public static bool EqualsTol(this Vector3 v, double tol, Vector3 other)

Parameters

v Vector3
tol double
other Vector3

Returns

bool

EqualsTol(Vector3, double, Vector3)

public static bool EqualsTol(this Vector3 v, double tol, Vector3 other)

Parameters

v Vector3
tol double
other Vector3

Returns

bool

Explode(Insert)

public static IEnumerable<EntityObject> Explode(this Insert ins)

Parameters

ins Insert

Returns

IEnumerable<EntityObject>

Fmt(double, int, int)

format number with given decimals and total length aligning right

public static string Fmt(this double n, int dec, int size)

Parameters

n double

number to format

dec int

decimals round

size int

string size

Returns

string

string representing given number formatted with given decimals and total length aligning right

Fmt(Matrix4x4, int, int)

matrix4x4 formatted print suitable for monospace font or terminal display

public static string Fmt(this Matrix4x4 m, int dec, int width = 10)

Parameters

m Matrix4x4

matrix

dec int

decimal to display

width int

column width

Returns

string

formatted text representation of given matrix

Fmt(float, int, int)

format number with given decimals and total length aligning right

public static string Fmt(this float n, int dec, int size)

Parameters

n float

number to format

dec int

decimals round

size int

string size

Returns

string

string representing given number formatted with given decimals and total length aligning right

GetItem(Matrix4x4, int, int)

retrieve item at given row(0..3), col(0..3) of the matrix4x4

public static float GetItem(this Matrix4x4 m, int rowIdx, int colIdx)

Parameters

m Matrix4x4

matrix

rowIdx int

row (0 based index)

colIdx int

col (0 based index)

Returns

float

matrix item

Intersect(IEnumerable<Geometry>, double, IEnumerable<Geometry>, GeomSegmentMode, GeomSegmentMode)

find intersection geometries resulting from all this geometries with all given geom2

public static IEnumerable<(Geometry intersectGeom, Geometry g1, Geometry g2)> Intersect(this IEnumerable<Geometry> _geom1, double tol, IEnumerable<Geometry> _geom2, GeomSegmentMode geom1SegmentMode = GeomSegmentMode.FromTo, GeomSegmentMode geom2SegmentMode = GeomSegmentMode.FromTo)

Parameters

_geom1 IEnumerable<Geometry>
tol double

length tolerance

_geom2 IEnumerable<Geometry>
geom1SegmentMode GeomSegmentMode

if geom1 item is Line3D specifies how to consider it

geom2SegmentMode GeomSegmentMode

if geom2 item is Line3D specifies how to consider it

Returns

IEnumerable<(Geometry intersectGeom, Geometry g1, Geometry g2)>

Intersect(IEnumerable<Line3D>, double, Line3D, GeomSegmentMode)

Find intersection points (0,1,2) of the given line with the given polygon TODO unit test

public static IEnumerable<Vector3D> Intersect(this IEnumerable<Line3D> polygonSegments, double tol, Line3D line, GeomSegmentMode segmentMode)

Parameters

polygonSegments IEnumerable<Line3D>
tol double
line Line3D
segmentMode GeomSegmentMode

Returns

IEnumerable<Vector3D>

Inverse(Matrix4x4)

retrieve inverse of given matrix

public static Matrix4x4 Inverse(this Matrix4x4 m)

Parameters

m Matrix4x4

4x4 matrix

Returns

Matrix4x4

inverse of given matrix

Remarks

can gen exception

IsAClosedPoly(IEnumerable<Line3D>, double)

Preprocess segs with SortPoly if needed. Return the ordered segments poly or null if not a closed poly.

public static IEnumerable<Line3D>? IsAClosedPoly(this IEnumerable<Line3D> segs, double tol)

Parameters

segs IEnumerable<Line3D>
tol double

Returns

IEnumerable<Line3D>

IsLinearIndependent(IEnumerable<Vector3D>)

states if given 3 vectors are linearly independent

public static bool IsLinearIndependent(this IEnumerable<Vector3D> vectors)

Parameters

vectors IEnumerable<Vector3D>

Returns

bool

true if given vector are linearly independent

Remarks

Length(IEnumerable<Vector3D>)

compute length of polyline from given seq_pts

public static double Length(this IEnumerable<Vector3D> seq_pts)

Parameters

seq_pts IEnumerable<Vector3D>

Returns

double

MakeVertexToEdges(IEnumerable<Edge>, double)

public static Dictionary<Vector3D, List<Edge>> MakeVertexToEdges(this IEnumerable<Edge> edges, double tol)

Parameters

edges IEnumerable<Edge>
tol double

Returns

Dictionary<Vector3D, List<Edge>>

Mean(IEnumerable<Vector3D>, bool)

mean of given vetor3d list note: if used to compute poly center enable skipFirstAtEnd

public static Vector3D Mean(this IEnumerable<Vector3D> lst, bool skipFirstAtEnd = false)

Parameters

lst IEnumerable<Vector3D>
skipFirstAtEnd bool

Returns

Vector3D

MergeColinearSegments(IEnumerable<Line3D>, double)

merge colinear overlapped segments into single result segments direction and order is not ensured pre: segs must colinear

public static IEnumerable<Line3D> MergeColinearSegments(this IEnumerable<Line3D> _segs, double tol)

Parameters

_segs IEnumerable<Line3D>
tol double

Returns

IEnumerable<Line3D>

MidPoint(Polyline2D)

get the midpoint of the 3d polyline distance is computed over all segments

public static Vector3D? MidPoint(this Polyline2D poly)

Parameters

poly Polyline2D

Returns

Vector3D

MinDistance(IEnumerable<double>)

Return the min distance between two adiacent number given from all of the given ordered set of numbers.

public static double MinDistance(this IEnumerable<double> orderedNumbers)

Parameters

orderedNumbers IEnumerable<double>

Returns

double

0 if empty set or 1 element. min distance otherwise.

MinMax(IEnumerable<double>)

retrieve min,max w/single sweep

public static (double min, double max) MinMax(this IEnumerable<double> input)

Parameters

input IEnumerable<double>

Returns

(double min, double max)

ModelSpace(DxfDocument)

public static Block ModelSpace(this DxfDocument dxf)

Parameters

dxf DxfDocument

Returns

Block

NormalizeAngle(double, double, double)

Normalize given angle(rad) into [maxRad-2PI,maxRad) range.

public static double NormalizeAngle(this double angle_rad, double maxRadExcluded = 6.283185307179586, double radTol = 1E-10)

Parameters

angle_rad double

angle(rad) to normalize

maxRadExcluded double

normalization range (excluded) max value ( minimum will computed as max-2PI )

radTol double

override rad tolerance

Returns

double

angle normalized

Remarks

Normalized(Vector3)

normalize given vector

public static Vector3 Normalized(this Vector3 v)

Parameters

v Vector3

vector

Returns

Vector3

normalized vector

Normalized(Vector4)

public static Vector4 Normalized(this Vector4 v)

Parameters

v Vector4

Returns

Vector4

Offset(IEnumerable<Vector3D>, double, double)

increase of decrease polygon points offseting ( this implementation uses Int64Map and clipper library )

public static IEnumerable<Vector3D> Offset(this IEnumerable<Vector3D> pts, double tol, double offset)

Parameters

pts IEnumerable<Vector3D>
tol double
offset double

Returns

IEnumerable<Vector3D>

Offset(Polyline2D, double, Vector3D, double)

public static Polyline2D Offset(this Polyline2D lwp, double tol, Vector3D sideRefPt, double amount)

Parameters

lwp Polyline2D
tol double
sideRefPt Vector3D
amount double

Returns

Polyline2D

OffsetGeoms(Polyline2D, double, Vector3D, double)

create offseted polygon from this one by offset of given offset amount toward given sideRefPt.

public static IEnumerable<Edge> OffsetGeoms(this Polyline2D lwp, double tol, Vector3D sideRefPt, double offset)

Parameters

lwp Polyline2D

this polyline

tol double

length tolerance

sideRefPt Vector3D

offseted polygon will the one on the side nearest to this ref pt. The offseted polygon doesn't need to contains this point, its only used to disambiguate the side choose.

offset double

offset amount from this actual polyline toward offseted one.

Returns

IEnumerable<Edge>

offseted polygon

Points(EntityObject)

public static IEnumerable<Vector3D> Points(this EntityObject eo)

Parameters

eo EntityObject

Returns

IEnumerable<Vector3D>

PolyPoints(IEnumerable<Line3D>)

retrieve s[0].from, s[1].from, ... s[n-1].from, s[n-1].to points

public static IEnumerable<Vector3D> PolyPoints(this IEnumerable<Line3D> segs)

Parameters

segs IEnumerable<Line3D>

Returns

IEnumerable<Vector3D>

PolyPoints(IEnumerable<Vector3D>, double, bool)

given a set of polygon pts, returns the enumeation of all pts so that the last not attach to the first ( if makeClosed = false ). Elsewhere it returns a last point equals the first ( makeClosed = true ).

public static IEnumerable<Vector3D> PolyPoints(this IEnumerable<Vector3D> pts, double tol, bool makeClosed = false)

Parameters

pts IEnumerable<Vector3D>
tol double
makeClosed bool

Returns

IEnumerable<Vector3D>

PolygonSegments(IEnumerable<Vector3D>, double)

yields an ienumerable of polygon segments corresponding to the given polygon pts ( z is not considered ) works even last point not equals the first one

public static IEnumerable<Line3D> PolygonSegments(this IEnumerable<Vector3D> pts, double tol)

Parameters

pts IEnumerable<Vector3D>
tol double

Returns

IEnumerable<Line3D>

QCadScript(IEnumerable<Edge>, bool)

qcad script from edge enumerable

public static string QCadScript(this IEnumerable<Edge> edges, bool final = true)

Parameters

edges IEnumerable<Edge>
final bool

if true adds QQ

Returns

string

QCadScript(IEnumerable<Geometry>)

qcad script from geoms

public static string QCadScript(this IEnumerable<Geometry> geoms)

Parameters

geoms IEnumerable<Geometry>

Returns

string

QCadScript(Polyline2D, double)

qcad script from lwp

public static string QCadScript(this Polyline2D lwp, double tol)

Parameters

lwp Polyline2D
tol double

Returns

string

RadTol(double, double)

compute angle rad tolerance by given arc length tolerance as (lenTol / radius)

public static double RadTol(this double lenTol, double radius)

Parameters

lenTol double

length tolerance on the arc

radius double

radius of the arc

Returns

double

RepeatFirstAtEnd(IEnumerable<Vector3D>, double)

given points a,b,c it will return a,b,c,a ( first is repeated at end ) it avoid to repeat first at end when latest point already equals the first one

public static IEnumerable<Vector3D> RepeatFirstAtEnd(this IEnumerable<Vector3D> pts, double tol)

Parameters

pts IEnumerable<Vector3D>
tol double

Returns

IEnumerable<Vector3D>

Reversed(IEnumerable<Vector3D>)

retrieve reversed version of given point set ( used to convert ccw, cw )

public static IList<Vector3D> Reversed(this IEnumerable<Vector3D> pts)

Parameters

pts IEnumerable<Vector3D>

Returns

IList<Vector3D>

Reversed(IList<Vector3D>)

retrieve reversed version of given point set ( used to convert ccw, cw )

public static IEnumerable<Vector3D> Reversed(this IList<Vector3D> pts)

Parameters

pts IList<Vector3D>

Returns

IEnumerable<Vector3D>

Segments(IEnumerable<Geometry>, double)

segments representation of given geometries if arc found a segment between endpoints returns

public static IEnumerable<Line3D> Segments(this IEnumerable<Geometry> geometry_block, double tol)

Parameters

geometry_block IEnumerable<Geometry>
tol double

length tolerance

Returns

IEnumerable<Line3D>

Set(Hatch, HatchSetterDelegate)

set hatch and boundary entities with given action

public static Hatch Set(this Hatch hatch, Ext.HatchSetterDelegate setter)

Parameters

hatch Hatch
setter Ext.HatchSetterDelegate

Returns

Hatch

SetColor(EntityObject, AciColor)

public static EntityObject SetColor(this EntityObject eo, AciColor color)

Parameters

eo EntityObject
color AciColor

Returns

EntityObject

SetLayer(IEnumerable<EntityObject>, Layer)

Set layer of given set of dxf entities

public static IEnumerable<EntityObject> SetLayer(this IEnumerable<EntityObject> ents, Layer layer)

Parameters

ents IEnumerable<EntityObject>
layer Layer

Returns

IEnumerable<EntityObject>

SetLayer(EntityObject, Layer)

public static EntityObject SetLayer(this EntityObject eo, Layer layer)

Parameters

eo EntityObject
layer Layer

Returns

EntityObject

SetX(Vector3, float)

create new Vector3 with given x overriden, others yz unchanged

public static Vector3 SetX(this Vector3 v, float x)

Parameters

v Vector3

vector

x float

x value to set

Returns

Vector3

changed vector

SetY(Vector3, float)

create new Vector3 with given y overriden, others xz unchanged

public static Vector3 SetY(this Vector3 v, float y)

Parameters

v Vector3

vector

y float

y value to set

Returns

Vector3

changed vector

SetZ(Vector3, float)

create new Vector3 with given z overriden, others xy unchanged

public static Vector3 SetZ(this Vector3 v, float z)

Parameters

v Vector3

vector

z float

z value to set

Returns

Vector3

changed vector

Similarity(double, double)

Test two numbers for similarity; the factor of similarity f = (max(x,y)-min(x,y)) / min(abs(x), abs(y)). Special cases:

  • if x=y=0 returns 0
  • if x=0 xor y=0 returns max(abs(x),abs(y)))/2
  • if sign(x) != sign(y) returns StDevP(x,y)
public static double Similarity(this double x, double y)

Parameters

x double

first number

y double

second number

Returns

double

similarity factor

SortCCW(IEnumerable<Vector3D>, double, CoordinateSystem3D)

sort the set of points in ccw order;
note that first returned point could not match the first point in the sequence ( for that use RouteFirst() ext )

public static IEnumerable<Vector3D> SortCCW(this IEnumerable<Vector3D> pts, double tol, CoordinateSystem3D cs)

Parameters

pts IEnumerable<Vector3D>

points

tol double

length tolerance

cs CoordinateSystem3D

CS used with origin as rotation center to sort ccw points and BaseZ used as reference rotation axis ( points plane normal right-hand rotate around )

Returns

IEnumerable<Vector3D>

input set of points ccw sorted

SortCCW(IEnumerable<Vector3D>, double, Vector3D, Vector3D)

sort the set of points in ccw order;
note that first returned point could not match the first point in the sequence ( for that use RouteFirst() ext )

public static IEnumerable<Vector3D> SortCCW(this IEnumerable<Vector3D> pts, double tol, Vector3D center, Vector3D refAxis)

Parameters

pts IEnumerable<Vector3D>

points

tol double

length tolerance

center Vector3D

rotation center to sort ccw points ( can use Mean() or Centroid() ext for closed polygon )

refAxis Vector3D

reference rotation axis ( points plane normal right-hand rotate around )

Returns

IEnumerable<Vector3D>

input set of points ccw sorted

SortCCW<T>(IEnumerable<T>, double, Func<T, Vector3D>, CoordinateSystem3D)

sort the set of templated points in ccw order;
note that first returned point could not match the first point in the sequence ( for that use RouteFirst() ext )

public static IEnumerable<T> SortCCW<T>(this IEnumerable<T> _tpts, double tol, Func<T, Vector3D> getPoint, CoordinateSystem3D cs)

Parameters

_tpts IEnumerable<T>

templated points

tol double

length tolerance

getPoint Func<T, Vector3D>

function to extract Vector3D point from templated point

cs CoordinateSystem3D

CS used with origin as rotation center to sort ccw points and BaseZ used as reference rotation axis ( points plane normal right-hand rotate around )

Returns

IEnumerable<T>

input set of templated points ccw sorted

Type Parameters

T

SortCCW<T>(IEnumerable<T>, double, Func<T, Vector3D>, Vector3D, Vector3D)

sort the set of templated points in ccw order;
note that first returned point could not match the first point in the sequence ( for that use RouteFirst() ext )

public static IEnumerable<T> SortCCW<T>(this IEnumerable<T> tpts, double tol, Func<T, Vector3D> getPoint, Vector3D center, Vector3D refAxis)

Parameters

tpts IEnumerable<T>

templated points

tol double

length tolerance

getPoint Func<T, Vector3D>

function to extract Vector3D point from templated point

center Vector3D

rotation center to sort ccw points ( can use Mean() or Centroid() ext for closed polygon )

refAxis Vector3D

reference rotation axis ( points plane normal right-hand rotate around )

Returns

IEnumerable<T>

input set of templated points ccw sorted

Type Parameters

T

Sqrt(Vector3D)

compute (Sqrt(v.x), Sqrt(v.y), Sqrt(v.z))

public static Vector3D Sqrt(this Vector3D v)

Parameters

v Vector3D

input vector

Returns

Vector3D

sqrt(v)

StatNfos(IEnumerable<double>)

Compute some stat info about given number set using LinqStatistics

public static NumbersStatNfo StatNfos(this IEnumerable<double> numbers)

Parameters

numbers IEnumerable<double>

Returns

NumbersStatNfo

a tuple containing stat informations about given number set

StringRepresentation(IEnumerable<Vector3D>)

array invariant string vector3d representation "(x1,y1,z2);(x2,y2,z2)"; an array of Vector3D can be rebuilt from string using Vector3D.FromStringArray

public static string StringRepresentation(this IEnumerable<Vector3D> pts)

Parameters

pts IEnumerable<Vector3D>

Returns

string

Sum(IEnumerable<Vector3D>)

retrieve the sum of given vector list

public static Vector3D Sum(this IEnumerable<Vector3D> lst)

Parameters

lst IEnumerable<Vector3D>

vector list

Returns

Vector3D

sum of given vector list

TakeUntilAdjacent(IEnumerable<Line3D>, double, bool)

Return the input set of segments until an adjacency between one and next is found. It can rectify the versus of line (by default) if needed. Note: returned set references can be different if rectifyVersus==true

public static IEnumerable<Line3D> TakeUntilAdjacent(this IEnumerable<Line3D> segs, double tol, bool rectifyVersus = true)

Parameters

segs IEnumerable<Line3D>
tol double
rectifyVersus bool

Returns

IEnumerable<Line3D>

Tessellate(IEnumerable<Vector3D>)

tessellate given pts list using 1 contour in clockwise ordering see used tessellation library ( https://github.com/speps/LibTessDotNet )

public static IEnumerable<Triangle3D> Tessellate(this IEnumerable<Vector3D> _pts)

Parameters

_pts IEnumerable<Vector3D>

pts to tessellate in triangles

Returns

IEnumerable<Triangle3D>

list of triangles

Thin(IEnumerable<double>, double, bool, bool)

retrieve given input set ordered with only distinct values after comparing through tolerance in this case result set contains only values from the input set (default) or rounding to given tol if maintain_original_values is false; if keep_ends true (default) min and max already exists at begin/end of returned sequence

public static List<double> Thin(this IEnumerable<double> input, double tol, bool keep_ends = true, bool maintain_original_values = true)

Parameters

input IEnumerable<double>
tol double
keep_ends bool
maintain_original_values bool

Returns

List<double>

ToArc3D(Arc, Vector3D?, double)

construct arc3 from given dxf arc

public static Arc3D ToArc3D(this Arc dxf_arc, Vector3D? start_vertex = null, double start_vertex_tol = 0)

Parameters

dxf_arc Arc
start_vertex Vector3D

optional start vertex allow to inject edge sense (used when explode from lwpolyline)

start_vertex_tol double

when use start_vertex argument this is the tol for equality test

Returns

Arc3D

ToCSV(IEnumerable<object>)

exports to a csv string some known fields note: not really a csv its a tab separated values for debug purpose just copy and paste

public static string ToCSV(this IEnumerable<object> lst)

Parameters

lst IEnumerable<object>

Returns

string

ToCadScript(IEnumerable<Line3D>)

public static string ToCadScript(this IEnumerable<Line3D> lines)

Parameters

lines IEnumerable<Line3D>

Returns

string

ToCircle3D(Circle)

build circle3d by provided dxf circle

public static Circle3D ToCircle3D(this Circle dxf_circle)

Parameters

dxf_circle Circle

Returns

Circle3D

ToCoordSequence(IEnumerable<Vector3D>)

from a list of vector3d retrieve x1,y1,z1,x2,y2,z2,... coord sequence

public static IEnumerable<double> ToCoordSequence(this IEnumerable<Vector3D> pts)

Parameters

pts IEnumerable<Vector3D>

Returns

IEnumerable<double>

ToCoordString2D(IEnumerable<Vector3D>)

produce a string with x1,y1,x2,y2, ...

public static string ToCoordString2D(this IEnumerable<Vector3D> points)

Parameters

points IEnumerable<Vector3D>

Returns

string

ToCoordString3D(IEnumerable<Vector3D>)

produce a string with x1,y1,z1,x2,y2,z2, ...

public static string ToCoordString3D(this IEnumerable<Vector3D> points)

Parameters

points IEnumerable<Vector3D>

Returns

string

ToDVector3(Vector3)

convert System.Numerics.Vector3 to netdxf.Vector3

public static Vector3 ToDVector3(this Vector3 v)

Parameters

v Vector3

Returns

Vector3

ToDeg(Vector3)

convert given vector to degrees

public static Vector3 ToDeg(this Vector3 v)

Parameters

v Vector3

vector source ( radians )

Returns

Vector3

vector ( degrees )

ToDxfLine(Line3D)

public static Line ToDxfLine(this Line3D line)

Parameters

line Line3D

Returns

Line

ToEulerAngles(Matrix4x4)

extract xyz rotation angles from given rotation matrix. Reference: Extracting Euler Angles from a Rotation Matrix by Mike Day

public static Vector3 ToEulerAngles(this Matrix4x4 rotation)

Parameters

rotation Matrix4x4

rotation matrix

Returns

Vector3

Vector3 with rotation angles(rad) around wcs xyz axes

Remarks

ToFace(Loop)

build face with given outer loop

public static Face ToFace(this Loop loop)

Parameters

loop Loop

Returns

Face

ToFace(IEnumerable<Polyline2D>, double)

build planar face with given loops ( first is the outer ); input loop can be unordered ( loop with greather area will be considered as outer loop ); precondition: loops must lie on same plane

public static Face ToFace(this IEnumerable<Polyline2D> lwpolyline, double tol)

Parameters

lwpolyline IEnumerable<Polyline2D>
tol double

Returns

Face

ToGeometries(Polyline2D, double)

extracs Arc3D, Line3D from given lwpolyline

public static IEnumerable<Geometry> ToGeometries(this Polyline2D lwpolyline, double tol)

Parameters

lwpolyline Polyline2D
tol double

length tolerance

Returns

IEnumerable<Geometry>

ToHatch(IEnumerable<Geometry>, HatchPattern, bool)

public static Hatch ToHatch(this IEnumerable<Geometry> _geom, HatchPattern pattern, bool associative = true)

Parameters

_geom IEnumerable<Geometry>
pattern HatchPattern
associative bool

Returns

Hatch

ToHatch(Polyline2D, HatchPattern, bool)

public static Hatch ToHatch(this Polyline2D lw, HatchPattern pattern, bool associative = true)

Parameters

lw Polyline2D
pattern HatchPattern
associative bool

Returns

Hatch

ToLine3D(Line)

public static Line3D ToLine3D(this Line line)

Parameters

line Line

Returns

Line3D

ToLoop(Polyline2D, double)

public static Loop ToLoop(this Polyline2D lwpolyline, double tol)

Parameters

lwpolyline Polyline2D
tol double

Returns

Loop

ToLwPolyline(IEnumerable<Geometry>, double, CoordinateSystem3D, bool)

build 2d dxf polyline. precondition: geom vertex must lie on the same plane note: use RepeatFirstAtEnd extension to build a closed polyline

public static Polyline2D ToLwPolyline(this IEnumerable<Geometry> _geom, double tol, CoordinateSystem3D cs, bool closed)

Parameters

_geom IEnumerable<Geometry>
tol double

length tolerance

cs CoordinateSystem3D

lw CS

closed bool

Returns

Polyline2D

ToNVector3(Vector3)

convert netdxf.Vector3 to System.Numerics.Vector3 ( double cast to float )

public static Vector3 ToNVector3(this Vector3 v)

Parameters

v Vector3

Returns

Vector3

ToPlane(Polyline2D)

public static Plane3D ToPlane(this Polyline2D lwpolyline)

Parameters

lwpolyline Polyline2D

Returns

Plane3D

ToPolyline(IEnumerable<Vector3D>, bool)

build 3d dxf polyline note: use RepeatFirstAtEnd extension to build a closed polyline

public static Polyline3D ToPolyline(this IEnumerable<Vector3D> pts, bool isClosed = true)

Parameters

pts IEnumerable<Vector3D>
isClosed bool

Returns

Polyline3D

ToRad(Vector3)

convert given vector to radians

public static Vector3 ToRad(this Vector3 v)

Parameters

v Vector3

vector source ( degrees )

Returns

Vector3

vector ( radians )

ToTriangle3D(IEnumerable<Vector3D>)

public static Triangle3D ToTriangle3D(this IEnumerable<Vector3D> pts)

Parameters

pts IEnumerable<Vector3D>

Returns

Triangle3D

ToVector2(Vector4)

create vector2 from vector4 discarding z, w

public static Vector2 ToVector2(this Vector4 v)

Parameters

v Vector4

vector4 input

Returns

Vector2

vector2

ToVector3(Vector4)

create vector3 from vector4 discarding w

public static Vector3 ToVector3(this Vector4 v)

Parameters

v Vector4

vector4 input

Returns

Vector3

vector3

ToVector3D(Vector3)

convert given vector3 to vector3d

public static Vector3D ToVector3D(this Vector3 v)

Parameters

v Vector3

vector3

Returns

Vector3D

vector3d

ToVector3D(Vector4)

convert given Vector4 to Vector3D ( discarding w )

public static Vector3D ToVector3D(this Vector4 v)

Parameters

v Vector4

Vector4

Returns

Vector3D

Vector3D

Transform(Vector3, Matrix4x4)

public static Vector3 Transform(this Vector3 v, Matrix4x4 m)

Parameters

v Vector3
m Matrix4x4

Returns

Vector3

Transform(Vector4, Matrix4x4)

public static Vector4 Transform(this Vector4 v, Matrix4x4 m)

Parameters

v Vector4
m Matrix4x4

Returns

Vector4

Union(IEnumerable<BBox3D>)

union of bboxes

public static BBox3D Union(this IEnumerable<BBox3D> bboxes)

Parameters

bboxes IEnumerable<BBox3D>

Returns

BBox3D

Vector3DCoords(Polyline2D)

enumerate as Vector3D given dxf lwpolyline vertexes

public static IEnumerable<Vector3D> Vector3DCoords(this Polyline2D lwp)

Parameters

lwp Polyline2D

Returns

IEnumerable<Vector3D>

Vector3DCoords(Polyline3D)

enumerate as Vector3D given dxf polyline vertexes

public static IEnumerable<Vector3D> Vector3DCoords(this Polyline3D pl)

Parameters

pl Polyline3D

Returns

IEnumerable<Vector3D>

Vertexes(IEnumerable<Geometry>, double)

vertexes from given set of geometries

public static IEnumerable<Vector3D> Vertexes(this IEnumerable<Geometry> _geometry_block, double tol)

Parameters

_geometry_block IEnumerable<Geometry>
tol double

length tolerance

Returns

IEnumerable<Vector3D>

WeightedDistribution(IEnumerable<double>, int)

retrieve a list of N pairs (value,presence) with value between min and max of inputs and presence between 0..1 that represents the percent of presence of the value

examples:

inputs = ( 1, 2, 3 ), N = 3 results: ( (1, .33), (2, .33), (3, .33) )

inputs = ( 1, 2.49, 3), N = 3 results: ( (1, .33), (2, .169), (3, .497) )

inputs = ( 1, 2, 3), N = 4 results: ( (1, .33), (1.6, .16), (2.3, .16), (3, .33) )

public static (double off, double weight)[] WeightedDistribution(this IEnumerable<double> inputs, int N)

Parameters

inputs IEnumerable<double>
N int

Returns

(double off, double weight)[]

XYArea(IEnumerable<Vector3D>, double)

(abs) Area of a polygon (does not consider z). note: points must ccw ordered. https://en.wikipedia.org/wiki/Centroid

public static double XYArea(this IEnumerable<Vector3D> pts, double tol)

Parameters

pts IEnumerable<Vector3D>
tol double

Returns

double

XYCentroid(IEnumerable<Vector3D>, double)

Centroid of a polygon (does not consider z). note: points must ccw ordered. use overloaded method if signed area already computed. https://en.wikipedia.org/wiki/Centroid

public static Vector3D XYCentroid(this IEnumerable<Vector3D> pts, double tol)

Parameters

pts IEnumerable<Vector3D>
tol double

Returns

Vector3D

XYCentroid(IEnumerable<Vector3D>, double, double)

Centroid of a polygon (does not consider z). note: points must ccw ordered. https://en.wikipedia.org/wiki/Centroid

public static Vector3D XYCentroid(this IEnumerable<Vector3D> _pts, double tol, double signed_area)

Parameters

_pts IEnumerable<Vector3D>
tol double
signed_area double

Returns

Vector3D

XYClosedPolys(IEnumerable<Line3D>, double, int)

build polygons from given list of 2d segments by intersecting segments. (does not consider z)

public static IEnumerable<IReadOnlyList<Vector3D>> XYClosedPolys(this IEnumerable<Line3D> segs, double tol, int polyMaxPoints = 0)

Parameters

segs IEnumerable<Line3D>
tol double
polyMaxPoints int

Returns

IEnumerable<IReadOnlyList<Vector3D>>

XYSignedArea(IEnumerable<Vector3D>, double)

(signed) Area of a polygon (does not consider z); note: points must ccw ordered. https://en.wikipedia.org/wiki/Centroid

public static double XYSignedArea(this IEnumerable<Vector3D> _pts, double tol)

Parameters

_pts IEnumerable<Vector3D>
tol double

Returns

double

ZapDuplicates(IEnumerable<Vector3D>, Vector3DEqualityComparer)

return pts (maintaining order) w/out duplicates

public static IEnumerable<Vector3D> ZapDuplicates(this IEnumerable<Vector3D> pts, Vector3DEqualityComparer cmp)

Parameters

pts IEnumerable<Vector3D>
cmp Vector3DEqualityComparer

Returns

IEnumerable<Vector3D>

ZapDuplicates(IEnumerable<Vector3D>, double)

return pts (maintaining order) w/out duplicates use the other overloaded method if already have a vector 3d equality comparer

public static IEnumerable<Vector3D> ZapDuplicates(this IEnumerable<Vector3D> pts, double tol)

Parameters

pts IEnumerable<Vector3D>
tol double

Returns

IEnumerable<Vector3D>