Table of Contents

Class Line3D

Namespace
SearchAThing.Sci
Assembly
netcore-sci.dll

Defines a line by an application point (From) and an extension from there (V). To is computed as From+V. Line can be built by givin From and To, or From and V using specialized constructor with Line3DConstructMode. Line can be built from a point using LineTo(), LineV() or LineDir() extension methods.

public class Line3D : Edge
Inheritance
Line3D
Inherited Members
Extension Methods

Constructors

Line3D(Line3D)

build a copy of given line

public Line3D(Line3D l)

Parameters

l Line3D

Line3D(Vector3D, Vector3D)

build segment

public Line3D(Vector3D from, Vector3D to)

Parameters

from Vector3D
to Vector3D

Line3D(Vector3D, Vector3D, Line3DConstructMode)

build segment from plus the given vector form to

public Line3D(Vector3D from, Vector3D v, Line3DConstructMode mode)

Parameters

from Vector3D
v Vector3D
mode Line3DConstructMode

Line3D(double, double, double, double)

z=0

public Line3D(double x1, double y1, double x2, double y2)

Parameters

x1 double
y1 double
x2 double
y2 double

Line3D(double, double, double, double, double, double)

public Line3D(double x1, double y1, double z1, double x2, double y2, double z2)

Parameters

x1 double
y1 double
z1 double
x2 double
y2 double
z2 double

Fields

XAxisLine

public static readonly Line3D XAxisLine

Field Value

Line3D

YAxisLine

public static readonly Line3D YAxisLine

Field Value

Line3D

ZAxisLine

public static readonly Line3D ZAxisLine

Field Value

Line3D

Properties

A0ProgeCadScript

public string A0ProgeCadScript { get; }

Property Value

string

A0QCadScript

public string A0QCadScript { get; }

Property Value

string

CadScript

public string CadScript { get; }

Property Value

string

Dir

V normalized

public Vector3D Dir { get; }

Property Value

Vector3D

DisambiguatedPoints

retrieve a unique endpoint representation of this line3d segment (regardless its from-to or to-from order) such that From.Distance(Vector3D.Zero) less than To.Distance(Vector3D.Zero)

public IEnumerable<Vector3D> DisambiguatedPoints { get; }

Property Value

IEnumerable<Vector3D>

DxfEntity

dxf entity representing this geom

public override EntityObject DxfEntity { get; }

Property Value

EntityObject

From

application point vector

public Vector3D From { get; }

Property Value

Vector3D

GeomFrom

start point

[JsonIgnore]
public override Vector3D GeomFrom { get; }

Property Value

Vector3D

GeomTo

end point

[JsonIgnore]
public override Vector3D GeomTo { get; }

Property Value

Vector3D

Inverted

return inverted segment

public Line3D Inverted { get; }

Property Value

Line3D

Length

geometry length ( 0 for point, line length for lines, perimeter for arc/circles )

public override double Length { get; }

Property Value

double

MidPoint

public override Vector3D MidPoint { get; }

Property Value

Vector3D

Points

public IEnumerable<Vector3D> Points { get; }

Property Value

IEnumerable<Vector3D>

Swapped

return segment with swapped from,to

public Line3D Swapped { get; }

Property Value

Line3D

To

From + V

public Vector3D To { get; }

Property Value

Vector3D

V

vector depart at From to identify To

public Vector3D V { get; }

Property Value

Vector3D

Vertexes

vertexes of this geom ( can be 1 for points, 2 for line/arc/circles )

[JsonIgnore]
public override IEnumerable<Vector3D> Vertexes { get; }

Property Value

IEnumerable<Vector3D>

Methods

ApparentIntersect(Line3D)

Find apparent intersection between this and given other line returning (shortest) segment perpendicular to either lines or null if lines parallels. This method will used from Intersect to find intersection between lines when perpendicular segment length not exceed given length tolerance.

public Line3D? ApparentIntersect(Line3D other)

Parameters

other Line3D

other 3d line

Returns

Line3D

Perp segment from(on this), to(on other).

Remarks

BBox(double)

bbox of this geom

public override BBox3D BBox(double tol)

Parameters

tol double

Returns

BBox3D

Bisect(double, Line3D, Vector3D?)

returns bisect of two given segment/lines ( if given segment not share nodes but intesects returned bisect start from ip ) bisect choosen will be the one between this and other withing shortest angle

if two given lines are parallel and parallelRotationAxis is given then bisect results as this segment rotated PI/2 about given axis using To as rotcenter

public Line3D? Bisect(double tol, Line3D other, Vector3D? parallelRotationAxis = null)

Parameters

tol double

length tolerance

other Line3D
parallelRotationAxis Vector3D

Returns

Line3D

Colinear(double, Line3D)

public bool Colinear(double tol, Line3D other)

Parameters

tol double
other Line3D

Returns

bool

CommonPoint(double, Line3D)

returns the common point from,to between two lines or null if not consecutives

public Vector3D? CommonPoint(double tol, Line3D other)

Parameters

tol double
other Line3D

Returns

Vector3D

Copy()

create copy of this geometry.

public override Geometry Copy()

Returns

Geometry

Remarks

it's required to call base.CopyFrom(other) to ensure geometry properties to be copied.

Divide(int, bool)

find split points for this geometry splitter int cnt parts

public override IEnumerable<Vector3D> Divide(int cnt, bool include_endpoints = false)

Parameters

cnt int
include_endpoints bool

if true GeomFrom and GeomTo will added

Returns

IEnumerable<Vector3D>

EdgeContainsPoint(double, Vector3D)

States if edge contains given point on its perimeter

public override bool EdgeContainsPoint(double tol, Vector3D pt)

Parameters

tol double
pt Vector3D

Returns

bool

EdgeMove(Vector3D)

public Edge EdgeMove(Vector3D delta)

Parameters

delta Vector3D

Returns

Edge

EnsureFrom(double, Vector3D)

if this segment from matches the given point returns this; if this segment to matches the given point return this with from,to swapped; precondition: this segment must have from or to equals given from

public Line3D EnsureFrom(double tol, Vector3D ptFromDesired)

Parameters

tol double

length tolerance

ptFromDesired Vector3D

Returns

Line3D

EqualsTol(double, Line3D, bool)

Checks if two lines are equals

public bool EqualsTol(double tol, Line3D other, bool strict = false)

Parameters

tol double

length tolerance

other Line3D

other line

strict bool

if false(default) two line equals even with swapped from,to

Returns

bool

GeomEquals(double, Geometry, bool)

states if this geom equals to given other

public override bool GeomEquals(double tol, Geometry other, bool checkSense = false)

Parameters

tol double

length tolerance

other Geometry

other geom

checkSense bool

if false two geometry with different sense but same space coverage are considered equals

Returns

bool

GeomIntersect(double, Geometry, GeomSegmentMode, GeomSegmentMode)

find intersections between this and another geometry resulting in zero or more geometries.

public override IEnumerable<Geometry> GeomIntersect(double tol, Geometry _other, GeomSegmentMode thisSegmentMode = GeomSegmentMode.FromTo, GeomSegmentMode otherSegmentMode = GeomSegmentMode.FromTo)

Parameters

tol double
_other Geometry
thisSegmentMode GeomSegmentMode

if this is Line3D specifies how to consider

otherSegmentMode GeomSegmentMode

if other is Line3D specifies how to consider

Returns

IEnumerable<Geometry>

Intersect(double, CoordinateSystem3D)

returns null if this line is parallel to the cs xy plane, the intersection point otherwise

public Vector3D? Intersect(double tol, CoordinateSystem3D cs)

Parameters

tol double
cs CoordinateSystem3D

Returns

Vector3D

Intersect(double, Line3D, GeomSegmentMode, GeomSegmentMode)

Intersects two lines with arbitrary segment mode for each.

public Vector3D? Intersect(double tol, Line3D other, GeomSegmentMode thisSegmentMode, GeomSegmentMode otherSegmentMode)

Parameters

tol double
other Line3D
thisSegmentMode GeomSegmentMode
otherSegmentMode GeomSegmentMode

Returns

Vector3D

Intersect(double, Line3D, LineIntersectBehavior)

Find intersection point between this and other line using given tolerance. Returns null if no intersection, otherwise it returns a point on the shortest segment ( the one that's perpendicular to either lines ) based on given behavior ( default midpoint ).

public Vector3D? Intersect(double tol, Line3D other, LineIntersectBehavior behavior = LineIntersectBehavior.MidPoint)

Parameters

tol double
other Line3D
behavior LineIntersectBehavior

Returns

Vector3D

Intersect(double, Line3D, bool, bool)

Intersects two lines with arbitrary segment mode for each.

public Vector3D? Intersect(double tol, Line3D other, bool thisSegment, bool otherSegment)

Parameters

tol double
other Line3D
thisSegment bool
otherSegment bool

Returns

Vector3D

Intersect(double, Plane3D)

returns null if this line is parallel to the plane, the intersection point otherwise

public Vector3D? Intersect(double tol, Plane3D plane)

Parameters

tol double
plane Plane3D

Returns

Vector3D

IsParallelTo(double, CoordinateSystem3D)

public bool IsParallelTo(double tol, CoordinateSystem3D cs)

Parameters

tol double
cs CoordinateSystem3D

Returns

bool

IsParallelTo(double, Plane3D)

public bool IsParallelTo(double tol, Plane3D plane)

Parameters

tol double
plane Plane3D

Returns

bool

LineContainsPoint(double, Vector3D, bool, bool)

Infinite line contains point.

public bool LineContainsPoint(double tol, Vector3D p, bool segmentMode = false, bool excludeExtreme = false)

Parameters

tol double
p Vector3D
segmentMode bool
excludeExtreme bool

Returns

bool

LineContainsPoint(double, double, double, double, bool)

Infinite line contains point. Note: tol must be Constant.NormalizedLengthTolerance if comparing normalized vectors

public bool LineContainsPoint(double tol, double x, double y, double z, bool segmentMode = false)

Parameters

tol double
x double
y double
z double
segmentMode bool

Returns

bool

Move(Vector3D)

move this segment of given delta

public override Geometry Move(Vector3D delta)

Parameters

delta Vector3D

Returns

Geometry

MoveEnd(double, EdgeEnd, Vector3D)

extends edge endpoint toward new given one.
returns null if edge can't extends toward new given end.

public override Edge? MoveEnd(double tol, EdgeEnd end, Vector3D newEnd)

Parameters

tol double
end EdgeEnd
newEnd Vector3D

Returns

Edge

MoveMidpoint(Vector3D)

Move this segment midpoint to the given coord

public Line3D MoveMidpoint(Vector3D newMidpoint)

Parameters

newMidpoint Vector3D

Returns

Line3D

Normalized()

build a segment with same from and vector normalized

public Line3D Normalized()

Returns

Line3D

Offset(double, Vector3D, double)

create offseted line toward refPt for given offset

public override Edge Offset(double tol, Vector3D refPt, double offset)

Parameters

tol double
refPt Vector3D
offset double

Returns

Edge

Perpendicular(double, Vector3D)

Build a perpendicular vector to this one starting from the given point p.

public Line3D? Perpendicular(double tol, Vector3D p)

Parameters

tol double
p Vector3D

Returns

Line3D

ProgeCadScript(bool)

public override string ProgeCadScript(bool final = true)

Parameters

final bool

Returns

string

Project(double, Plane3D)

project this line to given projection plane

public override Edge Project(double tol, Plane3D prjPlane)

Parameters

tol double
prjPlane Plane3D

Returns

Edge

Project(double, Vector3D, bool)

project given pt to this line

public override Vector3D? Project(double tol, Vector3D pt, bool segment_mode = true)

Parameters

tol double
pt Vector3D
segment_mode bool

Returns

Vector3D

QCadScript(bool)

2d qcad script representation ( vscode watch using var,nq )

public override string QCadScript(bool final = true)

Parameters

final bool

Returns

string

Reverse()

return the segment with swapped from,to

public Line3D Reverse()

Returns

Line3D

RotateAboutAxis(Line3D, double)

rotate this segment about given axis

public Line3D RotateAboutAxis(Line3D axisSegment, double angleRad)

Parameters

axisSegment Line3D
angleRad double

Returns

Line3D

Scale(Vector3D, double)

scale from,to of this line using given refpt and factor

public Line3D Scale(Vector3D refpt, double factor)

Parameters

refpt Vector3D
factor double

Returns

Line3D

Scale(double)

scale from,to of this line using given factor and assuming refpt = MidPoint

public Line3D Scale(double factor)

Parameters

factor double

factor to scale this segment

Returns

Line3D

scaled segment

Remarks

SegmentContainsPoint(double, Vector3D, bool)

Finite segment contains point. Note: tol must be Constant.NormalizedLengthTolerance if comparing normalized vectors

public bool SegmentContainsPoint(double tol, Vector3D p, bool excludeExtreme = false)

Parameters

tol double
p Vector3D
excludeExtreme bool

Returns

bool

SegmentContainsPoint(double, double, double, double)

Finite segment contains point. Note: tol must be Constant.NormalizedLengthTolerance if comparing normalized vectors

public bool SegmentContainsPoint(double tol, double x, double y, double z)

Parameters

tol double
x double
y double
z double

Returns

bool

SemiLineContainsPoint(double, Vector3D)

states if semiline From-To(inf) contains given point

public bool SemiLineContainsPoint(double tol, Vector3D p)

Parameters

tol double

len tolerance

p Vector3D

point to verify is it on semiline

Returns

bool

SetLength(double)

resize this segment to a new one with same From

public Line3D SetLength(double len)

Parameters

len double

Returns

Line3D

Split(double, IEnumerable<Vector3D>)

Split current segment into one or more depending on which of given split points was found on the segment.

public override IEnumerable<Geometry> Split(double tol, IEnumerable<Vector3D> breaks)

Parameters

tol double

length tolerance

breaks IEnumerable<Vector3D>

break points

Returns

IEnumerable<Geometry>

splitted segments starts from begin of line

ToString()

build an invariant string representation w/3 digits (f.x, f.y, f.z)-(t.x, t.y, t.z) L=len Δ=(v.x, v.y, v.z)

public override string ToString()

Returns

string

ToString(int)

build an invariant string representation w/given digits (f.x, f.y, f.z)-(t.x, t.y, t.z) L=len Δ=(v.x, v.y, v.z)

public override string ToString(int digits = 3)

Parameters

digits int

Returns

string

ToStringTol(double)

hash string with given tolerance

public string ToStringTol(double tol)

Parameters

tol double

Returns

string

ToggleSense()

public Line3D ToggleSense()

Returns

Line3D

Transform(Matrix4x4)

public Line3D Transform(Matrix4x4 transform)

Parameters

transform Matrix4x4

Returns

Line3D

Operators

operator +(Line3D, Vector3D)

Move this line of given delta adding value either at From, To

public static Line3D operator +(Line3D l, Vector3D delta)

Parameters

l Line3D
delta Vector3D

Returns

Line3D

operator *(Line3D, double)

multiply Length by given scalar factor Note : this will change To

public static Line3D operator *(Line3D l, double s)

Parameters

l Line3D
s double

Returns

Line3D

operator *(double, Line3D)

multiply Length by given scalar factor Note : this will change To

public static Line3D operator *(double s, Line3D l)

Parameters

s double
l Line3D

Returns

Line3D

operator -(Line3D, Vector3D)

Move this line of given delta subtracting value either at From, To

public static Line3D operator -(Line3D l, Vector3D delta)

Parameters

l Line3D
delta Vector3D

Returns

Line3D