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)
- intersect(plane, eps=1e-6)[source]#
Return the intersection point between the line and a given plane.
- Parameters:
plane (
Hyperplane
) – the plane to compute the intersection point.- Return type:
- Returns:
the lambda value used to compute the look at point.
the intersected point.
- 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.
- 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])