kornia.geometry.line#
- class kornia.geometry.line.ParametrizedLine(origin, direction)[source]#
Class that describes a parametrize line.
A parametrized line is defined by an origin point \(o\) and a unit direction vector \(d\) such that the line corresponds to the set
\[l(t) = o + t * d\]- __init__(origin, direction)[source]#
Initializes a parametrized line of direction and origin.
- Parameters
Example
>>> o = torch.tensor([0.0, 0.0]) >>> d = torch.tensor([1.0, 1.0]) >>> l = ParametrizedLine(o, d)
- point_at(t)[source]#
The point at \(t\) along this line.
- Parameters
- Return type
- Returns
tensor with the point.
Example
>>> p0 = torch.tensor([0.0, 0.0]) >>> p1 = torch.tensor([1.0, 1.0]) >>> l = ParametrizedLine.through(p0, p1) >>> p2 = l.point_at(0.1)
- squared_distance(point)[source]#
Return the squared distance of a point to its projection onte the line.
- classmethod through(p0, p1)[source]#
Constructs a parametrized line going from a point \(p0\) to \(p1\).
- Parameters
p0 – tensor with first point \((B, D)\) where D is the point dimension.
p1 – tensor with second point \((B, D)\) where D is the point dimension.
Example
>>> p0 = torch.tensor([0.0, 0.0]) >>> p1 = torch.tensor([1.0, 1.0]) >>> l = ParametrizedLine.through(p0, p1)
- Return type
- kornia.geometry.line.fit_line(points, weights=None)[source]#
Fit a line from a set of points.
- Parameters
- Return type
- Returns
A tensor containing the direction of the fited line of shape \((B,D)\).
Example
>>> points = torch.rand(2, 10, 3) >>> weights = torch.ones(2, 10) >>> line = fit_line(points, weights) >>> line.direction.shape torch.Size([2, 3])
- class kornia.geometry.line.Hyperplane[source]#
Not implemented yet: https://gitlab.com/libeigen/eigen/-/blob/master/Eigen/src/Geometry/Hyperplane.h.