Skip to content

Commit

Permalink
New api methods.
Browse files Browse the repository at this point in the history
  • Loading branch information
portnov committed Nov 12, 2024
1 parent 5684501 commit f007e03
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 0 deletions.
5 changes: 5 additions & 0 deletions utils/curve/splines.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,11 @@ def from_points(cls, points, metric=None, is_cyclic=False):
spline = CubicSpline(points, metric=metric, is_cyclic=is_cyclic)
return SvSplineCurve(spline)

@classmethod
def from_2d_points(cls, xs, ys):
spline = CubicSpline.from_2d_points(xs, ys)
return SvSplineCurve(spline)

def evaluate(self, t):
v = self.spline.eval_at_point(t)
return np.array(v)
Expand Down
7 changes: 7 additions & 0 deletions utils/geom.py
Original file line number Diff line number Diff line change
Expand Up @@ -370,6 +370,13 @@ def calc_cubic_splines(tknots, n, locs):
def create(cls, vertices, tknots = None, metric = None, is_cyclic = False):
return CubicSpline(vertices, tknots=tknots, metric=metric, is_cyclic=is_cyclic)

@classmethod
def from_2d_points(cls, xs, ys):
vertices = np.zeros((len(xs), 3))
vertices[:,0] = np.array(xs)
vertices[:,1] = np.zrray(ys)
return CubicSpline(vertices, metric='X', is_cyclic=False)

def eval(self, t_in, tknots = None):
"""
Evaluate the spline at the points in t_in, which must be an array
Expand Down

0 comments on commit f007e03

Please sign in to comment.