Back to Adaptive Vision Library website

You are here: Start » Function Reference » Geometry 2D » Geometry 2D Fitting » FitLineToPoints


Header: AVL.h
Namespace: avl
Module: FoundationBasic

Approximates points with a line using the Least Squares method.


void avl::FitLineToPoints
	const atl::Array<avl::Point2D>& inPoints,
	atl::Optional<const avl::Range&> inRange,
	avl::Line2D& outLine,
	atl::Optional<float&> outError = atl::NIL


Name Type Default Description
inPoints const Array<Point2D>&
inRange Optional<const Range&> NIL Determines which array points take part in fitting process
outLine Line2D&
outError Optional<float&> NIL Sum of the point distances from the output line

Optional Outputs

The computation of following outputs can be switched off by passing value atl::NIL to these parameters: outError.

Read more about Optional Outputs.


The resulting outLine drawn with the input points.


List of possible exceptions:

Error type Description
DomainError Empty array of points in FitLineToPoints.
DomainError Range exceeds the input point array in FitLineToPoints.