lstsq fix in circle fitting for old PyTorch

Summary: the pytorch3d.compat.lstsq function needs a 2D rhs.

Reviewed By: patricklabatut

Differential Revision: D36195826

fbshipit-source-id: 9dbafea2057035cc04973f56729dc97b47dcac83
This commit is contained in:
Jeremy Reizenstein 2022-05-06 04:12:51 -07:00 committed by Facebook GitHub Bot
parent 44ca5f95d9
commit 44cb00e468

View File

@ -106,9 +106,9 @@ def fit_circle_in_2d(
n_provided = points2d.shape[0]
if n_provided < 3:
raise ValueError(f"{n_provided} points are not enough to determine a circle")
solution = lstsq(design, rhs)
center = solution[:2] / 2
radius = torch.sqrt(solution[2] + (center ** 2).sum())
solution = lstsq(design, rhs[:, None])
center = solution[:2, 0] / 2
radius = torch.sqrt(solution[2, 0] + (center ** 2).sum())
if n_points > 0:
if angles is not None:
warnings.warn("n_points ignored because angles provided")