Back to FabImage Library website

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

FitLineToPoints


Header: FIL.h
Namespace: fil
Module: FoundationBasic

Approximates points with a line using the Least Squares method.

Syntax

C++
C#
 
void fil::FitLineToPoints
(
	const ftl::Array<fil::Point2D>& inPoints,
	ftl::Optional<const fil::Range&> inRange,
	fil::Line2D& outLine,
	ftl::Optional<float&> outError = ftl::NIL
)

Parameters

Name Type Default Description
Input value inPoints const Array<Point2D>&
Input value inRange Optional<const Range&> NIL Determines which array points take part in fitting process
Output value outLine Line2D&
Output value 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 ftl::NIL to these parameters: outError.

Read more about Optional Outputs.

Examples

The resulting outLine drawn with the input points.

Errors

List of possible exceptions:

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