kornia.geometry.line#
- class kornia.geometry.line.ParametrizedLine(origin, direction)#
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)#
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)
- distance(point)#
Return the distance of a point to its projections onto the line.
- intersect(plane, eps=1e-6)#
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)#
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)
- projection(point)#
Return the projection of a point onto the line.
- squared_distance(point)#
Return the squared distance of a point to its projection onte the line.
- classmethod through(p0, p1)#
Constructs a parametrized line going from a point \(p0\) to \(p1\).
- Parameters:
- Return type:
Example
>>> p0 = torch.tensor([0.0, 0.0]) >>> p1 = torch.tensor([1.0, 1.0]) >>> l = ParametrizedLine.through(p0, p1)
- kornia.geometry.line.fit_line(points, weights=None)#
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(n, d)#