Commit 44cb00e4 authored by Jeremy Reizenstein's avatar Jeremy Reizenstein Committed by Facebook GitHub Bot
Browse files

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
parent 44ca5f95
...@@ -106,9 +106,9 @@ def fit_circle_in_2d( ...@@ -106,9 +106,9 @@ def fit_circle_in_2d(
n_provided = points2d.shape[0] n_provided = points2d.shape[0]
if n_provided < 3: if n_provided < 3:
raise ValueError(f"{n_provided} points are not enough to determine a circle") raise ValueError(f"{n_provided} points are not enough to determine a circle")
solution = lstsq(design, rhs) solution = lstsq(design, rhs[:, None])
center = solution[:2] / 2 center = solution[:2, 0] / 2
radius = torch.sqrt(solution[2] + (center ** 2).sum()) radius = torch.sqrt(solution[2, 0] + (center ** 2).sum())
if n_points > 0: if n_points > 0:
if angles is not None: if angles is not None:
warnings.warn("n_points ignored because angles provided") warnings.warn("n_points ignored because angles provided")
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment