Linear Approximation¶

Functionality¶
This node tries to approximate provided set of vertices by either a plane or a straight line. In other words, it searches for such a plane / line, that all provided vertices have the minimum distance to it.
More technically, it searches for a plane or a line A, such that

The plane is represented by a point on the plane and a normal vector.
The line is represented by a point on the line and a direction vector.
That point on line or plane is calculated as a geometrical center of all provided vertices.
Inputs¶
This node has one input: Vertices - the vertices to be approximated.
Parameters¶
This node has one parameter - Mode. Two modes are supported:
Line - approximate vertices by straight line. This is the default mode.
Plane - approximate vertices by a plane.
Outputs¶
This node has the following outputs:
Center - the point on the line or plane. This is geometrical center of all input vertices.
Normal - the normal vector of a plane. This output is only available in the Plane mode.
Direction - the direction vector of a line. This output is only available in the Line mode.
Projections - the projections of input vertices to the line or plane.
Diffs - difference vectors between the input vertices and their projections to line or plane.
Distances - distances between the input vertices and their projections to line or plane.




Examples of usage¶
The simplest example: approximate 3D curve by a line. Here black curve is a grease pencil, green one - it’s representation in Sverchok, red line - result of linear approximation of green line.

Generator-> Line
Number-> Number Range
Vector-> Vector Interpolation
Modifiers->Modifier Make-> UV Connection
Viz-> Viewer Draw
A simple example with plane.

Generator-> Plane
Scene-> Objects In Lite
Matrix-> Matrix Track To
Viz-> Viewer Draw
The node can calculate approximation for several sets of vertices at once:

Generator-> Plane
Matrix-> Matrix Track To
Scene-> Objects In Lite
Viz-> Viewer Draw
You can also find more examples and some discussion in the development thread.