Skip to content

Commit

Permalink
Comment out derivatives_ctrlpts in favor of Issue #35
Browse files Browse the repository at this point in the history
  • Loading branch information
Onur Rauf Bingol committed Jul 29, 2018
1 parent be23539 commit c4013a0
Show file tree
Hide file tree
Showing 4 changed files with 215 additions and 215 deletions.
128 changes: 64 additions & 64 deletions geomdl/BSpline.py
Original file line number Diff line number Diff line change
Expand Up @@ -265,33 +265,33 @@ def derivatives(self, u=-1, order=0):
ctrlpts=self._control_points,
dimension=self._dimension)

# Evaluates the curve derivative control points
def derivatives_ctrlpts(self, order=0, **kwargs):
""" Evaluates the n-th order curve derivative control points.
Keyword arguments:
* ``r1``: minimum span
* ``r2``: maximum span
:param order: derivative order
:type order: integer
:return: a list containing the control points of up to {order}-th derivative of the curve
:rtype: list
"""
# Check all parameters are set before the curve evaluation
self._check_variables()

# Get keyword arguments
r1 = kwargs.get('r1', 0)
r2 = kwargs.get('r2', len(self._control_points) - 1)

# Evaluate and return the derivative control points
return self._evaluator.derivatives_ctrlpts(r1=r1, r2=r2,
deriv_order=order,
degree=self.degree,
knotvector=self.knotvector,
ctrlpts=self._control_points,
dimension=self._dimension)
# # Evaluates the curve derivative control points
# def derivatives_ctrlpts(self, order=0, **kwargs):
# """ Evaluates the n-th order curve derivative control points.
#
# Keyword arguments:
# * ``r1``: minimum span
# * ``r2``: maximum span
#
# :param order: derivative order
# :type order: integer
# :return: a list containing the control points of up to {order}-th derivative of the curve
# :rtype: list
# """
# # Check all parameters are set before the curve evaluation
# self._check_variables()
#
# # Get keyword arguments
# r1 = kwargs.get('r1', 0)
# r2 = kwargs.get('r2', len(self._control_points) - 1)
#
# # Evaluate and return the derivative control points
# return self._evaluator.derivatives_ctrlpts(r1=r1, r2=r2,
# deriv_order=order,
# degree=self.degree,
# knotvector=self.knotvector,
# ctrlpts=self._control_points,
# dimension=self._dimension)

# Evaluates the curve tangent at the given u parameter
def tangent(self, u=-1, normalize=False):
Expand Down Expand Up @@ -1086,43 +1086,43 @@ def derivatives(self, u=-1, v=-1, order=0):
ctrlpts=self._control_points2D,
dimension=self._dimension)

# Evaluates the curve derivative control points
def derivatives_ctrlpts(self, order=0, **kwargs):
""" Evaluates the n-th order surface derivative control points.
Returns a list PKL, where PKL[k][l][i][j] is the {i,j}-th control point of the derivative of the surface S(u,v)
w.r.t u k times and v l times.
Keyword arguments:
* ``r1``: minimum span on the u-direction
* ``r2``: maximum span on the u-direction
* ``s1``: minimum span on the v-direction
* ``s2``: maximum span on the v-direction
:param order: derivative order
:type order: integer
:return: the list PKL (as defined in the description)
:rtype: list
"""
# Check all parameters are set before the surface evaluation
self._check_variables()

# Get keyword arguments
r1 = kwargs.get('r1', 0)
r2 = kwargs.get('r2', self.ctrlpts_size_u - 1)
s1 = kwargs.get('s1', 0)
s2 = kwargs.get('s2', self.ctrlpts_size_v - 1)

# Evaluate and return the derivative control points
return self._evaluator.derivatives_ctrlpts(r1=r1, r2=r2,
s1=s1, s2=s2,
degree_u=self.degree_u, degree_v=self.degree_v,
knotvector_u=self.knotvector_u, knotvector_v=self.knotvector_v,
ctrlpts_size_u=self.ctrlpts_size_u,
ctrlpts_size_v=self.ctrlpts_size_v,
ctrlpts=self._control_points2D,
dimension=self._dimension,
deriv_order=order)
# # Evaluates the curve derivative control points
# def derivatives_ctrlpts(self, order=0, **kwargs):
# """ Evaluates the n-th order surface derivative control points.
#
# Returns a list PKL, where PKL[k][l][i][j] is the {i,j}-th control point of the derivative of the surface S(u,v)
# w.r.t u k times and v l times.
#
# Keyword arguments:
# * ``r1``: minimum span on the u-direction
# * ``r2``: maximum span on the u-direction
# * ``s1``: minimum span on the v-direction
# * ``s2``: maximum span on the v-direction
#
# :param order: derivative order
# :type order: integer
# :return: the list PKL (as defined in the description)
# :rtype: list
# """
# # Check all parameters are set before the surface evaluation
# self._check_variables()
#
# # Get keyword arguments
# r1 = kwargs.get('r1', 0)
# r2 = kwargs.get('r2', self.ctrlpts_size_u - 1)
# s1 = kwargs.get('s1', 0)
# s2 = kwargs.get('s2', self.ctrlpts_size_v - 1)
#
# # Evaluate and return the derivative control points
# return self._evaluator.derivatives_ctrlpts(r1=r1, r2=r2,
# s1=s1, s2=s2,
# degree_u=self.degree_u, degree_v=self.degree_v,
# knotvector_u=self.knotvector_u, knotvector_v=self.knotvector_v,
# ctrlpts_size_u=self.ctrlpts_size_u,
# ctrlpts_size_v=self.ctrlpts_size_v,
# ctrlpts=self._control_points2D,
# dimension=self._dimension,
# deriv_order=order)

# Evaluates the surface tangent vectors at the given (u,v) parameter
def tangent(self, u=-1, v=-1, normalize=False):
Expand Down
76 changes: 38 additions & 38 deletions tests/test_BSpline_Curve2D.py
Original file line number Diff line number Diff line change
Expand Up @@ -177,44 +177,44 @@ def test_bspline_curve2d_eval5():
assert abs(evalpt[1] - res[1]) < GEOMDL_DELTA


def test_bspline_curve2d_deriv_ctrlpts():
test_degree = 3
test_knotvector = [0.0, 0.0, 0.0, 0.0, 0.33, 0.66, 1.0, 1.0, 1.0, 1.0]
test_u = 0.35
test_order = test_degree

# Create a curve instance
curve = OBJECT_INSTANCE()

# Set curve degree
curve.degree = test_degree

# Set control points
curve.ctrlpts = CONTROL_POINTS

# Set knot vector
curve.knotvector = test_knotvector

# Take the derivative
der1 = curve.derivatives(u=test_u, order=test_order)

# Compute control points of the derivative
deriv_ctrlpts = curve.derivatives_ctrlpts(order=test_order - 1)

for k in range(0, test_order):
curvek = OBJECT_INSTANCE()
curvek.degree = test_degree - k

# Cutting out None values in deriv_ctrlpts[k] and excess clamping values in test_knotvector
if k == 0:
curvek.ctrlpts = deriv_ctrlpts[k]
curvek.knotvector = test_knotvector
else:
curvek.ctrlpts = deriv_ctrlpts[k][:-k]
curvek.knotvector = test_knotvector[k:-k]

assert abs(curvek.curvept(test_u)[0] - der1[k][0]) < GEOMDL_DELTA
assert abs(curvek.curvept(test_u)[1] - der1[k][1]) < GEOMDL_DELTA
# def test_bspline_curve2d_deriv_ctrlpts():
# test_degree = 3
# test_knotvector = [0.0, 0.0, 0.0, 0.0, 0.33, 0.66, 1.0, 1.0, 1.0, 1.0]
# test_u = 0.35
# test_order = test_degree
#
# # Create a curve instance
# curve = OBJECT_INSTANCE()
#
# # Set curve degree
# curve.degree = test_degree
#
# # Set control points
# curve.ctrlpts = CONTROL_POINTS
#
# # Set knot vector
# curve.knotvector = test_knotvector
#
# # Take the derivative
# der1 = curve.derivatives(u=test_u, order=test_order)
#
# # Compute control points of the derivative
# deriv_ctrlpts = curve.derivatives_ctrlpts(order=test_order - 1)
#
# for k in range(0, test_order):
# curvek = OBJECT_INSTANCE()
# curvek.degree = test_degree - k
#
# # Cutting out None values in deriv_ctrlpts[k] and excess clamping values in test_knotvector
# if k == 0:
# curvek.ctrlpts = deriv_ctrlpts[k]
# curvek.knotvector = test_knotvector
# else:
# curvek.ctrlpts = deriv_ctrlpts[k][:-k]
# curvek.knotvector = test_knotvector[k:-k]
#
# assert abs(curvek.curvept(test_u)[0] - der1[k][0]) < GEOMDL_DELTA
# assert abs(curvek.curvept(test_u)[1] - der1[k][1]) < GEOMDL_DELTA


def test_bspline_curve2d_deriv1():
Expand Down
78 changes: 39 additions & 39 deletions tests/test_BSpline_Curve3D.py
Original file line number Diff line number Diff line change
Expand Up @@ -161,45 +161,45 @@ def test_bspline_curve3d_bbox():
assert abs(to_check[1][2] - result[1][2]) < GEOMDL_DELTA


def test_bspline_curve3d_deriv_ctrlpts():
test_degree = 4
test_knotvector = [0.0, 0.0, 0.0, 0.0, 0.0, 0.1, 0.3, 0.5, 0.7, 0.9, 1.0, 1.0, 1.0, 1.0, 1.0]
test_u = 0.35
test_order = 3

# Create a curve instance
curve = OBJECT_INSTANCE()

# Set curve degree
curve.degree = test_degree

# Set control points
curve.ctrlpts = CONTROL_POINTS

# Set knot vector
curve.knotvector = test_knotvector

# Take the derivative
der1 = curve.derivatives(u=test_u, order=test_order)

# Compute control points of the derivative
deriv_ctrlpts = curve.derivatives_ctrlpts(order=test_order - 1)

for k in range(0, test_order):
curvek = OBJECT_INSTANCE()
curvek.degree = test_degree - k

# Cutting out None values in deriv_ctrlpts[k] and excess clamping values in test_knotvector
if k == 0:
curvek.ctrlpts = deriv_ctrlpts[k]
curvek.knotvector = test_knotvector
else:
curvek.ctrlpts = deriv_ctrlpts[k][:-k]
curvek.knotvector = test_knotvector[k:-k]

assert abs(curvek.curvept(test_u)[0] - der1[k][0]) < GEOMDL_DELTA
assert abs(curvek.curvept(test_u)[1] - der1[k][1]) < GEOMDL_DELTA
assert abs(curvek.curvept(test_u)[2] - der1[k][2]) < GEOMDL_DELTA
# def test_bspline_curve3d_deriv_ctrlpts():
# test_degree = 4
# test_knotvector = [0.0, 0.0, 0.0, 0.0, 0.0, 0.1, 0.3, 0.5, 0.7, 0.9, 1.0, 1.0, 1.0, 1.0, 1.0]
# test_u = 0.35
# test_order = 3
#
# # Create a curve instance
# curve = OBJECT_INSTANCE()
#
# # Set curve degree
# curve.degree = test_degree
#
# # Set control points
# curve.ctrlpts = CONTROL_POINTS
#
# # Set knot vector
# curve.knotvector = test_knotvector
#
# # Take the derivative
# der1 = curve.derivatives(u=test_u, order=test_order)
#
# # Compute control points of the derivative
# deriv_ctrlpts = curve.derivatives_ctrlpts(order=test_order - 1)
#
# for k in range(0, test_order):
# curvek = OBJECT_INSTANCE()
# curvek.degree = test_degree - k
#
# # Cutting out None values in deriv_ctrlpts[k] and excess clamping values in test_knotvector
# if k == 0:
# curvek.ctrlpts = deriv_ctrlpts[k]
# curvek.knotvector = test_knotvector
# else:
# curvek.ctrlpts = deriv_ctrlpts[k][:-k]
# curvek.knotvector = test_knotvector[k:-k]
#
# assert abs(curvek.curvept(test_u)[0] - der1[k][0]) < GEOMDL_DELTA
# assert abs(curvek.curvept(test_u)[1] - der1[k][1]) < GEOMDL_DELTA
# assert abs(curvek.curvept(test_u)[2] - der1[k][2]) < GEOMDL_DELTA


def test_bspline_curve3d_deriv1():
Expand Down
Loading

0 comments on commit c4013a0

Please sign in to comment.