id int32 0 252k | repo stringlengths 7 55 | path stringlengths 4 127 | func_name stringlengths 1 88 | original_string stringlengths 75 19.8k | language stringclasses 1
value | code stringlengths 51 19.8k | code_tokens list | docstring stringlengths 3 17.3k | docstring_tokens list | sha stringlengths 40 40 | url stringlengths 87 242 |
|---|---|---|---|---|---|---|---|---|---|---|---|
244,100 | orbingol/NURBS-Python | setup.py | copy_files | def copy_files(src, ext, dst):
""" Copies files with extensions "ext" from "src" to "dst" directory. """
src_path = os.path.join(os.path.dirname(__file__), src)
dst_path = os.path.join(os.path.dirname(__file__), dst)
file_list = os.listdir(src_path)
for f in file_list:
if f == '__init__.py'... | python | def copy_files(src, ext, dst):
src_path = os.path.join(os.path.dirname(__file__), src)
dst_path = os.path.join(os.path.dirname(__file__), dst)
file_list = os.listdir(src_path)
for f in file_list:
if f == '__init__.py':
continue
f_path = os.path.join(src_path, f)
if os... | [
"def",
"copy_files",
"(",
"src",
",",
"ext",
",",
"dst",
")",
":",
"src_path",
"=",
"os",
".",
"path",
".",
"join",
"(",
"os",
".",
"path",
".",
"dirname",
"(",
"__file__",
")",
",",
"src",
")",
"dst_path",
"=",
"os",
".",
"path",
".",
"join",
... | Copies files with extensions "ext" from "src" to "dst" directory. | [
"Copies",
"files",
"with",
"extensions",
"ext",
"from",
"src",
"to",
"dst",
"directory",
"."
] | b1c6a8b51cf143ff58761438e93ba6baef470627 | https://github.com/orbingol/NURBS-Python/blob/b1c6a8b51cf143ff58761438e93ba6baef470627/setup.py#L155-L165 |
244,101 | orbingol/NURBS-Python | setup.py | make_dir | def make_dir(project):
""" Creates the project directory for compiled modules. """
project_path = os.path.join(os.path.dirname(__file__), project)
# Delete the directory and the files inside it
if os.path.exists(project_path):
shutil.rmtree(project_path)
# Create the directory
os.mkdir(p... | python | def make_dir(project):
project_path = os.path.join(os.path.dirname(__file__), project)
# Delete the directory and the files inside it
if os.path.exists(project_path):
shutil.rmtree(project_path)
# Create the directory
os.mkdir(project_path)
# We need a __init__.py file inside the directo... | [
"def",
"make_dir",
"(",
"project",
")",
":",
"project_path",
"=",
"os",
".",
"path",
".",
"join",
"(",
"os",
".",
"path",
".",
"dirname",
"(",
"__file__",
")",
",",
"project",
")",
"# Delete the directory and the files inside it",
"if",
"os",
".",
"path",
... | Creates the project directory for compiled modules. | [
"Creates",
"the",
"project",
"directory",
"for",
"compiled",
"modules",
"."
] | b1c6a8b51cf143ff58761438e93ba6baef470627 | https://github.com/orbingol/NURBS-Python/blob/b1c6a8b51cf143ff58761438e93ba6baef470627/setup.py#L168-L180 |
244,102 | orbingol/NURBS-Python | setup.py | in_argv | def in_argv(arg_list):
""" Checks if any of the elements of the input list is in sys.argv array. """
for arg in sys.argv:
for parg in arg_list:
if parg == arg or arg.startswith(parg):
return True
return False | python | def in_argv(arg_list):
for arg in sys.argv:
for parg in arg_list:
if parg == arg or arg.startswith(parg):
return True
return False | [
"def",
"in_argv",
"(",
"arg_list",
")",
":",
"for",
"arg",
"in",
"sys",
".",
"argv",
":",
"for",
"parg",
"in",
"arg_list",
":",
"if",
"parg",
"==",
"arg",
"or",
"arg",
".",
"startswith",
"(",
"parg",
")",
":",
"return",
"True",
"return",
"False"
] | Checks if any of the elements of the input list is in sys.argv array. | [
"Checks",
"if",
"any",
"of",
"the",
"elements",
"of",
"the",
"input",
"list",
"is",
"in",
"sys",
".",
"argv",
"array",
"."
] | b1c6a8b51cf143ff58761438e93ba6baef470627 | https://github.com/orbingol/NURBS-Python/blob/b1c6a8b51cf143ff58761438e93ba6baef470627/setup.py#L183-L189 |
244,103 | orbingol/NURBS-Python | geomdl/knotvector.py | generate | def generate(degree, num_ctrlpts, **kwargs):
""" Generates an equally spaced knot vector.
It uses the following equality to generate knot vector: :math:`m = n + p + 1`
where;
* :math:`p`, degree
* :math:`n + 1`, number of control points
* :math:`m + 1`, number of knots
Keyword Arguments:... | python | def generate(degree, num_ctrlpts, **kwargs):
if degree == 0 or num_ctrlpts == 0:
raise ValueError("Input values should be different than zero.")
# Get keyword arguments
clamped = kwargs.get('clamped', True)
# Number of repetitions at the start and end of the array
num_repeat = degree
... | [
"def",
"generate",
"(",
"degree",
",",
"num_ctrlpts",
",",
"*",
"*",
"kwargs",
")",
":",
"if",
"degree",
"==",
"0",
"or",
"num_ctrlpts",
"==",
"0",
":",
"raise",
"ValueError",
"(",
"\"Input values should be different than zero.\"",
")",
"# Get keyword arguments",
... | Generates an equally spaced knot vector.
It uses the following equality to generate knot vector: :math:`m = n + p + 1`
where;
* :math:`p`, degree
* :math:`n + 1`, number of control points
* :math:`m + 1`, number of knots
Keyword Arguments:
* ``clamped``: Flag to choose from clamped ... | [
"Generates",
"an",
"equally",
"spaced",
"knot",
"vector",
"."
] | b1c6a8b51cf143ff58761438e93ba6baef470627 | https://github.com/orbingol/NURBS-Python/blob/b1c6a8b51cf143ff58761438e93ba6baef470627/geomdl/knotvector.py#L15-L65 |
244,104 | orbingol/NURBS-Python | geomdl/knotvector.py | check | def check(degree, knot_vector, num_ctrlpts):
""" Checks the validity of the input knot vector.
Please refer to The NURBS Book (2nd Edition), p.50 for details.
:param degree: degree of the curve or the surface
:type degree: int
:param knot_vector: knot vector to be checked
:type knot_vector: li... | python | def check(degree, knot_vector, num_ctrlpts):
try:
if knot_vector is None or len(knot_vector) == 0:
raise ValueError("Input knot vector cannot be empty")
except TypeError as e:
print("An error occurred: {}".format(e.args[-1]))
raise TypeError("Knot vector must be a list or tup... | [
"def",
"check",
"(",
"degree",
",",
"knot_vector",
",",
"num_ctrlpts",
")",
":",
"try",
":",
"if",
"knot_vector",
"is",
"None",
"or",
"len",
"(",
"knot_vector",
")",
"==",
"0",
":",
"raise",
"ValueError",
"(",
"\"Input knot vector cannot be empty\"",
")",
"e... | Checks the validity of the input knot vector.
Please refer to The NURBS Book (2nd Edition), p.50 for details.
:param degree: degree of the curve or the surface
:type degree: int
:param knot_vector: knot vector to be checked
:type knot_vector: list, tuple
:param num_ctrlpts: number of control p... | [
"Checks",
"the",
"validity",
"of",
"the",
"input",
"knot",
"vector",
"."
] | b1c6a8b51cf143ff58761438e93ba6baef470627 | https://github.com/orbingol/NURBS-Python/blob/b1c6a8b51cf143ff58761438e93ba6baef470627/geomdl/knotvector.py#L99-L133 |
244,105 | orbingol/NURBS-Python | geomdl/fitting.py | interpolate_curve | def interpolate_curve(points, degree, **kwargs):
""" Curve interpolation through the data points.
Please refer to Algorithm A9.1 on The NURBS Book (2nd Edition), pp.369-370 for details.
Keyword Arguments:
* ``centripetal``: activates centripetal parametrization method. *Default: False*
:param... | python | def interpolate_curve(points, degree, **kwargs):
# Keyword arguments
use_centripetal = kwargs.get('centripetal', False)
# Number of control points
num_points = len(points)
# Get uk
uk = compute_params_curve(points, use_centripetal)
# Compute knot vector
kv = compute_knot_vector(degree... | [
"def",
"interpolate_curve",
"(",
"points",
",",
"degree",
",",
"*",
"*",
"kwargs",
")",
":",
"# Keyword arguments",
"use_centripetal",
"=",
"kwargs",
".",
"get",
"(",
"'centripetal'",
",",
"False",
")",
"# Number of control points",
"num_points",
"=",
"len",
"("... | Curve interpolation through the data points.
Please refer to Algorithm A9.1 on The NURBS Book (2nd Edition), pp.369-370 for details.
Keyword Arguments:
* ``centripetal``: activates centripetal parametrization method. *Default: False*
:param points: data points
:type points: list, tuple
:p... | [
"Curve",
"interpolation",
"through",
"the",
"data",
"points",
"."
] | b1c6a8b51cf143ff58761438e93ba6baef470627 | https://github.com/orbingol/NURBS-Python/blob/b1c6a8b51cf143ff58761438e93ba6baef470627/geomdl/fitting.py#L16-L53 |
244,106 | orbingol/NURBS-Python | geomdl/fitting.py | interpolate_surface | def interpolate_surface(points, size_u, size_v, degree_u, degree_v, **kwargs):
""" Surface interpolation through the data points.
Please refer to the Algorithm A9.4 on The NURBS Book (2nd Edition), pp.380 for details.
Keyword Arguments:
* ``centripetal``: activates centripetal parametrization meth... | python | def interpolate_surface(points, size_u, size_v, degree_u, degree_v, **kwargs):
# Keyword arguments
use_centripetal = kwargs.get('centripetal', False)
# Get uk and vl
uk, vl = compute_params_surface(points, size_u, size_v, use_centripetal)
# Compute knot vectors
kv_u = compute_knot_vector(degre... | [
"def",
"interpolate_surface",
"(",
"points",
",",
"size_u",
",",
"size_v",
",",
"degree_u",
",",
"degree_v",
",",
"*",
"*",
"kwargs",
")",
":",
"# Keyword arguments",
"use_centripetal",
"=",
"kwargs",
".",
"get",
"(",
"'centripetal'",
",",
"False",
")",
"# G... | Surface interpolation through the data points.
Please refer to the Algorithm A9.4 on The NURBS Book (2nd Edition), pp.380 for details.
Keyword Arguments:
* ``centripetal``: activates centripetal parametrization method. *Default: False*
:param points: data points
:type points: list, tuple
... | [
"Surface",
"interpolation",
"through",
"the",
"data",
"points",
"."
] | b1c6a8b51cf143ff58761438e93ba6baef470627 | https://github.com/orbingol/NURBS-Python/blob/b1c6a8b51cf143ff58761438e93ba6baef470627/geomdl/fitting.py#L57-L112 |
244,107 | orbingol/NURBS-Python | geomdl/fitting.py | compute_knot_vector | def compute_knot_vector(degree, num_points, params):
""" Computes a knot vector from the parameter list using averaging method.
Please refer to the Equation 9.8 on The NURBS Book (2nd Edition), pp.365 for details.
:param degree: degree
:type degree: int
:param num_points: number of data points
... | python | def compute_knot_vector(degree, num_points, params):
# Start knot vector
kv = [0.0 for _ in range(degree + 1)]
# Use averaging method (Eqn 9.8) to compute internal knots in the knot vector
for i in range(num_points - degree - 1):
temp_kv = (1.0 / degree) * sum([params[j] for j in range(i + 1, i... | [
"def",
"compute_knot_vector",
"(",
"degree",
",",
"num_points",
",",
"params",
")",
":",
"# Start knot vector",
"kv",
"=",
"[",
"0.0",
"for",
"_",
"in",
"range",
"(",
"degree",
"+",
"1",
")",
"]",
"# Use averaging method (Eqn 9.8) to compute internal knots in the kn... | Computes a knot vector from the parameter list using averaging method.
Please refer to the Equation 9.8 on The NURBS Book (2nd Edition), pp.365 for details.
:param degree: degree
:type degree: int
:param num_points: number of data points
:type num_points: int
:param params: list of parameters,... | [
"Computes",
"a",
"knot",
"vector",
"from",
"the",
"parameter",
"list",
"using",
"averaging",
"method",
"."
] | b1c6a8b51cf143ff58761438e93ba6baef470627 | https://github.com/orbingol/NURBS-Python/blob/b1c6a8b51cf143ff58761438e93ba6baef470627/geomdl/fitting.py#L358-L383 |
244,108 | orbingol/NURBS-Python | geomdl/fitting.py | ginterp | def ginterp(coeff_matrix, points):
""" Applies global interpolation to the set of data points to find control points.
:param coeff_matrix: coefficient matrix
:type coeff_matrix: list, tuple
:param points: data points
:type points: list, tuple
:return: control points
:rtype: list
"""
... | python | def ginterp(coeff_matrix, points):
# Dimension
dim = len(points[0])
# Number of data points
num_points = len(points)
# Solve system of linear equations
matrix_l, matrix_u = linalg.lu_decomposition(coeff_matrix)
ctrlpts = [[0.0 for _ in range(dim)] for _ in range(num_points)]
for i in r... | [
"def",
"ginterp",
"(",
"coeff_matrix",
",",
"points",
")",
":",
"# Dimension",
"dim",
"=",
"len",
"(",
"points",
"[",
"0",
"]",
")",
"# Number of data points",
"num_points",
"=",
"len",
"(",
"points",
")",
"# Solve system of linear equations",
"matrix_l",
",",
... | Applies global interpolation to the set of data points to find control points.
:param coeff_matrix: coefficient matrix
:type coeff_matrix: list, tuple
:param points: data points
:type points: list, tuple
:return: control points
:rtype: list | [
"Applies",
"global",
"interpolation",
"to",
"the",
"set",
"of",
"data",
"points",
"to",
"find",
"control",
"points",
"."
] | b1c6a8b51cf143ff58761438e93ba6baef470627 | https://github.com/orbingol/NURBS-Python/blob/b1c6a8b51cf143ff58761438e93ba6baef470627/geomdl/fitting.py#L509-L536 |
244,109 | orbingol/NURBS-Python | geomdl/fitting.py | _build_coeff_matrix | def _build_coeff_matrix(degree, knotvector, params, points):
""" Builds the coefficient matrix for global interpolation.
This function only uses data points to build the coefficient matrix. Please refer to The NURBS Book (2nd Edition),
pp364-370 for details.
:param degree: degree
:type degree: int... | python | def _build_coeff_matrix(degree, knotvector, params, points):
# Number of data points
num_points = len(points)
# Set up coefficient matrix
matrix_a = [[0.0 for _ in range(num_points)] for _ in range(num_points)]
for i in range(num_points):
span = helpers.find_span_linear(degree, knotvector, ... | [
"def",
"_build_coeff_matrix",
"(",
"degree",
",",
"knotvector",
",",
"params",
",",
"points",
")",
":",
"# Number of data points",
"num_points",
"=",
"len",
"(",
"points",
")",
"# Set up coefficient matrix",
"matrix_a",
"=",
"[",
"[",
"0.0",
"for",
"_",
"in",
... | Builds the coefficient matrix for global interpolation.
This function only uses data points to build the coefficient matrix. Please refer to The NURBS Book (2nd Edition),
pp364-370 for details.
:param degree: degree
:type degree: int
:param knotvector: knot vector
:type knotvector: list, tuple... | [
"Builds",
"the",
"coefficient",
"matrix",
"for",
"global",
"interpolation",
"."
] | b1c6a8b51cf143ff58761438e93ba6baef470627 | https://github.com/orbingol/NURBS-Python/blob/b1c6a8b51cf143ff58761438e93ba6baef470627/geomdl/fitting.py#L539-L566 |
244,110 | orbingol/NURBS-Python | geomdl/visualization/vtk_helpers.py | create_render_window | def create_render_window(actors, callbacks, **kwargs):
""" Creates VTK render window with an interactor.
:param actors: list of VTK actors
:type actors: list, tuple
:param callbacks: callback functions for registering custom events
:type callbacks: dict
"""
# Get keyword arguments
figur... | python | def create_render_window(actors, callbacks, **kwargs):
# Get keyword arguments
figure_size = kwargs.get('figure_size', (800, 600))
camera_position = kwargs.get('camera_position', (0, 0, 100))
# Find camera focal point
center_points = []
for actor in actors:
center_points.append(actor.Ge... | [
"def",
"create_render_window",
"(",
"actors",
",",
"callbacks",
",",
"*",
"*",
"kwargs",
")",
":",
"# Get keyword arguments",
"figure_size",
"=",
"kwargs",
".",
"get",
"(",
"'figure_size'",
",",
"(",
"800",
",",
"600",
")",
")",
"camera_position",
"=",
"kwar... | Creates VTK render window with an interactor.
:param actors: list of VTK actors
:type actors: list, tuple
:param callbacks: callback functions for registering custom events
:type callbacks: dict | [
"Creates",
"VTK",
"render",
"window",
"with",
"an",
"interactor",
"."
] | b1c6a8b51cf143ff58761438e93ba6baef470627 | https://github.com/orbingol/NURBS-Python/blob/b1c6a8b51cf143ff58761438e93ba6baef470627/geomdl/visualization/vtk_helpers.py#L14-L73 |
244,111 | orbingol/NURBS-Python | geomdl/visualization/vtk_helpers.py | create_color | def create_color(color):
""" Creates VTK-compatible RGB color from a color string.
:param color: color
:type color: str
:return: RGB color values
:rtype: list
"""
if color[0] == "#":
# Convert hex string to RGB
return [int(color[i:i + 2], 16) / 255 for i in range(1, 7, 2)]
... | python | def create_color(color):
if color[0] == "#":
# Convert hex string to RGB
return [int(color[i:i + 2], 16) / 255 for i in range(1, 7, 2)]
else:
# Create a named colors instance
nc = vtk.vtkNamedColors()
return nc.GetColor3d(color) | [
"def",
"create_color",
"(",
"color",
")",
":",
"if",
"color",
"[",
"0",
"]",
"==",
"\"#\"",
":",
"# Convert hex string to RGB",
"return",
"[",
"int",
"(",
"color",
"[",
"i",
":",
"i",
"+",
"2",
"]",
",",
"16",
")",
"/",
"255",
"for",
"i",
"in",
"... | Creates VTK-compatible RGB color from a color string.
:param color: color
:type color: str
:return: RGB color values
:rtype: list | [
"Creates",
"VTK",
"-",
"compatible",
"RGB",
"color",
"from",
"a",
"color",
"string",
"."
] | b1c6a8b51cf143ff58761438e93ba6baef470627 | https://github.com/orbingol/NURBS-Python/blob/b1c6a8b51cf143ff58761438e93ba6baef470627/geomdl/visualization/vtk_helpers.py#L76-L90 |
244,112 | orbingol/NURBS-Python | geomdl/visualization/vtk_helpers.py | create_actor_pts | def create_actor_pts(pts, color, **kwargs):
""" Creates a VTK actor for rendering scatter plots.
:param pts: points
:type pts: vtkFloatArray
:param color: actor color
:type color: list
:return: a VTK actor
:rtype: vtkActor
"""
# Keyword arguments
array_name = kwargs.get('name', ... | python | def create_actor_pts(pts, color, **kwargs):
# Keyword arguments
array_name = kwargs.get('name', "")
array_index = kwargs.get('index', 0)
point_size = kwargs.get('size', 5)
point_sphere = kwargs.get('point_as_sphere', True)
# Create points
points = vtk.vtkPoints()
points.SetData(pts)
... | [
"def",
"create_actor_pts",
"(",
"pts",
",",
"color",
",",
"*",
"*",
"kwargs",
")",
":",
"# Keyword arguments",
"array_name",
"=",
"kwargs",
".",
"get",
"(",
"'name'",
",",
"\"\"",
")",
"array_index",
"=",
"kwargs",
".",
"get",
"(",
"'index'",
",",
"0",
... | Creates a VTK actor for rendering scatter plots.
:param pts: points
:type pts: vtkFloatArray
:param color: actor color
:type color: list
:return: a VTK actor
:rtype: vtkActor | [
"Creates",
"a",
"VTK",
"actor",
"for",
"rendering",
"scatter",
"plots",
"."
] | b1c6a8b51cf143ff58761438e93ba6baef470627 | https://github.com/orbingol/NURBS-Python/blob/b1c6a8b51cf143ff58761438e93ba6baef470627/geomdl/visualization/vtk_helpers.py#L93-L135 |
244,113 | orbingol/NURBS-Python | geomdl/visualization/vtk_helpers.py | create_actor_polygon | def create_actor_polygon(pts, color, **kwargs):
""" Creates a VTK actor for rendering polygons.
:param pts: points
:type pts: vtkFloatArray
:param color: actor color
:type color: list
:return: a VTK actor
:rtype: vtkActor
"""
# Keyword arguments
array_name = kwargs.get('name', "... | python | def create_actor_polygon(pts, color, **kwargs):
# Keyword arguments
array_name = kwargs.get('name', "")
array_index = kwargs.get('index', 0)
line_width = kwargs.get('size', 1.0)
# Create points
points = vtk.vtkPoints()
points.SetData(pts)
# Number of points
num_points = points.GetN... | [
"def",
"create_actor_polygon",
"(",
"pts",
",",
"color",
",",
"*",
"*",
"kwargs",
")",
":",
"# Keyword arguments",
"array_name",
"=",
"kwargs",
".",
"get",
"(",
"'name'",
",",
"\"\"",
")",
"array_index",
"=",
"kwargs",
".",
"get",
"(",
"'index'",
",",
"0... | Creates a VTK actor for rendering polygons.
:param pts: points
:type pts: vtkFloatArray
:param color: actor color
:type color: list
:return: a VTK actor
:rtype: vtkActor | [
"Creates",
"a",
"VTK",
"actor",
"for",
"rendering",
"polygons",
"."
] | b1c6a8b51cf143ff58761438e93ba6baef470627 | https://github.com/orbingol/NURBS-Python/blob/b1c6a8b51cf143ff58761438e93ba6baef470627/geomdl/visualization/vtk_helpers.py#L138-L186 |
244,114 | orbingol/NURBS-Python | geomdl/visualization/vtk_helpers.py | create_actor_mesh | def create_actor_mesh(pts, lines, color, **kwargs):
""" Creates a VTK actor for rendering quadrilateral plots.
:param pts: points
:type pts: vtkFloatArray
:param lines: point connectivity information
:type lines: vtkIntArray
:param color: actor color
:type color: list
:return: a VTK act... | python | def create_actor_mesh(pts, lines, color, **kwargs):
# Keyword arguments
array_name = kwargs.get('name', "")
array_index = kwargs.get('index', 0)
line_width = kwargs.get('size', 0.5)
# Create points
points = vtk.vtkPoints()
points.SetData(pts)
# Create lines
cells = vtk.vtkCellArray... | [
"def",
"create_actor_mesh",
"(",
"pts",
",",
"lines",
",",
"color",
",",
"*",
"*",
"kwargs",
")",
":",
"# Keyword arguments",
"array_name",
"=",
"kwargs",
".",
"get",
"(",
"'name'",
",",
"\"\"",
")",
"array_index",
"=",
"kwargs",
".",
"get",
"(",
"'index... | Creates a VTK actor for rendering quadrilateral plots.
:param pts: points
:type pts: vtkFloatArray
:param lines: point connectivity information
:type lines: vtkIntArray
:param color: actor color
:type color: list
:return: a VTK actor
:rtype: vtkActor | [
"Creates",
"a",
"VTK",
"actor",
"for",
"rendering",
"quadrilateral",
"plots",
"."
] | b1c6a8b51cf143ff58761438e93ba6baef470627 | https://github.com/orbingol/NURBS-Python/blob/b1c6a8b51cf143ff58761438e93ba6baef470627/geomdl/visualization/vtk_helpers.py#L189-L238 |
244,115 | orbingol/NURBS-Python | geomdl/visualization/vtk_helpers.py | create_actor_tri | def create_actor_tri(pts, tris, color, **kwargs):
""" Creates a VTK actor for rendering triangulated surface plots.
:param pts: points
:type pts: vtkFloatArray
:param tris: list of triangle indices
:type tris: ndarray
:param color: actor color
:type color: list
:return: a VTK actor
... | python | def create_actor_tri(pts, tris, color, **kwargs):
# Keyword arguments
array_name = kwargs.get('name', "")
array_index = kwargs.get('index', 0)
# Create points
points = vtk.vtkPoints()
points.SetData(pts)
# Create triangles
triangles = vtk.vtkCellArray()
for tri in tris:
tmp... | [
"def",
"create_actor_tri",
"(",
"pts",
",",
"tris",
",",
"color",
",",
"*",
"*",
"kwargs",
")",
":",
"# Keyword arguments",
"array_name",
"=",
"kwargs",
".",
"get",
"(",
"'name'",
",",
"\"\"",
")",
"array_index",
"=",
"kwargs",
".",
"get",
"(",
"'index'"... | Creates a VTK actor for rendering triangulated surface plots.
:param pts: points
:type pts: vtkFloatArray
:param tris: list of triangle indices
:type tris: ndarray
:param color: actor color
:type color: list
:return: a VTK actor
:rtype: vtkActor | [
"Creates",
"a",
"VTK",
"actor",
"for",
"rendering",
"triangulated",
"surface",
"plots",
"."
] | b1c6a8b51cf143ff58761438e93ba6baef470627 | https://github.com/orbingol/NURBS-Python/blob/b1c6a8b51cf143ff58761438e93ba6baef470627/geomdl/visualization/vtk_helpers.py#L241-L286 |
244,116 | orbingol/NURBS-Python | geomdl/visualization/vtk_helpers.py | create_actor_hexahedron | def create_actor_hexahedron(grid, color, **kwargs):
""" Creates a VTK actor for rendering voxels using hexahedron elements.
:param grid: grid
:type grid: ndarray
:param color: actor color
:type color: list
:return: a VTK actor
:rtype: vtkActor
"""
# Keyword arguments
array_name ... | python | def create_actor_hexahedron(grid, color, **kwargs):
# Keyword arguments
array_name = kwargs.get('name', "")
array_index = kwargs.get('index', 0)
# Create hexahedron elements
points = vtk.vtkPoints()
hexarray = vtk.vtkCellArray()
for j, pt in enumerate(grid):
tmp = vtk.vtkHexahedron(... | [
"def",
"create_actor_hexahedron",
"(",
"grid",
",",
"color",
",",
"*",
"*",
"kwargs",
")",
":",
"# Keyword arguments",
"array_name",
"=",
"kwargs",
".",
"get",
"(",
"'name'",
",",
"\"\"",
")",
"array_index",
"=",
"kwargs",
".",
"get",
"(",
"'index'",
",",
... | Creates a VTK actor for rendering voxels using hexahedron elements.
:param grid: grid
:type grid: ndarray
:param color: actor color
:type color: list
:return: a VTK actor
:rtype: vtkActor | [
"Creates",
"a",
"VTK",
"actor",
"for",
"rendering",
"voxels",
"using",
"hexahedron",
"elements",
"."
] | b1c6a8b51cf143ff58761438e93ba6baef470627 | https://github.com/orbingol/NURBS-Python/blob/b1c6a8b51cf143ff58761438e93ba6baef470627/geomdl/visualization/vtk_helpers.py#L289-L336 |
244,117 | orbingol/NURBS-Python | geomdl/visualization/vtk_helpers.py | create_actor_delaunay | def create_actor_delaunay(pts, color, **kwargs):
""" Creates a VTK actor for rendering triangulated plots using Delaunay triangulation.
Keyword Arguments:
* ``d3d``: flag to choose between Delaunay2D (``False``) and Delaunay3D (``True``). *Default: False*
:param pts: points
:type pts: vtkFloat... | python | def create_actor_delaunay(pts, color, **kwargs):
# Keyword arguments
array_name = kwargs.get('name', "")
array_index = kwargs.get('index', 0)
use_delaunay3d = kwargs.get("d3d", False)
# Create points
points = vtk.vtkPoints()
points.SetData(pts)
# Create a PolyData object and add points... | [
"def",
"create_actor_delaunay",
"(",
"pts",
",",
"color",
",",
"*",
"*",
"kwargs",
")",
":",
"# Keyword arguments",
"array_name",
"=",
"kwargs",
".",
"get",
"(",
"'name'",
",",
"\"\"",
")",
"array_index",
"=",
"kwargs",
".",
"get",
"(",
"'index'",
",",
"... | Creates a VTK actor for rendering triangulated plots using Delaunay triangulation.
Keyword Arguments:
* ``d3d``: flag to choose between Delaunay2D (``False``) and Delaunay3D (``True``). *Default: False*
:param pts: points
:type pts: vtkFloatArray
:param color: actor color
:type color: list... | [
"Creates",
"a",
"VTK",
"actor",
"for",
"rendering",
"triangulated",
"plots",
"using",
"Delaunay",
"triangulation",
"."
] | b1c6a8b51cf143ff58761438e93ba6baef470627 | https://github.com/orbingol/NURBS-Python/blob/b1c6a8b51cf143ff58761438e93ba6baef470627/geomdl/visualization/vtk_helpers.py#L339-L381 |
244,118 | orbingol/NURBS-Python | geomdl/compatibility.py | flip_ctrlpts_u | def flip_ctrlpts_u(ctrlpts, size_u, size_v):
""" Flips a list of 1-dimensional control points from u-row order to v-row order.
**u-row order**: each row corresponds to a list of u values
**v-row order**: each row corresponds to a list of v values
:param ctrlpts: control points in u-row order
:typ... | python | def flip_ctrlpts_u(ctrlpts, size_u, size_v):
new_ctrlpts = []
for i in range(0, size_u):
for j in range(0, size_v):
temp = [float(c) for c in ctrlpts[i + (j * size_u)]]
new_ctrlpts.append(temp)
return new_ctrlpts | [
"def",
"flip_ctrlpts_u",
"(",
"ctrlpts",
",",
"size_u",
",",
"size_v",
")",
":",
"new_ctrlpts",
"=",
"[",
"]",
"for",
"i",
"in",
"range",
"(",
"0",
",",
"size_u",
")",
":",
"for",
"j",
"in",
"range",
"(",
"0",
",",
"size_v",
")",
":",
"temp",
"="... | Flips a list of 1-dimensional control points from u-row order to v-row order.
**u-row order**: each row corresponds to a list of u values
**v-row order**: each row corresponds to a list of v values
:param ctrlpts: control points in u-row order
:type ctrlpts: list, tuple
:param size_u: size in u-d... | [
"Flips",
"a",
"list",
"of",
"1",
"-",
"dimensional",
"control",
"points",
"from",
"u",
"-",
"row",
"order",
"to",
"v",
"-",
"row",
"order",
"."
] | b1c6a8b51cf143ff58761438e93ba6baef470627 | https://github.com/orbingol/NURBS-Python/blob/b1c6a8b51cf143ff58761438e93ba6baef470627/geomdl/compatibility.py#L11-L33 |
244,119 | orbingol/NURBS-Python | geomdl/compatibility.py | generate_ctrlptsw | def generate_ctrlptsw(ctrlpts):
""" Generates weighted control points from unweighted ones in 1-D.
This function
#. Takes in a 1-D control points list whose coordinates are organized in (x, y, z, w) format
#. converts into (x*w, y*w, z*w, w) format
#. Returns the result
:param ctrlpts: 1-D co... | python | def generate_ctrlptsw(ctrlpts):
# Multiply control points by weight
new_ctrlpts = []
for cpt in ctrlpts:
temp = [float(pt * cpt[-1]) for pt in cpt]
temp[-1] = float(cpt[-1])
new_ctrlpts.append(temp)
return new_ctrlpts | [
"def",
"generate_ctrlptsw",
"(",
"ctrlpts",
")",
":",
"# Multiply control points by weight",
"new_ctrlpts",
"=",
"[",
"]",
"for",
"cpt",
"in",
"ctrlpts",
":",
"temp",
"=",
"[",
"float",
"(",
"pt",
"*",
"cpt",
"[",
"-",
"1",
"]",
")",
"for",
"pt",
"in",
... | Generates weighted control points from unweighted ones in 1-D.
This function
#. Takes in a 1-D control points list whose coordinates are organized in (x, y, z, w) format
#. converts into (x*w, y*w, z*w, w) format
#. Returns the result
:param ctrlpts: 1-D control points (P)
:type ctrlpts: list... | [
"Generates",
"weighted",
"control",
"points",
"from",
"unweighted",
"ones",
"in",
"1",
"-",
"D",
"."
] | b1c6a8b51cf143ff58761438e93ba6baef470627 | https://github.com/orbingol/NURBS-Python/blob/b1c6a8b51cf143ff58761438e93ba6baef470627/geomdl/compatibility.py#L86-L107 |
244,120 | orbingol/NURBS-Python | geomdl/compatibility.py | generate_ctrlpts_weights | def generate_ctrlpts_weights(ctrlpts):
""" Generates unweighted control points from weighted ones in 1-D.
This function
#. Takes in 1-D control points list whose coordinates are organized in (x*w, y*w, z*w, w) format
#. Converts the input control points list into (x, y, z, w) format
#. Returns the... | python | def generate_ctrlpts_weights(ctrlpts):
# Divide control points by weight
new_ctrlpts = []
for cpt in ctrlpts:
temp = [float(pt / cpt[-1]) for pt in cpt]
temp[-1] = float(cpt[-1])
new_ctrlpts.append(temp)
return new_ctrlpts | [
"def",
"generate_ctrlpts_weights",
"(",
"ctrlpts",
")",
":",
"# Divide control points by weight",
"new_ctrlpts",
"=",
"[",
"]",
"for",
"cpt",
"in",
"ctrlpts",
":",
"temp",
"=",
"[",
"float",
"(",
"pt",
"/",
"cpt",
"[",
"-",
"1",
"]",
")",
"for",
"pt",
"i... | Generates unweighted control points from weighted ones in 1-D.
This function
#. Takes in 1-D control points list whose coordinates are organized in (x*w, y*w, z*w, w) format
#. Converts the input control points list into (x, y, z, w) format
#. Returns the result
:param ctrlpts: 1-D control points... | [
"Generates",
"unweighted",
"control",
"points",
"from",
"weighted",
"ones",
"in",
"1",
"-",
"D",
"."
] | b1c6a8b51cf143ff58761438e93ba6baef470627 | https://github.com/orbingol/NURBS-Python/blob/b1c6a8b51cf143ff58761438e93ba6baef470627/geomdl/compatibility.py#L139-L160 |
244,121 | orbingol/NURBS-Python | geomdl/compatibility.py | combine_ctrlpts_weights | def combine_ctrlpts_weights(ctrlpts, weights=None):
""" Multiplies control points by the weights to generate weighted control points.
This function is dimension agnostic, i.e. control points can be in any dimension but weights should be 1D.
The ``weights`` function parameter can be set to None to let the ... | python | def combine_ctrlpts_weights(ctrlpts, weights=None):
if weights is None:
weights = [1.0 for _ in range(len(ctrlpts))]
ctrlptsw = []
for pt, w in zip(ctrlpts, weights):
temp = [float(c * w) for c in pt]
temp.append(float(w))
ctrlptsw.append(temp)
return ctrlptsw | [
"def",
"combine_ctrlpts_weights",
"(",
"ctrlpts",
",",
"weights",
"=",
"None",
")",
":",
"if",
"weights",
"is",
"None",
":",
"weights",
"=",
"[",
"1.0",
"for",
"_",
"in",
"range",
"(",
"len",
"(",
"ctrlpts",
")",
")",
"]",
"ctrlptsw",
"=",
"[",
"]",
... | Multiplies control points by the weights to generate weighted control points.
This function is dimension agnostic, i.e. control points can be in any dimension but weights should be 1D.
The ``weights`` function parameter can be set to None to let the function generate a weights vector composed of
1.0 value... | [
"Multiplies",
"control",
"points",
"by",
"the",
"weights",
"to",
"generate",
"weighted",
"control",
"points",
"."
] | b1c6a8b51cf143ff58761438e93ba6baef470627 | https://github.com/orbingol/NURBS-Python/blob/b1c6a8b51cf143ff58761438e93ba6baef470627/geomdl/compatibility.py#L190-L214 |
244,122 | orbingol/NURBS-Python | geomdl/compatibility.py | separate_ctrlpts_weights | def separate_ctrlpts_weights(ctrlptsw):
""" Divides weighted control points by weights to generate unweighted control points and weights vector.
This function is dimension agnostic, i.e. control points can be in any dimension but the last element of the array
should indicate the weight.
:param ctrlpts... | python | def separate_ctrlpts_weights(ctrlptsw):
ctrlpts = []
weights = []
for ptw in ctrlptsw:
temp = [float(pw / ptw[-1]) for pw in ptw[:-1]]
ctrlpts.append(temp)
weights.append(ptw[-1])
return [ctrlpts, weights] | [
"def",
"separate_ctrlpts_weights",
"(",
"ctrlptsw",
")",
":",
"ctrlpts",
"=",
"[",
"]",
"weights",
"=",
"[",
"]",
"for",
"ptw",
"in",
"ctrlptsw",
":",
"temp",
"=",
"[",
"float",
"(",
"pw",
"/",
"ptw",
"[",
"-",
"1",
"]",
")",
"for",
"pw",
"in",
"... | Divides weighted control points by weights to generate unweighted control points and weights vector.
This function is dimension agnostic, i.e. control points can be in any dimension but the last element of the array
should indicate the weight.
:param ctrlptsw: weighted control points
:type ctrlptsw: l... | [
"Divides",
"weighted",
"control",
"points",
"by",
"weights",
"to",
"generate",
"unweighted",
"control",
"points",
"and",
"weights",
"vector",
"."
] | b1c6a8b51cf143ff58761438e93ba6baef470627 | https://github.com/orbingol/NURBS-Python/blob/b1c6a8b51cf143ff58761438e93ba6baef470627/geomdl/compatibility.py#L217-L235 |
244,123 | orbingol/NURBS-Python | geomdl/compatibility.py | flip_ctrlpts2d_file | def flip_ctrlpts2d_file(file_in='', file_out='ctrlpts_flip.txt'):
""" Flips u and v directions of a 2D control points file and saves flipped coordinates to a file.
:param file_in: name of the input file (to be read)
:type file_in: str
:param file_out: name of the output file (to be saved)
:type fil... | python | def flip_ctrlpts2d_file(file_in='', file_out='ctrlpts_flip.txt'):
# Read control points
ctrlpts2d, size_u, size_v = _read_ctrltps2d_file(file_in)
# Flip control points array
new_ctrlpts2d = flip_ctrlpts2d(ctrlpts2d, size_u, size_v)
# Save new control points
_save_ctrlpts2d_file(new_ctrlpts2d, ... | [
"def",
"flip_ctrlpts2d_file",
"(",
"file_in",
"=",
"''",
",",
"file_out",
"=",
"'ctrlpts_flip.txt'",
")",
":",
"# Read control points",
"ctrlpts2d",
",",
"size_u",
",",
"size_v",
"=",
"_read_ctrltps2d_file",
"(",
"file_in",
")",
"# Flip control points array",
"new_ctr... | Flips u and v directions of a 2D control points file and saves flipped coordinates to a file.
:param file_in: name of the input file (to be read)
:type file_in: str
:param file_out: name of the output file (to be saved)
:type file_out: str
:raises IOError: an error occurred reading or writing the f... | [
"Flips",
"u",
"and",
"v",
"directions",
"of",
"a",
"2D",
"control",
"points",
"file",
"and",
"saves",
"flipped",
"coordinates",
"to",
"a",
"file",
"."
] | b1c6a8b51cf143ff58761438e93ba6baef470627 | https://github.com/orbingol/NURBS-Python/blob/b1c6a8b51cf143ff58761438e93ba6baef470627/geomdl/compatibility.py#L238-L254 |
244,124 | orbingol/NURBS-Python | geomdl/compatibility.py | generate_ctrlptsw2d_file | def generate_ctrlptsw2d_file(file_in='', file_out='ctrlptsw.txt'):
""" Generates weighted control points from unweighted ones in 2-D.
This function
#. Takes in a 2-D control points file whose coordinates are organized in (x, y, z, w) format
#. Converts into (x*w, y*w, z*w, w) format
#. Saves the r... | python | def generate_ctrlptsw2d_file(file_in='', file_out='ctrlptsw.txt'):
# Read control points
ctrlpts2d, size_u, size_v = _read_ctrltps2d_file(file_in)
# Multiply control points by weight
new_ctrlpts2d = generate_ctrlptsw2d(ctrlpts2d)
# Save new control points
_save_ctrlpts2d_file(new_ctrlpts2d, si... | [
"def",
"generate_ctrlptsw2d_file",
"(",
"file_in",
"=",
"''",
",",
"file_out",
"=",
"'ctrlptsw.txt'",
")",
":",
"# Read control points",
"ctrlpts2d",
",",
"size_u",
",",
"size_v",
"=",
"_read_ctrltps2d_file",
"(",
"file_in",
")",
"# Multiply control points by weight",
... | Generates weighted control points from unweighted ones in 2-D.
This function
#. Takes in a 2-D control points file whose coordinates are organized in (x, y, z, w) format
#. Converts into (x*w, y*w, z*w, w) format
#. Saves the result to a file
Therefore, the resultant file could be a direct input ... | [
"Generates",
"weighted",
"control",
"points",
"from",
"unweighted",
"ones",
"in",
"2",
"-",
"D",
"."
] | b1c6a8b51cf143ff58761438e93ba6baef470627 | https://github.com/orbingol/NURBS-Python/blob/b1c6a8b51cf143ff58761438e93ba6baef470627/geomdl/compatibility.py#L257-L281 |
244,125 | orbingol/NURBS-Python | geomdl/visualization/VisVTK.py | VisConfig.keypress_callback | def keypress_callback(self, obj, ev):
""" VTK callback for keypress events.
Keypress events:
* ``e``: exit the application
* ``p``: pick object (hover the mouse and then press to pick)
* ``f``: fly to point (click somewhere in the window and press to fly)
... | python | def keypress_callback(self, obj, ev):
key = obj.GetKeySym() # pressed key (as str)
render_window = obj.GetRenderWindow() # vtkRenderWindow
renderer = render_window.GetRenderers().GetFirstRenderer() # vtkRenderer
picker = obj.GetPicker() # vtkPropPicker
actor = picker.GetActor... | [
"def",
"keypress_callback",
"(",
"self",
",",
"obj",
",",
"ev",
")",
":",
"key",
"=",
"obj",
".",
"GetKeySym",
"(",
")",
"# pressed key (as str)",
"render_window",
"=",
"obj",
".",
"GetRenderWindow",
"(",
")",
"# vtkRenderWindow",
"renderer",
"=",
"render_wind... | VTK callback for keypress events.
Keypress events:
* ``e``: exit the application
* ``p``: pick object (hover the mouse and then press to pick)
* ``f``: fly to point (click somewhere in the window and press to fly)
* ``r``: reset the camera
* ``s`` and... | [
"VTK",
"callback",
"for",
"keypress",
"events",
"."
] | b1c6a8b51cf143ff58761438e93ba6baef470627 | https://github.com/orbingol/NURBS-Python/blob/b1c6a8b51cf143ff58761438e93ba6baef470627/geomdl/visualization/VisVTK.py#L46-L112 |
244,126 | orbingol/NURBS-Python | geomdl/_voxelize.py | generate_voxel_grid | def generate_voxel_grid(bbox, szval, use_cubes=False):
""" Generates the voxel grid with the desired size.
:param bbox: bounding box
:type bbox: list, tuple
:param szval: size in x-, y-, z-directions
:type szval: list, tuple
:param use_cubes: use cube voxels instead of cuboid ones
:type use... | python | def generate_voxel_grid(bbox, szval, use_cubes=False):
# Input validation
if szval[0] <= 1 or szval[1] <= 1 or szval[2] <= 1:
raise GeomdlException("Size values must be bigger than 1", data=dict(sizevals=szval))
# Find step size for each direction
steps = [float(bbox[1][idx] - bbox[0][idx]) / f... | [
"def",
"generate_voxel_grid",
"(",
"bbox",
",",
"szval",
",",
"use_cubes",
"=",
"False",
")",
":",
"# Input validation",
"if",
"szval",
"[",
"0",
"]",
"<=",
"1",
"or",
"szval",
"[",
"1",
"]",
"<=",
"1",
"or",
"szval",
"[",
"2",
"]",
"<=",
"1",
":",... | Generates the voxel grid with the desired size.
:param bbox: bounding box
:type bbox: list, tuple
:param szval: size in x-, y-, z-directions
:type szval: list, tuple
:param use_cubes: use cube voxels instead of cuboid ones
:type use_cubes: bool
:return: voxel grid
:rtype: list | [
"Generates",
"the",
"voxel",
"grid",
"with",
"the",
"desired",
"size",
"."
] | b1c6a8b51cf143ff58761438e93ba6baef470627 | https://github.com/orbingol/NURBS-Python/blob/b1c6a8b51cf143ff58761438e93ba6baef470627/geomdl/_voxelize.py#L49-L83 |
244,127 | orbingol/NURBS-Python | geomdl/_exchange.py | process_template | def process_template(file_src):
""" Process Jinja2 template input
:param file_src: file contents
:type file_src: str
"""
def tmpl_sqrt(x):
""" Square-root of 'x' """
return math.sqrt(x)
def tmpl_cubert(x):
""" Cube-root of 'x' """
return x ** (1.0 / 3.0) if x >=... | python | def process_template(file_src):
def tmpl_sqrt(x):
""" Square-root of 'x' """
return math.sqrt(x)
def tmpl_cubert(x):
""" Cube-root of 'x' """
return x ** (1.0 / 3.0) if x >= 0 else -(-x) ** (1.0 / 3.0)
def tmpl_pow(x, y):
""" 'x' to the power 'y' """
return ... | [
"def",
"process_template",
"(",
"file_src",
")",
":",
"def",
"tmpl_sqrt",
"(",
"x",
")",
":",
"\"\"\" Square-root of 'x' \"\"\"",
"return",
"math",
".",
"sqrt",
"(",
"x",
")",
"def",
"tmpl_cubert",
"(",
"x",
")",
":",
"\"\"\" Cube-root of 'x' \"\"\"",
"return",
... | Process Jinja2 template input
:param file_src: file contents
:type file_src: str | [
"Process",
"Jinja2",
"template",
"input"
] | b1c6a8b51cf143ff58761438e93ba6baef470627 | https://github.com/orbingol/NURBS-Python/blob/b1c6a8b51cf143ff58761438e93ba6baef470627/geomdl/_exchange.py#L21-L67 |
244,128 | orbingol/NURBS-Python | geomdl/_exchange.py | import_surf_mesh | def import_surf_mesh(file_name):
""" Generates a NURBS surface object from a mesh file.
:param file_name: input mesh file
:type file_name: str
:return: a NURBS surface
:rtype: NURBS.Surface
"""
raw_content = read_file(file_name)
raw_content = raw_content.split("\n")
content = []
... | python | def import_surf_mesh(file_name):
raw_content = read_file(file_name)
raw_content = raw_content.split("\n")
content = []
for rc in raw_content:
temp = rc.strip().split()
content.append(temp)
# 1st line defines the dimension and it must be 3
if int(content[0][0]) != 3:
rais... | [
"def",
"import_surf_mesh",
"(",
"file_name",
")",
":",
"raw_content",
"=",
"read_file",
"(",
"file_name",
")",
"raw_content",
"=",
"raw_content",
".",
"split",
"(",
"\"\\n\"",
")",
"content",
"=",
"[",
"]",
"for",
"rc",
"in",
"raw_content",
":",
"temp",
"=... | Generates a NURBS surface object from a mesh file.
:param file_name: input mesh file
:type file_name: str
:return: a NURBS surface
:rtype: NURBS.Surface | [
"Generates",
"a",
"NURBS",
"surface",
"object",
"from",
"a",
"mesh",
"file",
"."
] | b1c6a8b51cf143ff58761438e93ba6baef470627 | https://github.com/orbingol/NURBS-Python/blob/b1c6a8b51cf143ff58761438e93ba6baef470627/geomdl/_exchange.py#L102-L150 |
244,129 | orbingol/NURBS-Python | geomdl/_exchange.py | import_vol_mesh | def import_vol_mesh(file_name):
""" Generates a NURBS volume object from a mesh file.
:param file_name: input mesh file
:type file_name: str
:return: a NURBS volume
:rtype: NURBS.Volume
"""
raw_content = read_file(file_name)
raw_content = raw_content.split("\n")
content = []
for... | python | def import_vol_mesh(file_name):
raw_content = read_file(file_name)
raw_content = raw_content.split("\n")
content = []
for rc in raw_content:
temp = rc.strip().split()
content.append(temp)
# 1st line defines the dimension and it must be 3
if int(content[0][0]) != 3:
raise... | [
"def",
"import_vol_mesh",
"(",
"file_name",
")",
":",
"raw_content",
"=",
"read_file",
"(",
"file_name",
")",
"raw_content",
"=",
"raw_content",
".",
"split",
"(",
"\"\\n\"",
")",
"content",
"=",
"[",
"]",
"for",
"rc",
"in",
"raw_content",
":",
"temp",
"="... | Generates a NURBS volume object from a mesh file.
:param file_name: input mesh file
:type file_name: str
:return: a NURBS volume
:rtype: NURBS.Volume | [
"Generates",
"a",
"NURBS",
"volume",
"object",
"from",
"a",
"mesh",
"file",
"."
] | b1c6a8b51cf143ff58761438e93ba6baef470627 | https://github.com/orbingol/NURBS-Python/blob/b1c6a8b51cf143ff58761438e93ba6baef470627/geomdl/_exchange.py#L153-L207 |
244,130 | orbingol/NURBS-Python | geomdl/exchange.py | import_txt | def import_txt(file_name, two_dimensional=False, **kwargs):
""" Reads control points from a text file and generates a 1-dimensional list of control points.
The following code examples illustrate importing different types of text files for curves and surfaces:
.. code-block:: python
:linenos:
... | python | def import_txt(file_name, two_dimensional=False, **kwargs):
# Read file
content = exch.read_file(file_name)
# Are we using a Jinja2 template?
j2tmpl = kwargs.get('jinja2', False)
if j2tmpl:
content = exch.process_template(content)
# File delimiters
col_sep = kwargs.get('col_separat... | [
"def",
"import_txt",
"(",
"file_name",
",",
"two_dimensional",
"=",
"False",
",",
"*",
"*",
"kwargs",
")",
":",
"# Read file",
"content",
"=",
"exch",
".",
"read_file",
"(",
"file_name",
")",
"# Are we using a Jinja2 template?",
"j2tmpl",
"=",
"kwargs",
".",
"... | Reads control points from a text file and generates a 1-dimensional list of control points.
The following code examples illustrate importing different types of text files for curves and surfaces:
.. code-block:: python
:linenos:
# Import curve control points from a text file
curve_ctr... | [
"Reads",
"control",
"points",
"from",
"a",
"text",
"file",
"and",
"generates",
"a",
"1",
"-",
"dimensional",
"list",
"of",
"control",
"points",
"."
] | b1c6a8b51cf143ff58761438e93ba6baef470627 | https://github.com/orbingol/NURBS-Python/blob/b1c6a8b51cf143ff58761438e93ba6baef470627/geomdl/exchange.py#L21-L89 |
244,131 | orbingol/NURBS-Python | geomdl/exchange.py | export_txt | def export_txt(obj, file_name, two_dimensional=False, **kwargs):
""" Exports control points as a text file.
For curves the output is always a list of control points. For surfaces, it is possible to generate a 2-dimensional
control point output file using ``two_dimensional``.
Please see :py:func:`.exch... | python | def export_txt(obj, file_name, two_dimensional=False, **kwargs):
# Check if the user has set any control points
if obj.ctrlpts is None or len(obj.ctrlpts) == 0:
raise exch.GeomdlException("There are no control points to save!")
# Check the usage of two_dimensional flag
if obj.pdimension == 1 an... | [
"def",
"export_txt",
"(",
"obj",
",",
"file_name",
",",
"two_dimensional",
"=",
"False",
",",
"*",
"*",
"kwargs",
")",
":",
"# Check if the user has set any control points",
"if",
"obj",
".",
"ctrlpts",
"is",
"None",
"or",
"len",
"(",
"obj",
".",
"ctrlpts",
... | Exports control points as a text file.
For curves the output is always a list of control points. For surfaces, it is possible to generate a 2-dimensional
control point output file using ``two_dimensional``.
Please see :py:func:`.exchange.import_txt()` for detailed description of the keyword arguments.
... | [
"Exports",
"control",
"points",
"as",
"a",
"text",
"file",
"."
] | b1c6a8b51cf143ff58761438e93ba6baef470627 | https://github.com/orbingol/NURBS-Python/blob/b1c6a8b51cf143ff58761438e93ba6baef470627/geomdl/exchange.py#L93-L123 |
244,132 | orbingol/NURBS-Python | geomdl/exchange.py | import_csv | def import_csv(file_name, **kwargs):
""" Reads control points from a CSV file and generates a 1-dimensional list of control points.
It is possible to use a different value separator via ``separator`` keyword argument. The following code segment
illustrates the usage of ``separator`` keyword argument.
... | python | def import_csv(file_name, **kwargs):
# File delimiters
sep = kwargs.get('separator', ",")
content = exch.read_file(file_name, skip_lines=1)
return exch.import_text_data(content, sep) | [
"def",
"import_csv",
"(",
"file_name",
",",
"*",
"*",
"kwargs",
")",
":",
"# File delimiters",
"sep",
"=",
"kwargs",
".",
"get",
"(",
"'separator'",
",",
"\",\"",
")",
"content",
"=",
"exch",
".",
"read_file",
"(",
"file_name",
",",
"skip_lines",
"=",
"1... | Reads control points from a CSV file and generates a 1-dimensional list of control points.
It is possible to use a different value separator via ``separator`` keyword argument. The following code segment
illustrates the usage of ``separator`` keyword argument.
.. code-block:: python
:linenos:
... | [
"Reads",
"control",
"points",
"from",
"a",
"CSV",
"file",
"and",
"generates",
"a",
"1",
"-",
"dimensional",
"list",
"of",
"control",
"points",
"."
] | b1c6a8b51cf143ff58761438e93ba6baef470627 | https://github.com/orbingol/NURBS-Python/blob/b1c6a8b51cf143ff58761438e93ba6baef470627/geomdl/exchange.py#L127-L155 |
244,133 | orbingol/NURBS-Python | geomdl/exchange.py | export_csv | def export_csv(obj, file_name, point_type='evalpts', **kwargs):
""" Exports control points or evaluated points as a CSV file.
:param obj: a spline geometry object
:type obj: abstract.SplineGeometry
:param file_name: output file name
:type file_name: str
:param point_type: ``ctrlpts`` for contro... | python | def export_csv(obj, file_name, point_type='evalpts', **kwargs):
if not 0 < obj.pdimension < 3:
raise exch.GeomdlException("Input object should be a curve or a surface")
# Pick correct points from the object
if point_type == 'ctrlpts':
points = obj.ctrlptsw if obj.rational else obj.ctrlpts
... | [
"def",
"export_csv",
"(",
"obj",
",",
"file_name",
",",
"point_type",
"=",
"'evalpts'",
",",
"*",
"*",
"kwargs",
")",
":",
"if",
"not",
"0",
"<",
"obj",
".",
"pdimension",
"<",
"3",
":",
"raise",
"exch",
".",
"GeomdlException",
"(",
"\"Input object shoul... | Exports control points or evaluated points as a CSV file.
:param obj: a spline geometry object
:type obj: abstract.SplineGeometry
:param file_name: output file name
:type file_name: str
:param point_type: ``ctrlpts`` for control points or ``evalpts`` for evaluated points
:type point_type: str
... | [
"Exports",
"control",
"points",
"or",
"evaluated",
"points",
"as",
"a",
"CSV",
"file",
"."
] | b1c6a8b51cf143ff58761438e93ba6baef470627 | https://github.com/orbingol/NURBS-Python/blob/b1c6a8b51cf143ff58761438e93ba6baef470627/geomdl/exchange.py#L159-L193 |
244,134 | orbingol/NURBS-Python | geomdl/exchange.py | import_cfg | def import_cfg(file_name, **kwargs):
""" Imports curves and surfaces from files in libconfig format.
.. note::
Requires `libconf <https://pypi.org/project/libconf/>`_ package.
Use ``jinja2=True`` to activate Jinja2 template processing. Please refer to the documentation for details.
:param fi... | python | def import_cfg(file_name, **kwargs):
def callback(data):
return libconf.loads(data)
# Check if it is possible to import 'libconf'
try:
import libconf
except ImportError:
raise exch.GeomdlException("Please install 'libconf' package to use libconfig format: pip install libconf")
... | [
"def",
"import_cfg",
"(",
"file_name",
",",
"*",
"*",
"kwargs",
")",
":",
"def",
"callback",
"(",
"data",
")",
":",
"return",
"libconf",
".",
"loads",
"(",
"data",
")",
"# Check if it is possible to import 'libconf'",
"try",
":",
"import",
"libconf",
"except",... | Imports curves and surfaces from files in libconfig format.
.. note::
Requires `libconf <https://pypi.org/project/libconf/>`_ package.
Use ``jinja2=True`` to activate Jinja2 template processing. Please refer to the documentation for details.
:param file_name: name of the input file
:type fil... | [
"Imports",
"curves",
"and",
"surfaces",
"from",
"files",
"in",
"libconfig",
"format",
"."
] | b1c6a8b51cf143ff58761438e93ba6baef470627 | https://github.com/orbingol/NURBS-Python/blob/b1c6a8b51cf143ff58761438e93ba6baef470627/geomdl/exchange.py#L197-L229 |
244,135 | orbingol/NURBS-Python | geomdl/exchange.py | export_cfg | def export_cfg(obj, file_name):
""" Exports curves and surfaces in libconfig format.
.. note::
Requires `libconf <https://pypi.org/project/libconf/>`_ package.
Libconfig format is also used by the `geomdl command-line application <https://github.com/orbingol/geomdl-cli>`_
as a way to input sh... | python | def export_cfg(obj, file_name):
def callback(data):
return libconf.dumps(data)
# Check if it is possible to import 'libconf'
try:
import libconf
except ImportError:
raise exch.GeomdlException("Please install 'libconf' package to use libconfig format: pip install libconf")
#... | [
"def",
"export_cfg",
"(",
"obj",
",",
"file_name",
")",
":",
"def",
"callback",
"(",
"data",
")",
":",
"return",
"libconf",
".",
"dumps",
"(",
"data",
")",
"# Check if it is possible to import 'libconf'",
"try",
":",
"import",
"libconf",
"except",
"ImportError",... | Exports curves and surfaces in libconfig format.
.. note::
Requires `libconf <https://pypi.org/project/libconf/>`_ package.
Libconfig format is also used by the `geomdl command-line application <https://github.com/orbingol/geomdl-cli>`_
as a way to input shape data from the command line.
:pa... | [
"Exports",
"curves",
"and",
"surfaces",
"in",
"libconfig",
"format",
"."
] | b1c6a8b51cf143ff58761438e93ba6baef470627 | https://github.com/orbingol/NURBS-Python/blob/b1c6a8b51cf143ff58761438e93ba6baef470627/geomdl/exchange.py#L233-L262 |
244,136 | orbingol/NURBS-Python | geomdl/exchange.py | import_yaml | def import_yaml(file_name, **kwargs):
""" Imports curves and surfaces from files in YAML format.
.. note::
Requires `ruamel.yaml <https://pypi.org/project/ruamel.yaml/>`_ package.
Use ``jinja2=True`` to activate Jinja2 template processing. Please refer to the documentation for details.
:para... | python | def import_yaml(file_name, **kwargs):
def callback(data):
yaml = YAML()
return yaml.load(data)
# Check if it is possible to import 'ruamel.yaml'
try:
from ruamel.yaml import YAML
except ImportError:
raise exch.GeomdlException("Please install 'ruamel.yaml' package to use ... | [
"def",
"import_yaml",
"(",
"file_name",
",",
"*",
"*",
"kwargs",
")",
":",
"def",
"callback",
"(",
"data",
")",
":",
"yaml",
"=",
"YAML",
"(",
")",
"return",
"yaml",
".",
"load",
"(",
"data",
")",
"# Check if it is possible to import 'ruamel.yaml'",
"try",
... | Imports curves and surfaces from files in YAML format.
.. note::
Requires `ruamel.yaml <https://pypi.org/project/ruamel.yaml/>`_ package.
Use ``jinja2=True`` to activate Jinja2 template processing. Please refer to the documentation for details.
:param file_name: name of the input file
:type ... | [
"Imports",
"curves",
"and",
"surfaces",
"from",
"files",
"in",
"YAML",
"format",
"."
] | b1c6a8b51cf143ff58761438e93ba6baef470627 | https://github.com/orbingol/NURBS-Python/blob/b1c6a8b51cf143ff58761438e93ba6baef470627/geomdl/exchange.py#L266-L299 |
244,137 | orbingol/NURBS-Python | geomdl/exchange.py | export_yaml | def export_yaml(obj, file_name):
""" Exports curves and surfaces in YAML format.
.. note::
Requires `ruamel.yaml <https://pypi.org/project/ruamel.yaml/>`_ package.
YAML format is also used by the `geomdl command-line application <https://github.com/orbingol/geomdl-cli>`_
as a way to input sha... | python | def export_yaml(obj, file_name):
def callback(data):
# Ref: https://yaml.readthedocs.io/en/latest/example.html#output-of-dump-as-a-string
stream = StringIO()
yaml = YAML()
yaml.dump(data, stream)
return stream.getvalue()
# Check if it is possible to import 'ruamel.yaml'
... | [
"def",
"export_yaml",
"(",
"obj",
",",
"file_name",
")",
":",
"def",
"callback",
"(",
"data",
")",
":",
"# Ref: https://yaml.readthedocs.io/en/latest/example.html#output-of-dump-as-a-string",
"stream",
"=",
"StringIO",
"(",
")",
"yaml",
"=",
"YAML",
"(",
")",
"yaml"... | Exports curves and surfaces in YAML format.
.. note::
Requires `ruamel.yaml <https://pypi.org/project/ruamel.yaml/>`_ package.
YAML format is also used by the `geomdl command-line application <https://github.com/orbingol/geomdl-cli>`_
as a way to input shape data from the command line.
:para... | [
"Exports",
"curves",
"and",
"surfaces",
"in",
"YAML",
"format",
"."
] | b1c6a8b51cf143ff58761438e93ba6baef470627 | https://github.com/orbingol/NURBS-Python/blob/b1c6a8b51cf143ff58761438e93ba6baef470627/geomdl/exchange.py#L303-L336 |
244,138 | orbingol/NURBS-Python | geomdl/exchange.py | import_json | def import_json(file_name, **kwargs):
""" Imports curves and surfaces from files in JSON format.
Use ``jinja2=True`` to activate Jinja2 template processing. Please refer to the documentation for details.
:param file_name: name of the input file
:type file_name: str
:return: a list of rational spli... | python | def import_json(file_name, **kwargs):
def callback(data):
return json.loads(data)
# Get keyword arguments
delta = kwargs.get('delta', -1.0)
use_template = kwargs.get('jinja2', False)
# Read file
file_src = exch.read_file(file_name)
# Import data
return exch.import_dict_str(fil... | [
"def",
"import_json",
"(",
"file_name",
",",
"*",
"*",
"kwargs",
")",
":",
"def",
"callback",
"(",
"data",
")",
":",
"return",
"json",
".",
"loads",
"(",
"data",
")",
"# Get keyword arguments",
"delta",
"=",
"kwargs",
".",
"get",
"(",
"'delta'",
",",
"... | Imports curves and surfaces from files in JSON format.
Use ``jinja2=True`` to activate Jinja2 template processing. Please refer to the documentation for details.
:param file_name: name of the input file
:type file_name: str
:return: a list of rational spline geometries
:rtype: list
:raises Geo... | [
"Imports",
"curves",
"and",
"surfaces",
"from",
"files",
"in",
"JSON",
"format",
"."
] | b1c6a8b51cf143ff58761438e93ba6baef470627 | https://github.com/orbingol/NURBS-Python/blob/b1c6a8b51cf143ff58761438e93ba6baef470627/geomdl/exchange.py#L340-L362 |
244,139 | orbingol/NURBS-Python | geomdl/exchange.py | export_json | def export_json(obj, file_name):
""" Exports curves and surfaces in JSON format.
JSON format is also used by the `geomdl command-line application <https://github.com/orbingol/geomdl-cli>`_
as a way to input shape data from the command line.
:param obj: input geometry
:type obj: abstract.SplineGeom... | python | def export_json(obj, file_name):
def callback(data):
return json.dumps(data, indent=4)
# Export data
exported_data = exch.export_dict_str(obj=obj, callback=callback)
# Write to file
return exch.write_file(file_name, exported_data) | [
"def",
"export_json",
"(",
"obj",
",",
"file_name",
")",
":",
"def",
"callback",
"(",
"data",
")",
":",
"return",
"json",
".",
"dumps",
"(",
"data",
",",
"indent",
"=",
"4",
")",
"# Export data",
"exported_data",
"=",
"exch",
".",
"export_dict_str",
"(",... | Exports curves and surfaces in JSON format.
JSON format is also used by the `geomdl command-line application <https://github.com/orbingol/geomdl-cli>`_
as a way to input shape data from the command line.
:param obj: input geometry
:type obj: abstract.SplineGeometry, multi.AbstractContainer
:param ... | [
"Exports",
"curves",
"and",
"surfaces",
"in",
"JSON",
"format",
"."
] | b1c6a8b51cf143ff58761438e93ba6baef470627 | https://github.com/orbingol/NURBS-Python/blob/b1c6a8b51cf143ff58761438e93ba6baef470627/geomdl/exchange.py#L366-L385 |
244,140 | orbingol/NURBS-Python | geomdl/exchange.py | import_obj | def import_obj(file_name, **kwargs):
""" Reads .obj files and generates faces.
Keyword Arguments:
* ``callback``: reference to the function that processes the faces for customized output
The structure of the callback function is shown below:
.. code-block:: python
def my_callback_fun... | python | def import_obj(file_name, **kwargs):
def default_callback(face_list):
return face_list
# Keyword arguments
callback_func = kwargs.get('callback', default_callback)
# Read and process the input file
content = exch.read_file(file_name)
content_arr = content.split("\n")
# Initialize ... | [
"def",
"import_obj",
"(",
"file_name",
",",
"*",
"*",
"kwargs",
")",
":",
"def",
"default_callback",
"(",
"face_list",
")",
":",
"return",
"face_list",
"# Keyword arguments",
"callback_func",
"=",
"kwargs",
".",
"get",
"(",
"'callback'",
",",
"default_callback",... | Reads .obj files and generates faces.
Keyword Arguments:
* ``callback``: reference to the function that processes the faces for customized output
The structure of the callback function is shown below:
.. code-block:: python
def my_callback_function(face_list):
# "face_list" w... | [
"Reads",
".",
"obj",
"files",
"and",
"generates",
"faces",
"."
] | b1c6a8b51cf143ff58761438e93ba6baef470627 | https://github.com/orbingol/NURBS-Python/blob/b1c6a8b51cf143ff58761438e93ba6baef470627/geomdl/exchange.py#L389-L460 |
244,141 | orbingol/NURBS-Python | geomdl/multi.py | select_color | def select_color(cpcolor, evalcolor, idx=0):
""" Selects item color for plotting.
:param cpcolor: color for control points grid item
:type cpcolor: str, list, tuple
:param evalcolor: color for evaluated points grid item
:type evalcolor: str, list, tuple
:param idx: index of the current geometry... | python | def select_color(cpcolor, evalcolor, idx=0):
# Random colors by default
color = utilities.color_generator()
# Constant color for control points grid
if isinstance(cpcolor, str):
color[0] = cpcolor
# User-defined color for control points grid
if isinstance(cpcolor, (list, tuple)):
... | [
"def",
"select_color",
"(",
"cpcolor",
",",
"evalcolor",
",",
"idx",
"=",
"0",
")",
":",
"# Random colors by default",
"color",
"=",
"utilities",
".",
"color_generator",
"(",
")",
"# Constant color for control points grid",
"if",
"isinstance",
"(",
"cpcolor",
",",
... | Selects item color for plotting.
:param cpcolor: color for control points grid item
:type cpcolor: str, list, tuple
:param evalcolor: color for evaluated points grid item
:type evalcolor: str, list, tuple
:param idx: index of the current geometry object
:type idx: int
:return: a list of col... | [
"Selects",
"item",
"color",
"for",
"plotting",
"."
] | b1c6a8b51cf143ff58761438e93ba6baef470627 | https://github.com/orbingol/NURBS-Python/blob/b1c6a8b51cf143ff58761438e93ba6baef470627/geomdl/multi.py#L1080-L1111 |
244,142 | orbingol/NURBS-Python | geomdl/multi.py | process_tessellate | def process_tessellate(elem, update_delta, delta, **kwargs):
""" Tessellates surfaces.
.. note:: Helper function required for ``multiprocessing``
:param elem: surface
:type elem: abstract.Surface
:param update_delta: flag to control evaluation delta updates
:type update_delta: bool
:param ... | python | def process_tessellate(elem, update_delta, delta, **kwargs):
if update_delta:
elem.delta = delta
elem.evaluate()
elem.tessellate(**kwargs)
return elem | [
"def",
"process_tessellate",
"(",
"elem",
",",
"update_delta",
",",
"delta",
",",
"*",
"*",
"kwargs",
")",
":",
"if",
"update_delta",
":",
"elem",
".",
"delta",
"=",
"delta",
"elem",
".",
"evaluate",
"(",
")",
"elem",
".",
"tessellate",
"(",
"*",
"*",
... | Tessellates surfaces.
.. note:: Helper function required for ``multiprocessing``
:param elem: surface
:type elem: abstract.Surface
:param update_delta: flag to control evaluation delta updates
:type update_delta: bool
:param delta: evaluation delta
:type delta: list, tuple
:return: upd... | [
"Tessellates",
"surfaces",
"."
] | b1c6a8b51cf143ff58761438e93ba6baef470627 | https://github.com/orbingol/NURBS-Python/blob/b1c6a8b51cf143ff58761438e93ba6baef470627/geomdl/multi.py#L1114-L1132 |
244,143 | orbingol/NURBS-Python | geomdl/multi.py | process_elements_surface | def process_elements_surface(elem, mconf, colorval, idx, force_tsl, update_delta, delta, reset_names):
""" Processes visualization elements for surfaces.
.. note:: Helper function required for ``multiprocessing``
:param elem: surface
:type elem: abstract.Surface
:param mconf: visualization module ... | python | def process_elements_surface(elem, mconf, colorval, idx, force_tsl, update_delta, delta, reset_names):
if idx < 0:
lock.acquire()
idx = counter.value
counter.value += 1
lock.release()
if update_delta:
elem.delta = delta
elem.evaluate()
# Reset element name
i... | [
"def",
"process_elements_surface",
"(",
"elem",
",",
"mconf",
",",
"colorval",
",",
"idx",
",",
"force_tsl",
",",
"update_delta",
",",
"delta",
",",
"reset_names",
")",
":",
"if",
"idx",
"<",
"0",
":",
"lock",
".",
"acquire",
"(",
")",
"idx",
"=",
"cou... | Processes visualization elements for surfaces.
.. note:: Helper function required for ``multiprocessing``
:param elem: surface
:type elem: abstract.Surface
:param mconf: visualization module configuration
:type mconf: dict
:param colorval: color values
:type colorval: tuple
:param idx:... | [
"Processes",
"visualization",
"elements",
"for",
"surfaces",
"."
] | b1c6a8b51cf143ff58761438e93ba6baef470627 | https://github.com/orbingol/NURBS-Python/blob/b1c6a8b51cf143ff58761438e93ba6baef470627/geomdl/multi.py#L1135-L1224 |
244,144 | orbingol/NURBS-Python | geomdl/helpers.py | find_span_binsearch | def find_span_binsearch(degree, knot_vector, num_ctrlpts, knot, **kwargs):
""" Finds the span of the knot over the input knot vector using binary search.
Implementation of Algorithm A2.1 from The NURBS Book by Piegl & Tiller.
The NURBS Book states that the knot span index always starts from zero, i.e. for... | python | def find_span_binsearch(degree, knot_vector, num_ctrlpts, knot, **kwargs):
# Get tolerance value
tol = kwargs.get('tol', 10e-6)
# In The NURBS Book; number of knots = m + 1, number of control points = n + 1, p = degree
# All knot vectors should follow the rule: m = p + n + 1
n = num_ctrlpts - 1
... | [
"def",
"find_span_binsearch",
"(",
"degree",
",",
"knot_vector",
",",
"num_ctrlpts",
",",
"knot",
",",
"*",
"*",
"kwargs",
")",
":",
"# Get tolerance value",
"tol",
"=",
"kwargs",
".",
"get",
"(",
"'tol'",
",",
"10e-6",
")",
"# In The NURBS Book; number of knots... | Finds the span of the knot over the input knot vector using binary search.
Implementation of Algorithm A2.1 from The NURBS Book by Piegl & Tiller.
The NURBS Book states that the knot span index always starts from zero, i.e. for a knot vector [0, 0, 1, 1];
if FindSpan returns 1, then the knot is between th... | [
"Finds",
"the",
"span",
"of",
"the",
"knot",
"over",
"the",
"input",
"knot",
"vector",
"using",
"binary",
"search",
"."
] | b1c6a8b51cf143ff58761438e93ba6baef470627 | https://github.com/orbingol/NURBS-Python/blob/b1c6a8b51cf143ff58761438e93ba6baef470627/geomdl/helpers.py#L20-L68 |
244,145 | orbingol/NURBS-Python | geomdl/helpers.py | find_span_linear | def find_span_linear(degree, knot_vector, num_ctrlpts, knot, **kwargs):
""" Finds the span of a single knot over the knot vector using linear search.
Alternative implementation for the Algorithm A2.1 from The NURBS Book by Piegl & Tiller.
:param degree: degree, :math:`p`
:type degree: int
:param k... | python | def find_span_linear(degree, knot_vector, num_ctrlpts, knot, **kwargs):
span = 0 # Knot span index starts from zero
while span < num_ctrlpts and knot_vector[span] <= knot:
span += 1
return span - 1 | [
"def",
"find_span_linear",
"(",
"degree",
",",
"knot_vector",
",",
"num_ctrlpts",
",",
"knot",
",",
"*",
"*",
"kwargs",
")",
":",
"span",
"=",
"0",
"# Knot span index starts from zero",
"while",
"span",
"<",
"num_ctrlpts",
"and",
"knot_vector",
"[",
"span",
"]... | Finds the span of a single knot over the knot vector using linear search.
Alternative implementation for the Algorithm A2.1 from The NURBS Book by Piegl & Tiller.
:param degree: degree, :math:`p`
:type degree: int
:param knot_vector: knot vector, :math:`U`
:type knot_vector: list, tuple
:param... | [
"Finds",
"the",
"span",
"of",
"a",
"single",
"knot",
"over",
"the",
"knot",
"vector",
"using",
"linear",
"search",
"."
] | b1c6a8b51cf143ff58761438e93ba6baef470627 | https://github.com/orbingol/NURBS-Python/blob/b1c6a8b51cf143ff58761438e93ba6baef470627/geomdl/helpers.py#L71-L91 |
244,146 | orbingol/NURBS-Python | geomdl/helpers.py | find_spans | def find_spans(degree, knot_vector, num_ctrlpts, knots, func=find_span_linear):
""" Finds spans of a list of knots over the knot vector.
:param degree: degree, :math:`p`
:type degree: int
:param knot_vector: knot vector, :math:`U`
:type knot_vector: list, tuple
:param num_ctrlpts: number of con... | python | def find_spans(degree, knot_vector, num_ctrlpts, knots, func=find_span_linear):
spans = []
for knot in knots:
spans.append(func(degree, knot_vector, num_ctrlpts, knot))
return spans | [
"def",
"find_spans",
"(",
"degree",
",",
"knot_vector",
",",
"num_ctrlpts",
",",
"knots",
",",
"func",
"=",
"find_span_linear",
")",
":",
"spans",
"=",
"[",
"]",
"for",
"knot",
"in",
"knots",
":",
"spans",
".",
"append",
"(",
"func",
"(",
"degree",
","... | Finds spans of a list of knots over the knot vector.
:param degree: degree, :math:`p`
:type degree: int
:param knot_vector: knot vector, :math:`U`
:type knot_vector: list, tuple
:param num_ctrlpts: number of control points, :math:`n + 1`
:type num_ctrlpts: int
:param knots: list of knots or... | [
"Finds",
"spans",
"of",
"a",
"list",
"of",
"knots",
"over",
"the",
"knot",
"vector",
"."
] | b1c6a8b51cf143ff58761438e93ba6baef470627 | https://github.com/orbingol/NURBS-Python/blob/b1c6a8b51cf143ff58761438e93ba6baef470627/geomdl/helpers.py#L94-L112 |
244,147 | orbingol/NURBS-Python | geomdl/helpers.py | find_multiplicity | def find_multiplicity(knot, knot_vector, **kwargs):
""" Finds knot multiplicity over the knot vector.
Keyword Arguments:
* ``tol``: tolerance (delta) value for equality checking
:param knot: knot or parameter, :math:`u`
:type knot: float
:param knot_vector: knot vector, :math:`U`
:type... | python | def find_multiplicity(knot, knot_vector, **kwargs):
# Get tolerance value
tol = kwargs.get('tol', 10e-8)
mult = 0 # initial multiplicity
for kv in knot_vector:
if abs(knot - kv) <= tol:
mult += 1
return mult | [
"def",
"find_multiplicity",
"(",
"knot",
",",
"knot_vector",
",",
"*",
"*",
"kwargs",
")",
":",
"# Get tolerance value",
"tol",
"=",
"kwargs",
".",
"get",
"(",
"'tol'",
",",
"10e-8",
")",
"mult",
"=",
"0",
"# initial multiplicity",
"for",
"kv",
"in",
"knot... | Finds knot multiplicity over the knot vector.
Keyword Arguments:
* ``tol``: tolerance (delta) value for equality checking
:param knot: knot or parameter, :math:`u`
:type knot: float
:param knot_vector: knot vector, :math:`U`
:type knot_vector: list, tuple
:return: knot multiplicity, :m... | [
"Finds",
"knot",
"multiplicity",
"over",
"the",
"knot",
"vector",
"."
] | b1c6a8b51cf143ff58761438e93ba6baef470627 | https://github.com/orbingol/NURBS-Python/blob/b1c6a8b51cf143ff58761438e93ba6baef470627/geomdl/helpers.py#L115-L137 |
244,148 | orbingol/NURBS-Python | geomdl/helpers.py | basis_function | def basis_function(degree, knot_vector, span, knot):
""" Computes the non-vanishing basis functions for a single parameter.
Implementation of Algorithm A2.2 from The NURBS Book by Piegl & Tiller.
:param degree: degree, :math:`p`
:type degree: int
:param knot_vector: knot vector, :math:`U`
:typ... | python | def basis_function(degree, knot_vector, span, knot):
left = [0.0 for _ in range(degree + 1)]
right = [0.0 for _ in range(degree + 1)]
N = [1.0 for _ in range(degree + 1)] # N[0] = 1.0 by definition
for j in range(1, degree + 1):
left[j] = knot - knot_vector[span + 1 - j]
right[j] = kno... | [
"def",
"basis_function",
"(",
"degree",
",",
"knot_vector",
",",
"span",
",",
"knot",
")",
":",
"left",
"=",
"[",
"0.0",
"for",
"_",
"in",
"range",
"(",
"degree",
"+",
"1",
")",
"]",
"right",
"=",
"[",
"0.0",
"for",
"_",
"in",
"range",
"(",
"degr... | Computes the non-vanishing basis functions for a single parameter.
Implementation of Algorithm A2.2 from The NURBS Book by Piegl & Tiller.
:param degree: degree, :math:`p`
:type degree: int
:param knot_vector: knot vector, :math:`U`
:type knot_vector: list, tuple
:param span: knot span, :math:... | [
"Computes",
"the",
"non",
"-",
"vanishing",
"basis",
"functions",
"for",
"a",
"single",
"parameter",
"."
] | b1c6a8b51cf143ff58761438e93ba6baef470627 | https://github.com/orbingol/NURBS-Python/blob/b1c6a8b51cf143ff58761438e93ba6baef470627/geomdl/helpers.py#L140-L170 |
244,149 | orbingol/NURBS-Python | geomdl/helpers.py | basis_functions | def basis_functions(degree, knot_vector, spans, knots):
""" Computes the non-vanishing basis functions for a list of parameters.
:param degree: degree, :math:`p`
:type degree: int
:param knot_vector: knot vector, :math:`U`
:type knot_vector: list, tuple
:param spans: list of knot spans
:typ... | python | def basis_functions(degree, knot_vector, spans, knots):
basis = []
for span, knot in zip(spans, knots):
basis.append(basis_function(degree, knot_vector, span, knot))
return basis | [
"def",
"basis_functions",
"(",
"degree",
",",
"knot_vector",
",",
"spans",
",",
"knots",
")",
":",
"basis",
"=",
"[",
"]",
"for",
"span",
",",
"knot",
"in",
"zip",
"(",
"spans",
",",
"knots",
")",
":",
"basis",
".",
"append",
"(",
"basis_function",
"... | Computes the non-vanishing basis functions for a list of parameters.
:param degree: degree, :math:`p`
:type degree: int
:param knot_vector: knot vector, :math:`U`
:type knot_vector: list, tuple
:param spans: list of knot spans
:type spans: list, tuple
:param knots: list of knots or paramet... | [
"Computes",
"the",
"non",
"-",
"vanishing",
"basis",
"functions",
"for",
"a",
"list",
"of",
"parameters",
"."
] | b1c6a8b51cf143ff58761438e93ba6baef470627 | https://github.com/orbingol/NURBS-Python/blob/b1c6a8b51cf143ff58761438e93ba6baef470627/geomdl/helpers.py#L173-L190 |
244,150 | orbingol/NURBS-Python | geomdl/helpers.py | basis_function_all | def basis_function_all(degree, knot_vector, span, knot):
""" Computes all non-zero basis functions of all degrees from 0 up to the input degree for a single parameter.
A slightly modified version of Algorithm A2.2 from The NURBS Book by Piegl & Tiller.
:param degree: degree, :math:`p`
:type degree: in... | python | def basis_function_all(degree, knot_vector, span, knot):
N = [[None for _ in range(degree + 1)] for _ in range(degree + 1)]
for i in range(0, degree + 1):
bfuns = basis_function(i, knot_vector, span, knot)
for j in range(0, i + 1):
N[j][i] = bfuns[j]
return N | [
"def",
"basis_function_all",
"(",
"degree",
",",
"knot_vector",
",",
"span",
",",
"knot",
")",
":",
"N",
"=",
"[",
"[",
"None",
"for",
"_",
"in",
"range",
"(",
"degree",
"+",
"1",
")",
"]",
"for",
"_",
"in",
"range",
"(",
"degree",
"+",
"1",
")",... | Computes all non-zero basis functions of all degrees from 0 up to the input degree for a single parameter.
A slightly modified version of Algorithm A2.2 from The NURBS Book by Piegl & Tiller.
:param degree: degree, :math:`p`
:type degree: int
:param knot_vector: knot vector, :math:`U`
:type knot_... | [
"Computes",
"all",
"non",
"-",
"zero",
"basis",
"functions",
"of",
"all",
"degrees",
"from",
"0",
"up",
"to",
"the",
"input",
"degree",
"for",
"a",
"single",
"parameter",
"."
] | b1c6a8b51cf143ff58761438e93ba6baef470627 | https://github.com/orbingol/NURBS-Python/blob/b1c6a8b51cf143ff58761438e93ba6baef470627/geomdl/helpers.py#L193-L214 |
244,151 | orbingol/NURBS-Python | geomdl/helpers.py | basis_functions_ders | def basis_functions_ders(degree, knot_vector, spans, knots, order):
""" Computes derivatives of the basis functions for a list of parameters.
:param degree: degree, :math:`p`
:type degree: int
:param knot_vector: knot vector, :math:`U`
:type knot_vector: list, tuple
:param spans: list of knot s... | python | def basis_functions_ders(degree, knot_vector, spans, knots, order):
basis_ders = []
for span, knot in zip(spans, knots):
basis_ders.append(basis_function_ders(degree, knot_vector, span, knot, order))
return basis_ders | [
"def",
"basis_functions_ders",
"(",
"degree",
",",
"knot_vector",
",",
"spans",
",",
"knots",
",",
"order",
")",
":",
"basis_ders",
"=",
"[",
"]",
"for",
"span",
",",
"knot",
"in",
"zip",
"(",
"spans",
",",
"knots",
")",
":",
"basis_ders",
".",
"append... | Computes derivatives of the basis functions for a list of parameters.
:param degree: degree, :math:`p`
:type degree: int
:param knot_vector: knot vector, :math:`U`
:type knot_vector: list, tuple
:param spans: list of knot spans
:type spans: list, tuple
:param knots: list of knots or parame... | [
"Computes",
"derivatives",
"of",
"the",
"basis",
"functions",
"for",
"a",
"list",
"of",
"parameters",
"."
] | b1c6a8b51cf143ff58761438e93ba6baef470627 | https://github.com/orbingol/NURBS-Python/blob/b1c6a8b51cf143ff58761438e93ba6baef470627/geomdl/helpers.py#L307-L326 |
244,152 | orbingol/NURBS-Python | geomdl/helpers.py | basis_function_one | def basis_function_one(degree, knot_vector, span, knot):
""" Computes the value of a basis function for a single parameter.
Implementation of Algorithm 2.4 from The NURBS Book by Piegl & Tiller.
:param degree: degree, :math:`p`
:type degree: int
:param knot_vector: knot vector
:type knot_vecto... | python | def basis_function_one(degree, knot_vector, span, knot):
# Special case at boundaries
if (span == 0 and knot == knot_vector[0]) or \
(span == len(knot_vector) - degree - 2) and knot == knot_vector[len(knot_vector) - 1]:
return 1.0
# Knot is outside of span range
if knot < knot_vecto... | [
"def",
"basis_function_one",
"(",
"degree",
",",
"knot_vector",
",",
"span",
",",
"knot",
")",
":",
"# Special case at boundaries",
"if",
"(",
"span",
"==",
"0",
"and",
"knot",
"==",
"knot_vector",
"[",
"0",
"]",
")",
"or",
"(",
"span",
"==",
"len",
"(",... | Computes the value of a basis function for a single parameter.
Implementation of Algorithm 2.4 from The NURBS Book by Piegl & Tiller.
:param degree: degree, :math:`p`
:type degree: int
:param knot_vector: knot vector
:type knot_vector: list, tuple
:param span: knot span, :math:`i`
:type sp... | [
"Computes",
"the",
"value",
"of",
"a",
"basis",
"function",
"for",
"a",
"single",
"parameter",
"."
] | b1c6a8b51cf143ff58761438e93ba6baef470627 | https://github.com/orbingol/NURBS-Python/blob/b1c6a8b51cf143ff58761438e93ba6baef470627/geomdl/helpers.py#L329-L381 |
244,153 | orbingol/NURBS-Python | geomdl/visualization/VisMPL.py | VisConfig.set_axes_equal | def set_axes_equal(ax):
""" Sets equal aspect ratio across the three axes of a 3D plot.
Contributed by Xuefeng Zhao.
:param ax: a Matplotlib axis, e.g., as output from plt.gca().
"""
bounds = [ax.get_xlim3d(), ax.get_ylim3d(), ax.get_zlim3d()]
ranges = [abs(bound[1] - b... | python | def set_axes_equal(ax):
bounds = [ax.get_xlim3d(), ax.get_ylim3d(), ax.get_zlim3d()]
ranges = [abs(bound[1] - bound[0]) for bound in bounds]
centers = [np.mean(bound) for bound in bounds]
radius = 0.5 * max(ranges)
lower_limits = centers - radius
upper_limits = centers + ... | [
"def",
"set_axes_equal",
"(",
"ax",
")",
":",
"bounds",
"=",
"[",
"ax",
".",
"get_xlim3d",
"(",
")",
",",
"ax",
".",
"get_ylim3d",
"(",
")",
",",
"ax",
".",
"get_zlim3d",
"(",
")",
"]",
"ranges",
"=",
"[",
"abs",
"(",
"bound",
"[",
"1",
"]",
"-... | Sets equal aspect ratio across the three axes of a 3D plot.
Contributed by Xuefeng Zhao.
:param ax: a Matplotlib axis, e.g., as output from plt.gca(). | [
"Sets",
"equal",
"aspect",
"ratio",
"across",
"the",
"three",
"axes",
"of",
"a",
"3D",
"plot",
"."
] | b1c6a8b51cf143ff58761438e93ba6baef470627 | https://github.com/orbingol/NURBS-Python/blob/b1c6a8b51cf143ff58761438e93ba6baef470627/geomdl/visualization/VisMPL.py#L88-L103 |
244,154 | orbingol/NURBS-Python | geomdl/visualization/VisMPL.py | VisSurface.animate | def animate(self, **kwargs):
""" Animates the surface.
This function only animates the triangulated surface. There will be no other elements, such as control points
grid or bounding box.
Keyword arguments:
* ``colormap``: applies colormap to the surface
Colormaps a... | python | def animate(self, **kwargs):
# Calling parent render function
super(VisSurface, self).render(**kwargs)
# Colormaps
surf_cmaps = kwargs.get('colormap', None)
# Initialize variables
tri_idxs = []
vert_coords = []
trisurf_params = []
frames = []
... | [
"def",
"animate",
"(",
"self",
",",
"*",
"*",
"kwargs",
")",
":",
"# Calling parent render function",
"super",
"(",
"VisSurface",
",",
"self",
")",
".",
"render",
"(",
"*",
"*",
"kwargs",
")",
"# Colormaps",
"surf_cmaps",
"=",
"kwargs",
".",
"get",
"(",
... | Animates the surface.
This function only animates the triangulated surface. There will be no other elements, such as control points
grid or bounding box.
Keyword arguments:
* ``colormap``: applies colormap to the surface
Colormaps are a visualization feature of Matplotlib.... | [
"Animates",
"the",
"surface",
"."
] | b1c6a8b51cf143ff58761438e93ba6baef470627 | https://github.com/orbingol/NURBS-Python/blob/b1c6a8b51cf143ff58761438e93ba6baef470627/geomdl/visualization/VisMPL.py#L298-L402 |
244,155 | orbingol/NURBS-Python | geomdl/_operations.py | tangent_curve_single_list | def tangent_curve_single_list(obj, param_list, normalize):
""" Evaluates the curve tangent vectors at the given list of parameter values.
:param obj: input curve
:type obj: abstract.Curve
:param param_list: parameter list
:type param_list: list or tuple
:param normalize: if True, the returned v... | python | def tangent_curve_single_list(obj, param_list, normalize):
ret_vector = []
for param in param_list:
temp = tangent_curve_single(obj, param, normalize)
ret_vector.append(temp)
return tuple(ret_vector) | [
"def",
"tangent_curve_single_list",
"(",
"obj",
",",
"param_list",
",",
"normalize",
")",
":",
"ret_vector",
"=",
"[",
"]",
"for",
"param",
"in",
"param_list",
":",
"temp",
"=",
"tangent_curve_single",
"(",
"obj",
",",
"param",
",",
"normalize",
")",
"ret_ve... | Evaluates the curve tangent vectors at the given list of parameter values.
:param obj: input curve
:type obj: abstract.Curve
:param param_list: parameter list
:type param_list: list or tuple
:param normalize: if True, the returned vector is converted to a unit vector
:type normalize: bool
:... | [
"Evaluates",
"the",
"curve",
"tangent",
"vectors",
"at",
"the",
"given",
"list",
"of",
"parameter",
"values",
"."
] | b1c6a8b51cf143ff58761438e93ba6baef470627 | https://github.com/orbingol/NURBS-Python/blob/b1c6a8b51cf143ff58761438e93ba6baef470627/geomdl/_operations.py#L41-L57 |
244,156 | orbingol/NURBS-Python | geomdl/_operations.py | normal_curve_single | def normal_curve_single(obj, u, normalize):
""" Evaluates the curve normal vector at the input parameter, u.
Curve normal is calculated from the 2nd derivative of the curve at the input parameter, u.
The output returns a list containing the starting point (i.e. origin) of the vector and the vector itself.
... | python | def normal_curve_single(obj, u, normalize):
# 2nd derivative of the curve gives the normal
ders = obj.derivatives(u, 2)
point = ders[0]
vector = linalg.vector_normalize(ders[2]) if normalize else ders[2]
return tuple(point), tuple(vector) | [
"def",
"normal_curve_single",
"(",
"obj",
",",
"u",
",",
"normalize",
")",
":",
"# 2nd derivative of the curve gives the normal",
"ders",
"=",
"obj",
".",
"derivatives",
"(",
"u",
",",
"2",
")",
"point",
"=",
"ders",
"[",
"0",
"]",
"vector",
"=",
"linalg",
... | Evaluates the curve normal vector at the input parameter, u.
Curve normal is calculated from the 2nd derivative of the curve at the input parameter, u.
The output returns a list containing the starting point (i.e. origin) of the vector and the vector itself.
:param obj: input curve
:type obj: abstract... | [
"Evaluates",
"the",
"curve",
"normal",
"vector",
"at",
"the",
"input",
"parameter",
"u",
"."
] | b1c6a8b51cf143ff58761438e93ba6baef470627 | https://github.com/orbingol/NURBS-Python/blob/b1c6a8b51cf143ff58761438e93ba6baef470627/geomdl/_operations.py#L60-L81 |
244,157 | orbingol/NURBS-Python | geomdl/_operations.py | normal_curve_single_list | def normal_curve_single_list(obj, param_list, normalize):
""" Evaluates the curve normal vectors at the given list of parameter values.
:param obj: input curve
:type obj: abstract.Curve
:param param_list: parameter list
:type param_list: list or tuple
:param normalize: if True, the returned vec... | python | def normal_curve_single_list(obj, param_list, normalize):
ret_vector = []
for param in param_list:
temp = normal_curve_single(obj, param, normalize)
ret_vector.append(temp)
return tuple(ret_vector) | [
"def",
"normal_curve_single_list",
"(",
"obj",
",",
"param_list",
",",
"normalize",
")",
":",
"ret_vector",
"=",
"[",
"]",
"for",
"param",
"in",
"param_list",
":",
"temp",
"=",
"normal_curve_single",
"(",
"obj",
",",
"param",
",",
"normalize",
")",
"ret_vect... | Evaluates the curve normal vectors at the given list of parameter values.
:param obj: input curve
:type obj: abstract.Curve
:param param_list: parameter list
:type param_list: list or tuple
:param normalize: if True, the returned vector is converted to a unit vector
:type normalize: bool
:r... | [
"Evaluates",
"the",
"curve",
"normal",
"vectors",
"at",
"the",
"given",
"list",
"of",
"parameter",
"values",
"."
] | b1c6a8b51cf143ff58761438e93ba6baef470627 | https://github.com/orbingol/NURBS-Python/blob/b1c6a8b51cf143ff58761438e93ba6baef470627/geomdl/_operations.py#L84-L100 |
244,158 | orbingol/NURBS-Python | geomdl/_operations.py | binormal_curve_single | def binormal_curve_single(obj, u, normalize):
""" Evaluates the curve binormal vector at the given u parameter.
Curve binormal is the cross product of the normal and the tangent vectors.
The output returns a list containing the starting point (i.e. origin) of the vector and the vector itself.
:param o... | python | def binormal_curve_single(obj, u, normalize):
# Cross product of tangent and normal vectors gives binormal vector
tan_vector = tangent_curve_single(obj, u, normalize)
norm_vector = normal_curve_single(obj, u, normalize)
point = tan_vector[0]
vector = linalg.vector_cross(tan_vector[1], norm_vector[1... | [
"def",
"binormal_curve_single",
"(",
"obj",
",",
"u",
",",
"normalize",
")",
":",
"# Cross product of tangent and normal vectors gives binormal vector",
"tan_vector",
"=",
"tangent_curve_single",
"(",
"obj",
",",
"u",
",",
"normalize",
")",
"norm_vector",
"=",
"normal_c... | Evaluates the curve binormal vector at the given u parameter.
Curve binormal is the cross product of the normal and the tangent vectors.
The output returns a list containing the starting point (i.e. origin) of the vector and the vector itself.
:param obj: input curve
:type obj: abstract.Curve
:par... | [
"Evaluates",
"the",
"curve",
"binormal",
"vector",
"at",
"the",
"given",
"u",
"parameter",
"."
] | b1c6a8b51cf143ff58761438e93ba6baef470627 | https://github.com/orbingol/NURBS-Python/blob/b1c6a8b51cf143ff58761438e93ba6baef470627/geomdl/_operations.py#L103-L126 |
244,159 | orbingol/NURBS-Python | geomdl/_operations.py | binormal_curve_single_list | def binormal_curve_single_list(obj, param_list, normalize):
""" Evaluates the curve binormal vectors at the given list of parameter values.
:param obj: input curve
:type obj: abstract.Curve
:param param_list: parameter list
:type param_list: list or tuple
:param normalize: if True, the returned... | python | def binormal_curve_single_list(obj, param_list, normalize):
ret_vector = []
for param in param_list:
temp = binormal_curve_single(obj, param, normalize)
ret_vector.append(temp)
return tuple(ret_vector) | [
"def",
"binormal_curve_single_list",
"(",
"obj",
",",
"param_list",
",",
"normalize",
")",
":",
"ret_vector",
"=",
"[",
"]",
"for",
"param",
"in",
"param_list",
":",
"temp",
"=",
"binormal_curve_single",
"(",
"obj",
",",
"param",
",",
"normalize",
")",
"ret_... | Evaluates the curve binormal vectors at the given list of parameter values.
:param obj: input curve
:type obj: abstract.Curve
:param param_list: parameter list
:type param_list: list or tuple
:param normalize: if True, the returned vector is converted to a unit vector
:type normalize: bool
... | [
"Evaluates",
"the",
"curve",
"binormal",
"vectors",
"at",
"the",
"given",
"list",
"of",
"parameter",
"values",
"."
] | b1c6a8b51cf143ff58761438e93ba6baef470627 | https://github.com/orbingol/NURBS-Python/blob/b1c6a8b51cf143ff58761438e93ba6baef470627/geomdl/_operations.py#L129-L145 |
244,160 | orbingol/NURBS-Python | geomdl/_operations.py | tangent_surface_single_list | def tangent_surface_single_list(obj, param_list, normalize):
""" Evaluates the surface tangent vectors at the given list of parameter values.
:param obj: input surface
:type obj: abstract.Surface
:param param_list: parameter list
:type param_list: list or tuple
:param normalize: if True, the re... | python | def tangent_surface_single_list(obj, param_list, normalize):
ret_vector = []
for param in param_list:
temp = tangent_surface_single(obj, param, normalize)
ret_vector.append(temp)
return tuple(ret_vector) | [
"def",
"tangent_surface_single_list",
"(",
"obj",
",",
"param_list",
",",
"normalize",
")",
":",
"ret_vector",
"=",
"[",
"]",
"for",
"param",
"in",
"param_list",
":",
"temp",
"=",
"tangent_surface_single",
"(",
"obj",
",",
"param",
",",
"normalize",
")",
"re... | Evaluates the surface tangent vectors at the given list of parameter values.
:param obj: input surface
:type obj: abstract.Surface
:param param_list: parameter list
:type param_list: list or tuple
:param normalize: if True, the returned vector is converted to a unit vector
:type normalize: bool... | [
"Evaluates",
"the",
"surface",
"tangent",
"vectors",
"at",
"the",
"given",
"list",
"of",
"parameter",
"values",
"."
] | b1c6a8b51cf143ff58761438e93ba6baef470627 | https://github.com/orbingol/NURBS-Python/blob/b1c6a8b51cf143ff58761438e93ba6baef470627/geomdl/_operations.py#L172-L188 |
244,161 | orbingol/NURBS-Python | geomdl/_operations.py | normal_surface_single_list | def normal_surface_single_list(obj, param_list, normalize):
""" Evaluates the surface normal vectors at the given list of parameter values.
:param obj: input surface
:type obj: abstract.Surface
:param param_list: parameter list
:type param_list: list or tuple
:param normalize: if True, the retu... | python | def normal_surface_single_list(obj, param_list, normalize):
ret_vector = []
for param in param_list:
temp = normal_surface_single(obj, param, normalize)
ret_vector.append(temp)
return tuple(ret_vector) | [
"def",
"normal_surface_single_list",
"(",
"obj",
",",
"param_list",
",",
"normalize",
")",
":",
"ret_vector",
"=",
"[",
"]",
"for",
"param",
"in",
"param_list",
":",
"temp",
"=",
"normal_surface_single",
"(",
"obj",
",",
"param",
",",
"normalize",
")",
"ret_... | Evaluates the surface normal vectors at the given list of parameter values.
:param obj: input surface
:type obj: abstract.Surface
:param param_list: parameter list
:type param_list: list or tuple
:param normalize: if True, the returned vector is converted to a unit vector
:type normalize: bool
... | [
"Evaluates",
"the",
"surface",
"normal",
"vectors",
"at",
"the",
"given",
"list",
"of",
"parameter",
"values",
"."
] | b1c6a8b51cf143ff58761438e93ba6baef470627 | https://github.com/orbingol/NURBS-Python/blob/b1c6a8b51cf143ff58761438e93ba6baef470627/geomdl/_operations.py#L215-L231 |
244,162 | orbingol/NURBS-Python | geomdl/_operations.py | find_ctrlpts_curve | def find_ctrlpts_curve(t, curve, **kwargs):
""" Finds the control points involved in the evaluation of the curve point defined by the input parameter.
This function uses a modified version of the algorithm *A3.1 CurvePoint* from The NURBS Book by Piegl & Tiller.
:param t: parameter
:type t: float
... | python | def find_ctrlpts_curve(t, curve, **kwargs):
# Get keyword arguments
span_func = kwargs.get('find_span_func', helpers.find_span_linear)
# Find spans and the constant index
span = span_func(curve.degree, curve.knotvector, len(curve.ctrlpts), t)
idx = span - curve.degree
# Find control points inv... | [
"def",
"find_ctrlpts_curve",
"(",
"t",
",",
"curve",
",",
"*",
"*",
"kwargs",
")",
":",
"# Get keyword arguments",
"span_func",
"=",
"kwargs",
".",
"get",
"(",
"'find_span_func'",
",",
"helpers",
".",
"find_span_linear",
")",
"# Find spans and the constant index",
... | Finds the control points involved in the evaluation of the curve point defined by the input parameter.
This function uses a modified version of the algorithm *A3.1 CurvePoint* from The NURBS Book by Piegl & Tiller.
:param t: parameter
:type t: float
:param curve: input curve object
:type curve: ab... | [
"Finds",
"the",
"control",
"points",
"involved",
"in",
"the",
"evaluation",
"of",
"the",
"curve",
"point",
"defined",
"by",
"the",
"input",
"parameter",
"."
] | b1c6a8b51cf143ff58761438e93ba6baef470627 | https://github.com/orbingol/NURBS-Python/blob/b1c6a8b51cf143ff58761438e93ba6baef470627/geomdl/_operations.py#L234-L259 |
244,163 | orbingol/NURBS-Python | geomdl/_operations.py | find_ctrlpts_surface | def find_ctrlpts_surface(t_u, t_v, surf, **kwargs):
""" Finds the control points involved in the evaluation of the surface point defined by the input parameter pair.
This function uses a modified version of the algorithm *A3.5 SurfacePoint* from The NURBS Book by Piegl & Tiller.
:param t_u: parameter on t... | python | def find_ctrlpts_surface(t_u, t_v, surf, **kwargs):
# Get keyword arguments
span_func = kwargs.get('find_span_func', helpers.find_span_linear)
# Find spans
span_u = span_func(surf.degree_u, surf.knotvector_u, surf.ctrlpts_size_u, t_u)
span_v = span_func(surf.degree_v, surf.knotvector_v, surf.ctrlpt... | [
"def",
"find_ctrlpts_surface",
"(",
"t_u",
",",
"t_v",
",",
"surf",
",",
"*",
"*",
"kwargs",
")",
":",
"# Get keyword arguments",
"span_func",
"=",
"kwargs",
".",
"get",
"(",
"'find_span_func'",
",",
"helpers",
".",
"find_span_linear",
")",
"# Find spans",
"sp... | Finds the control points involved in the evaluation of the surface point defined by the input parameter pair.
This function uses a modified version of the algorithm *A3.5 SurfacePoint* from The NURBS Book by Piegl & Tiller.
:param t_u: parameter on the u-direction
:type t_u: float
:param t_v: paramete... | [
"Finds",
"the",
"control",
"points",
"involved",
"in",
"the",
"evaluation",
"of",
"the",
"surface",
"point",
"defined",
"by",
"the",
"input",
"parameter",
"pair",
"."
] | b1c6a8b51cf143ff58761438e93ba6baef470627 | https://github.com/orbingol/NURBS-Python/blob/b1c6a8b51cf143ff58761438e93ba6baef470627/geomdl/_operations.py#L262-L296 |
244,164 | orbingol/NURBS-Python | geomdl/_operations.py | link_curves | def link_curves(*args, **kwargs):
""" Links the input curves together.
The end control point of the curve k has to be the same with the start control point of the curve k + 1.
Keyword Arguments:
* ``tol``: tolerance value for checking equality. *Default: 10e-8*
* ``validate``: flag to enab... | python | def link_curves(*args, **kwargs):
# Get keyword arguments
tol = kwargs.get('tol', 10e-8)
validate = kwargs.get('validate', False)
# Validate input
if validate:
for idx in range(len(args) - 1):
if linalg.point_distance(args[idx].ctrlpts[-1], args[idx + 1].ctrlpts[0]) > tol:
... | [
"def",
"link_curves",
"(",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"# Get keyword arguments",
"tol",
"=",
"kwargs",
".",
"get",
"(",
"'tol'",
",",
"10e-8",
")",
"validate",
"=",
"kwargs",
".",
"get",
"(",
"'validate'",
",",
"False",
")",
"# Val... | Links the input curves together.
The end control point of the curve k has to be the same with the start control point of the curve k + 1.
Keyword Arguments:
* ``tol``: tolerance value for checking equality. *Default: 10e-8*
* ``validate``: flag to enable input validation. *Default: False*
... | [
"Links",
"the",
"input",
"curves",
"together",
"."
] | b1c6a8b51cf143ff58761438e93ba6baef470627 | https://github.com/orbingol/NURBS-Python/blob/b1c6a8b51cf143ff58761438e93ba6baef470627/geomdl/_operations.py#L299-L357 |
244,165 | orbingol/NURBS-Python | geomdl/operations.py | add_dimension | def add_dimension(obj, **kwargs):
""" Elevates the spatial dimension of the spline geometry.
If you pass ``inplace=True`` keyword argument, the input will be updated. Otherwise, this function does not
change the input but returns a new instance with the updated data.
:param obj: spline geometry
:t... | python | def add_dimension(obj, **kwargs):
if not isinstance(obj, abstract.SplineGeometry):
raise GeomdlException("Can only operate on spline geometry objects")
# Keyword arguments
inplace = kwargs.get('inplace', False)
array_init = kwargs.get('array_init', [[] for _ in range(len(obj.ctrlpts))])
off... | [
"def",
"add_dimension",
"(",
"obj",
",",
"*",
"*",
"kwargs",
")",
":",
"if",
"not",
"isinstance",
"(",
"obj",
",",
"abstract",
".",
"SplineGeometry",
")",
":",
"raise",
"GeomdlException",
"(",
"\"Can only operate on spline geometry objects\"",
")",
"# Keyword argu... | Elevates the spatial dimension of the spline geometry.
If you pass ``inplace=True`` keyword argument, the input will be updated. Otherwise, this function does not
change the input but returns a new instance with the updated data.
:param obj: spline geometry
:type obj: abstract.SplineGeometry
:retu... | [
"Elevates",
"the",
"spatial",
"dimension",
"of",
"the",
"spline",
"geometry",
"."
] | b1c6a8b51cf143ff58761438e93ba6baef470627 | https://github.com/orbingol/NURBS-Python/blob/b1c6a8b51cf143ff58761438e93ba6baef470627/geomdl/operations.py#L877-L909 |
244,166 | orbingol/NURBS-Python | geomdl/operations.py | split_curve | def split_curve(obj, param, **kwargs):
""" Splits the curve at the input parametric coordinate.
This method splits the curve into two pieces at the given parametric coordinate, generates two different
curve objects and returns them. It does not modify the input curve.
Keyword Arguments:
* ``fi... | python | def split_curve(obj, param, **kwargs):
# Validate input
if not isinstance(obj, abstract.Curve):
raise GeomdlException("Input shape must be an instance of abstract.Curve class")
if param == obj.knotvector[0] or param == obj.knotvector[-1]:
raise GeomdlException("Cannot split on the corner po... | [
"def",
"split_curve",
"(",
"obj",
",",
"param",
",",
"*",
"*",
"kwargs",
")",
":",
"# Validate input",
"if",
"not",
"isinstance",
"(",
"obj",
",",
"abstract",
".",
"Curve",
")",
":",
"raise",
"GeomdlException",
"(",
"\"Input shape must be an instance of abstract... | Splits the curve at the input parametric coordinate.
This method splits the curve into two pieces at the given parametric coordinate, generates two different
curve objects and returns them. It does not modify the input curve.
Keyword Arguments:
* ``find_span_func``: FindSpan implementation. *Defau... | [
"Splits",
"the",
"curve",
"at",
"the",
"input",
"parametric",
"coordinate",
"."
] | b1c6a8b51cf143ff58761438e93ba6baef470627 | https://github.com/orbingol/NURBS-Python/blob/b1c6a8b51cf143ff58761438e93ba6baef470627/geomdl/operations.py#L913-L979 |
244,167 | orbingol/NURBS-Python | geomdl/operations.py | decompose_curve | def decompose_curve(obj, **kwargs):
""" Decomposes the curve into Bezier curve segments of the same degree.
This operation does not modify the input curve, instead it returns the split curve segments.
Keyword Arguments:
* ``find_span_func``: FindSpan implementation. *Default:* :func:`.helpers.find... | python | def decompose_curve(obj, **kwargs):
if not isinstance(obj, abstract.Curve):
raise GeomdlException("Input shape must be an instance of abstract.Curve class")
multi_curve = []
curve = copy.deepcopy(obj)
knots = curve.knotvector[curve.degree + 1:-(curve.degree + 1)]
while knots:
knot =... | [
"def",
"decompose_curve",
"(",
"obj",
",",
"*",
"*",
"kwargs",
")",
":",
"if",
"not",
"isinstance",
"(",
"obj",
",",
"abstract",
".",
"Curve",
")",
":",
"raise",
"GeomdlException",
"(",
"\"Input shape must be an instance of abstract.Curve class\"",
")",
"multi_cur... | Decomposes the curve into Bezier curve segments of the same degree.
This operation does not modify the input curve, instead it returns the split curve segments.
Keyword Arguments:
* ``find_span_func``: FindSpan implementation. *Default:* :func:`.helpers.find_span_linear`
* ``insert_knot_func``... | [
"Decomposes",
"the",
"curve",
"into",
"Bezier",
"curve",
"segments",
"of",
"the",
"same",
"degree",
"."
] | b1c6a8b51cf143ff58761438e93ba6baef470627 | https://github.com/orbingol/NURBS-Python/blob/b1c6a8b51cf143ff58761438e93ba6baef470627/geomdl/operations.py#L983-L1011 |
244,168 | orbingol/NURBS-Python | geomdl/operations.py | length_curve | def length_curve(obj):
""" Computes the approximate length of the parametric curve.
Uses the following equation to compute the approximate length:
.. math::
\\sum_{i=0}^{n-1} \\sqrt{P_{i + 1}^2-P_{i}^2}
where :math:`n` is number of evaluated curve points and :math:`P` is the n-dimensional po... | python | def length_curve(obj):
if not isinstance(obj, abstract.Curve):
raise GeomdlException("Input shape must be an instance of abstract.Curve class")
length = 0.0
evalpts = obj.evalpts
num_evalpts = len(obj.evalpts)
for idx in range(num_evalpts - 1):
length += linalg.point_distance(evalpt... | [
"def",
"length_curve",
"(",
"obj",
")",
":",
"if",
"not",
"isinstance",
"(",
"obj",
",",
"abstract",
".",
"Curve",
")",
":",
"raise",
"GeomdlException",
"(",
"\"Input shape must be an instance of abstract.Curve class\"",
")",
"length",
"=",
"0.0",
"evalpts",
"=",
... | Computes the approximate length of the parametric curve.
Uses the following equation to compute the approximate length:
.. math::
\\sum_{i=0}^{n-1} \\sqrt{P_{i + 1}^2-P_{i}^2}
where :math:`n` is number of evaluated curve points and :math:`P` is the n-dimensional point.
:param obj: input cur... | [
"Computes",
"the",
"approximate",
"length",
"of",
"the",
"parametric",
"curve",
"."
] | b1c6a8b51cf143ff58761438e93ba6baef470627 | https://github.com/orbingol/NURBS-Python/blob/b1c6a8b51cf143ff58761438e93ba6baef470627/geomdl/operations.py#L1054-L1078 |
244,169 | orbingol/NURBS-Python | geomdl/operations.py | split_surface_u | def split_surface_u(obj, param, **kwargs):
""" Splits the surface at the input parametric coordinate on the u-direction.
This method splits the surface into two pieces at the given parametric coordinate on the u-direction,
generates two different surface objects and returns them. It does not modify the inp... | python | def split_surface_u(obj, param, **kwargs):
# Validate input
if not isinstance(obj, abstract.Surface):
raise GeomdlException("Input shape must be an instance of abstract.Surface class")
if param == obj.knotvector_u[0] or param == obj.knotvector_u[-1]:
raise GeomdlException("Cannot split on t... | [
"def",
"split_surface_u",
"(",
"obj",
",",
"param",
",",
"*",
"*",
"kwargs",
")",
":",
"# Validate input",
"if",
"not",
"isinstance",
"(",
"obj",
",",
"abstract",
".",
"Surface",
")",
":",
"raise",
"GeomdlException",
"(",
"\"Input shape must be an instance of ab... | Splits the surface at the input parametric coordinate on the u-direction.
This method splits the surface into two pieces at the given parametric coordinate on the u-direction,
generates two different surface objects and returns them. It does not modify the input surface.
Keyword Arguments:
* ``fin... | [
"Splits",
"the",
"surface",
"at",
"the",
"input",
"parametric",
"coordinate",
"on",
"the",
"u",
"-",
"direction",
"."
] | b1c6a8b51cf143ff58761438e93ba6baef470627 | https://github.com/orbingol/NURBS-Python/blob/b1c6a8b51cf143ff58761438e93ba6baef470627/geomdl/operations.py#L1082-L1151 |
244,170 | orbingol/NURBS-Python | geomdl/operations.py | decompose_surface | def decompose_surface(obj, **kwargs):
""" Decomposes the surface into Bezier surface patches of the same degree.
This operation does not modify the input surface, instead it returns the surface patches.
Keyword Arguments:
* ``find_span_func``: FindSpan implementation. *Default:* :func:`.helpers.fi... | python | def decompose_surface(obj, **kwargs):
def decompose(srf, idx, split_func_list, **kws):
srf_list = []
knots = srf.knotvector[idx][srf.degree[idx] + 1:-(srf.degree[idx] + 1)]
while knots:
knot = knots[0]
srfs = split_func_list[idx](srf, param=knot, **kws)
sr... | [
"def",
"decompose_surface",
"(",
"obj",
",",
"*",
"*",
"kwargs",
")",
":",
"def",
"decompose",
"(",
"srf",
",",
"idx",
",",
"split_func_list",
",",
"*",
"*",
"kws",
")",
":",
"srf_list",
"=",
"[",
"]",
"knots",
"=",
"srf",
".",
"knotvector",
"[",
"... | Decomposes the surface into Bezier surface patches of the same degree.
This operation does not modify the input surface, instead it returns the surface patches.
Keyword Arguments:
* ``find_span_func``: FindSpan implementation. *Default:* :func:`.helpers.find_span_linear`
* ``insert_knot_func``... | [
"Decomposes",
"the",
"surface",
"into",
"Bezier",
"surface",
"patches",
"of",
"the",
"same",
"degree",
"."
] | b1c6a8b51cf143ff58761438e93ba6baef470627 | https://github.com/orbingol/NURBS-Python/blob/b1c6a8b51cf143ff58761438e93ba6baef470627/geomdl/operations.py#L1234-L1293 |
244,171 | orbingol/NURBS-Python | geomdl/operations.py | tangent | def tangent(obj, params, **kwargs):
""" Evaluates the tangent vector of the curves or surfaces at the input parameter values.
This function is designed to evaluate tangent vectors of the B-Spline and NURBS shapes at single or
multiple parameter positions.
:param obj: input shape
:type obj: abstrac... | python | def tangent(obj, params, **kwargs):
normalize = kwargs.get('normalize', True)
if isinstance(obj, abstract.Curve):
if isinstance(params, (list, tuple)):
return ops.tangent_curve_single_list(obj, params, normalize)
else:
return ops.tangent_curve_single(obj, params, normaliz... | [
"def",
"tangent",
"(",
"obj",
",",
"params",
",",
"*",
"*",
"kwargs",
")",
":",
"normalize",
"=",
"kwargs",
".",
"get",
"(",
"'normalize'",
",",
"True",
")",
"if",
"isinstance",
"(",
"obj",
",",
"abstract",
".",
"Curve",
")",
":",
"if",
"isinstance",... | Evaluates the tangent vector of the curves or surfaces at the input parameter values.
This function is designed to evaluate tangent vectors of the B-Spline and NURBS shapes at single or
multiple parameter positions.
:param obj: input shape
:type obj: abstract.Curve or abstract.Surface
:param param... | [
"Evaluates",
"the",
"tangent",
"vector",
"of",
"the",
"curves",
"or",
"surfaces",
"at",
"the",
"input",
"parameter",
"values",
"."
] | b1c6a8b51cf143ff58761438e93ba6baef470627 | https://github.com/orbingol/NURBS-Python/blob/b1c6a8b51cf143ff58761438e93ba6baef470627/geomdl/operations.py#L1392-L1415 |
244,172 | orbingol/NURBS-Python | geomdl/operations.py | normal | def normal(obj, params, **kwargs):
""" Evaluates the normal vector of the curves or surfaces at the input parameter values.
This function is designed to evaluate normal vectors of the B-Spline and NURBS shapes at single or
multiple parameter positions.
:param obj: input geometry
:type obj: abstrac... | python | def normal(obj, params, **kwargs):
normalize = kwargs.get('normalize', True)
if isinstance(obj, abstract.Curve):
if isinstance(params, (list, tuple)):
return ops.normal_curve_single_list(obj, params, normalize)
else:
return ops.normal_curve_single(obj, params, normalize)
... | [
"def",
"normal",
"(",
"obj",
",",
"params",
",",
"*",
"*",
"kwargs",
")",
":",
"normalize",
"=",
"kwargs",
".",
"get",
"(",
"'normalize'",
",",
"True",
")",
"if",
"isinstance",
"(",
"obj",
",",
"abstract",
".",
"Curve",
")",
":",
"if",
"isinstance",
... | Evaluates the normal vector of the curves or surfaces at the input parameter values.
This function is designed to evaluate normal vectors of the B-Spline and NURBS shapes at single or
multiple parameter positions.
:param obj: input geometry
:type obj: abstract.Curve or abstract.Surface
:param para... | [
"Evaluates",
"the",
"normal",
"vector",
"of",
"the",
"curves",
"or",
"surfaces",
"at",
"the",
"input",
"parameter",
"values",
"."
] | b1c6a8b51cf143ff58761438e93ba6baef470627 | https://github.com/orbingol/NURBS-Python/blob/b1c6a8b51cf143ff58761438e93ba6baef470627/geomdl/operations.py#L1419-L1442 |
244,173 | orbingol/NURBS-Python | geomdl/operations.py | binormal | def binormal(obj, params, **kwargs):
""" Evaluates the binormal vector of the curves or surfaces at the input parameter values.
This function is designed to evaluate binormal vectors of the B-Spline and NURBS shapes at single or
multiple parameter positions.
:param obj: input shape
:type obj: abst... | python | def binormal(obj, params, **kwargs):
normalize = kwargs.get('normalize', True)
if isinstance(obj, abstract.Curve):
if isinstance(params, (list, tuple)):
return ops.binormal_curve_single_list(obj, params, normalize)
else:
return ops.binormal_curve_single(obj, params, norma... | [
"def",
"binormal",
"(",
"obj",
",",
"params",
",",
"*",
"*",
"kwargs",
")",
":",
"normalize",
"=",
"kwargs",
".",
"get",
"(",
"'normalize'",
",",
"True",
")",
"if",
"isinstance",
"(",
"obj",
",",
"abstract",
".",
"Curve",
")",
":",
"if",
"isinstance"... | Evaluates the binormal vector of the curves or surfaces at the input parameter values.
This function is designed to evaluate binormal vectors of the B-Spline and NURBS shapes at single or
multiple parameter positions.
:param obj: input shape
:type obj: abstract.Curve or abstract.Surface
:param par... | [
"Evaluates",
"the",
"binormal",
"vector",
"of",
"the",
"curves",
"or",
"surfaces",
"at",
"the",
"input",
"parameter",
"values",
"."
] | b1c6a8b51cf143ff58761438e93ba6baef470627 | https://github.com/orbingol/NURBS-Python/blob/b1c6a8b51cf143ff58761438e93ba6baef470627/geomdl/operations.py#L1446-L1466 |
244,174 | orbingol/NURBS-Python | geomdl/operations.py | translate | def translate(obj, vec, **kwargs):
""" Translates curves, surface or volumes by the input vector.
Keyword Arguments:
* ``inplace``: if False, operation applied to a copy of the object. *Default: False*
:param obj: input geometry
:type obj: abstract.SplineGeometry or multi.AbstractContainer
... | python | def translate(obj, vec, **kwargs):
# Input validity checks
if not vec or not isinstance(vec, (tuple, list)):
raise GeomdlException("The input must be a list or a tuple")
# Input validity checks
if len(vec) != obj.dimension:
raise GeomdlException("The input vector must have " + str(obj.d... | [
"def",
"translate",
"(",
"obj",
",",
"vec",
",",
"*",
"*",
"kwargs",
")",
":",
"# Input validity checks",
"if",
"not",
"vec",
"or",
"not",
"isinstance",
"(",
"vec",
",",
"(",
"tuple",
",",
"list",
")",
")",
":",
"raise",
"GeomdlException",
"(",
"\"The ... | Translates curves, surface or volumes by the input vector.
Keyword Arguments:
* ``inplace``: if False, operation applied to a copy of the object. *Default: False*
:param obj: input geometry
:type obj: abstract.SplineGeometry or multi.AbstractContainer
:param vec: translation vector
:type v... | [
"Translates",
"curves",
"surface",
"or",
"volumes",
"by",
"the",
"input",
"vector",
"."
] | b1c6a8b51cf143ff58761438e93ba6baef470627 | https://github.com/orbingol/NURBS-Python/blob/b1c6a8b51cf143ff58761438e93ba6baef470627/geomdl/operations.py#L1470-L1506 |
244,175 | orbingol/NURBS-Python | geomdl/operations.py | scale | def scale(obj, multiplier, **kwargs):
""" Scales curves, surfaces or volumes by the input multiplier.
Keyword Arguments:
* ``inplace``: if False, operation applied to a copy of the object. *Default: False*
:param obj: input geometry
:type obj: abstract.SplineGeometry, multi.AbstractGeometry
... | python | def scale(obj, multiplier, **kwargs):
# Input validity checks
if not isinstance(multiplier, (int, float)):
raise GeomdlException("The multiplier must be a float or an integer")
# Keyword arguments
inplace = kwargs.get('inplace', False)
if not inplace:
geom = copy.deepcopy(obj)
... | [
"def",
"scale",
"(",
"obj",
",",
"multiplier",
",",
"*",
"*",
"kwargs",
")",
":",
"# Input validity checks",
"if",
"not",
"isinstance",
"(",
"multiplier",
",",
"(",
"int",
",",
"float",
")",
")",
":",
"raise",
"GeomdlException",
"(",
"\"The multiplier must b... | Scales curves, surfaces or volumes by the input multiplier.
Keyword Arguments:
* ``inplace``: if False, operation applied to a copy of the object. *Default: False*
:param obj: input geometry
:type obj: abstract.SplineGeometry, multi.AbstractGeometry
:param multiplier: scaling multiplier
:t... | [
"Scales",
"curves",
"surfaces",
"or",
"volumes",
"by",
"the",
"input",
"multiplier",
"."
] | b1c6a8b51cf143ff58761438e93ba6baef470627 | https://github.com/orbingol/NURBS-Python/blob/b1c6a8b51cf143ff58761438e93ba6baef470627/geomdl/operations.py#L1607-L1638 |
244,176 | orbingol/NURBS-Python | geomdl/voxelize.py | voxelize | def voxelize(obj, **kwargs):
""" Generates binary voxel representation of the surfaces and volumes.
Keyword Arguments:
* ``grid_size``: size of the voxel grid. *Default: (8, 8, 8)*
* ``padding``: voxel padding for in-outs finding. *Default: 10e-8*
* ``use_cubes``: use cube voxels instea... | python | def voxelize(obj, **kwargs):
# Get keyword arguments
grid_size = kwargs.pop('grid_size', (8, 8, 8))
use_cubes = kwargs.pop('use_cubes', False)
num_procs = kwargs.get('num_procs', 1)
if not isinstance(grid_size, (list, tuple)):
raise TypeError("Grid size must be a list or a tuple of integers... | [
"def",
"voxelize",
"(",
"obj",
",",
"*",
"*",
"kwargs",
")",
":",
"# Get keyword arguments",
"grid_size",
"=",
"kwargs",
".",
"pop",
"(",
"'grid_size'",
",",
"(",
"8",
",",
"8",
",",
"8",
")",
")",
"use_cubes",
"=",
"kwargs",
".",
"pop",
"(",
"'use_c... | Generates binary voxel representation of the surfaces and volumes.
Keyword Arguments:
* ``grid_size``: size of the voxel grid. *Default: (8, 8, 8)*
* ``padding``: voxel padding for in-outs finding. *Default: 10e-8*
* ``use_cubes``: use cube voxels instead of cuboid ones. *Default: False*
... | [
"Generates",
"binary",
"voxel",
"representation",
"of",
"the",
"surfaces",
"and",
"volumes",
"."
] | b1c6a8b51cf143ff58761438e93ba6baef470627 | https://github.com/orbingol/NURBS-Python/blob/b1c6a8b51cf143ff58761438e93ba6baef470627/geomdl/voxelize.py#L16-L56 |
244,177 | orbingol/NURBS-Python | geomdl/voxelize.py | convert_bb_to_faces | def convert_bb_to_faces(voxel_grid):
""" Converts a voxel grid defined by min and max coordinates to a voxel grid defined by faces.
:param voxel_grid: voxel grid defined by the bounding box of all voxels
:return: voxel grid with face data
"""
new_vg = []
for v in voxel_grid:
# Vertices
... | python | def convert_bb_to_faces(voxel_grid):
new_vg = []
for v in voxel_grid:
# Vertices
p1 = v[0]
p2 = [v[1][0], v[0][1], v[0][2]]
p3 = [v[1][0], v[1][1], v[0][2]]
p4 = [v[0][0], v[1][1], v[0][2]]
p5 = [v[0][0], v[0][1], v[1][2]]
p6 = [v[1][0], v[0][1], v[1][2]]
... | [
"def",
"convert_bb_to_faces",
"(",
"voxel_grid",
")",
":",
"new_vg",
"=",
"[",
"]",
"for",
"v",
"in",
"voxel_grid",
":",
"# Vertices",
"p1",
"=",
"v",
"[",
"0",
"]",
"p2",
"=",
"[",
"v",
"[",
"1",
"]",
"[",
"0",
"]",
",",
"v",
"[",
"0",
"]",
... | Converts a voxel grid defined by min and max coordinates to a voxel grid defined by faces.
:param voxel_grid: voxel grid defined by the bounding box of all voxels
:return: voxel grid with face data | [
"Converts",
"a",
"voxel",
"grid",
"defined",
"by",
"min",
"and",
"max",
"coordinates",
"to",
"a",
"voxel",
"grid",
"defined",
"by",
"faces",
"."
] | b1c6a8b51cf143ff58761438e93ba6baef470627 | https://github.com/orbingol/NURBS-Python/blob/b1c6a8b51cf143ff58761438e93ba6baef470627/geomdl/voxelize.py#L59-L85 |
244,178 | orbingol/NURBS-Python | geomdl/voxelize.py | save_voxel_grid | def save_voxel_grid(voxel_grid, file_name):
""" Saves binary voxel grid as a binary file.
The binary file is structured in little-endian unsigned int format.
:param voxel_grid: binary voxel grid
:type voxel_grid: list, tuple
:param file_name: file name to save
:type file_name: str
"""
... | python | def save_voxel_grid(voxel_grid, file_name):
try:
with open(file_name, 'wb') as fp:
for voxel in voxel_grid:
fp.write(struct.pack("<I", voxel))
except IOError as e:
print("An error occurred: {}".format(e.args[-1]))
raise e
except Exception:
raise | [
"def",
"save_voxel_grid",
"(",
"voxel_grid",
",",
"file_name",
")",
":",
"try",
":",
"with",
"open",
"(",
"file_name",
",",
"'wb'",
")",
"as",
"fp",
":",
"for",
"voxel",
"in",
"voxel_grid",
":",
"fp",
".",
"write",
"(",
"struct",
".",
"pack",
"(",
"\... | Saves binary voxel grid as a binary file.
The binary file is structured in little-endian unsigned int format.
:param voxel_grid: binary voxel grid
:type voxel_grid: list, tuple
:param file_name: file name to save
:type file_name: str | [
"Saves",
"binary",
"voxel",
"grid",
"as",
"a",
"binary",
"file",
"."
] | b1c6a8b51cf143ff58761438e93ba6baef470627 | https://github.com/orbingol/NURBS-Python/blob/b1c6a8b51cf143ff58761438e93ba6baef470627/geomdl/voxelize.py#L89-L107 |
244,179 | orbingol/NURBS-Python | geomdl/linalg.py | vector_cross | def vector_cross(vector1, vector2):
""" Computes the cross-product of the input vectors.
:param vector1: input vector 1
:type vector1: list, tuple
:param vector2: input vector 2
:type vector2: list, tuple
:return: result of the cross product
:rtype: tuple
"""
try:
if vector1... | python | def vector_cross(vector1, vector2):
try:
if vector1 is None or len(vector1) == 0 or vector2 is None or len(vector2) == 0:
raise ValueError("Input vectors cannot be empty")
except TypeError as e:
print("An error occurred: {}".format(e.args[-1]))
raise TypeError("Input must be ... | [
"def",
"vector_cross",
"(",
"vector1",
",",
"vector2",
")",
":",
"try",
":",
"if",
"vector1",
"is",
"None",
"or",
"len",
"(",
"vector1",
")",
"==",
"0",
"or",
"vector2",
"is",
"None",
"or",
"len",
"(",
"vector2",
")",
"==",
"0",
":",
"raise",
"Valu... | Computes the cross-product of the input vectors.
:param vector1: input vector 1
:type vector1: list, tuple
:param vector2: input vector 2
:type vector2: list, tuple
:return: result of the cross product
:rtype: tuple | [
"Computes",
"the",
"cross",
"-",
"product",
"of",
"the",
"input",
"vectors",
"."
] | b1c6a8b51cf143ff58761438e93ba6baef470627 | https://github.com/orbingol/NURBS-Python/blob/b1c6a8b51cf143ff58761438e93ba6baef470627/geomdl/linalg.py#L20-L59 |
244,180 | orbingol/NURBS-Python | geomdl/linalg.py | vector_dot | def vector_dot(vector1, vector2):
""" Computes the dot-product of the input vectors.
:param vector1: input vector 1
:type vector1: list, tuple
:param vector2: input vector 2
:type vector2: list, tuple
:return: result of the dot product
:rtype: float
"""
try:
if vector1 is No... | python | def vector_dot(vector1, vector2):
try:
if vector1 is None or len(vector1) == 0 or vector2 is None or len(vector2) == 0:
raise ValueError("Input vectors cannot be empty")
except TypeError as e:
print("An error occurred: {}".format(e.args[-1]))
raise TypeError("Input must be a ... | [
"def",
"vector_dot",
"(",
"vector1",
",",
"vector2",
")",
":",
"try",
":",
"if",
"vector1",
"is",
"None",
"or",
"len",
"(",
"vector1",
")",
"==",
"0",
"or",
"vector2",
"is",
"None",
"or",
"len",
"(",
"vector2",
")",
"==",
"0",
":",
"raise",
"ValueE... | Computes the dot-product of the input vectors.
:param vector1: input vector 1
:type vector1: list, tuple
:param vector2: input vector 2
:type vector2: list, tuple
:return: result of the dot product
:rtype: float | [
"Computes",
"the",
"dot",
"-",
"product",
"of",
"the",
"input",
"vectors",
"."
] | b1c6a8b51cf143ff58761438e93ba6baef470627 | https://github.com/orbingol/NURBS-Python/blob/b1c6a8b51cf143ff58761438e93ba6baef470627/geomdl/linalg.py#L62-L87 |
244,181 | orbingol/NURBS-Python | geomdl/linalg.py | vector_sum | def vector_sum(vector1, vector2, coeff=1.0):
""" Sums the vectors.
This function computes the result of the vector operation :math:`\\overline{v}_{1} + c * \\overline{v}_{2}`, where
:math:`\\overline{v}_{1}` is ``vector1``, :math:`\\overline{v}_{2}` is ``vector2`` and :math:`c` is ``coeff``.
:param v... | python | def vector_sum(vector1, vector2, coeff=1.0):
summed_vector = [v1 + (coeff * v2) for v1, v2 in zip(vector1, vector2)]
return summed_vector | [
"def",
"vector_sum",
"(",
"vector1",
",",
"vector2",
",",
"coeff",
"=",
"1.0",
")",
":",
"summed_vector",
"=",
"[",
"v1",
"+",
"(",
"coeff",
"*",
"v2",
")",
"for",
"v1",
",",
"v2",
"in",
"zip",
"(",
"vector1",
",",
"vector2",
")",
"]",
"return",
... | Sums the vectors.
This function computes the result of the vector operation :math:`\\overline{v}_{1} + c * \\overline{v}_{2}`, where
:math:`\\overline{v}_{1}` is ``vector1``, :math:`\\overline{v}_{2}` is ``vector2`` and :math:`c` is ``coeff``.
:param vector1: vector 1
:type vector1: list, tuple
:... | [
"Sums",
"the",
"vectors",
"."
] | b1c6a8b51cf143ff58761438e93ba6baef470627 | https://github.com/orbingol/NURBS-Python/blob/b1c6a8b51cf143ff58761438e93ba6baef470627/geomdl/linalg.py#L106-L122 |
244,182 | orbingol/NURBS-Python | geomdl/linalg.py | vector_normalize | def vector_normalize(vector_in, decimals=18):
""" Generates a unit vector from the input.
:param vector_in: vector to be normalized
:type vector_in: list, tuple
:param decimals: number of significands
:type decimals: int
:return: the normalized vector (i.e. the unit vector)
:rtype: list
... | python | def vector_normalize(vector_in, decimals=18):
try:
if vector_in is None or len(vector_in) == 0:
raise ValueError("Input vector cannot be empty")
except TypeError as e:
print("An error occurred: {}".format(e.args[-1]))
raise TypeError("Input must be a list or tuple")
excep... | [
"def",
"vector_normalize",
"(",
"vector_in",
",",
"decimals",
"=",
"18",
")",
":",
"try",
":",
"if",
"vector_in",
"is",
"None",
"or",
"len",
"(",
"vector_in",
")",
"==",
"0",
":",
"raise",
"ValueError",
"(",
"\"Input vector cannot be empty\"",
")",
"except",... | Generates a unit vector from the input.
:param vector_in: vector to be normalized
:type vector_in: list, tuple
:param decimals: number of significands
:type decimals: int
:return: the normalized vector (i.e. the unit vector)
:rtype: list | [
"Generates",
"a",
"unit",
"vector",
"from",
"the",
"input",
"."
] | b1c6a8b51cf143ff58761438e93ba6baef470627 | https://github.com/orbingol/NURBS-Python/blob/b1c6a8b51cf143ff58761438e93ba6baef470627/geomdl/linalg.py#L125-L156 |
244,183 | orbingol/NURBS-Python | geomdl/linalg.py | vector_generate | def vector_generate(start_pt, end_pt, normalize=False):
""" Generates a vector from 2 input points.
:param start_pt: start point of the vector
:type start_pt: list, tuple
:param end_pt: end point of the vector
:type end_pt: list, tuple
:param normalize: if True, the generated vector is normaliz... | python | def vector_generate(start_pt, end_pt, normalize=False):
try:
if start_pt is None or len(start_pt) == 0 or end_pt is None or len(end_pt) == 0:
raise ValueError("Input points cannot be empty")
except TypeError as e:
print("An error occurred: {}".format(e.args[-1]))
raise TypeEr... | [
"def",
"vector_generate",
"(",
"start_pt",
",",
"end_pt",
",",
"normalize",
"=",
"False",
")",
":",
"try",
":",
"if",
"start_pt",
"is",
"None",
"or",
"len",
"(",
"start_pt",
")",
"==",
"0",
"or",
"end_pt",
"is",
"None",
"or",
"len",
"(",
"end_pt",
")... | Generates a vector from 2 input points.
:param start_pt: start point of the vector
:type start_pt: list, tuple
:param end_pt: end point of the vector
:type end_pt: list, tuple
:param normalize: if True, the generated vector is normalized
:type normalize: bool
:return: a vector from start_pt... | [
"Generates",
"a",
"vector",
"from",
"2",
"input",
"points",
"."
] | b1c6a8b51cf143ff58761438e93ba6baef470627 | https://github.com/orbingol/NURBS-Python/blob/b1c6a8b51cf143ff58761438e93ba6baef470627/geomdl/linalg.py#L159-L186 |
244,184 | orbingol/NURBS-Python | geomdl/linalg.py | vector_magnitude | def vector_magnitude(vector_in):
""" Computes the magnitude of the input vector.
:param vector_in: input vector
:type vector_in: list, tuple
:return: magnitude of the vector
:rtype: float
"""
sq_sum = 0.0
for vin in vector_in:
sq_sum += vin**2
return math.sqrt(sq_sum) | python | def vector_magnitude(vector_in):
sq_sum = 0.0
for vin in vector_in:
sq_sum += vin**2
return math.sqrt(sq_sum) | [
"def",
"vector_magnitude",
"(",
"vector_in",
")",
":",
"sq_sum",
"=",
"0.0",
"for",
"vin",
"in",
"vector_in",
":",
"sq_sum",
"+=",
"vin",
"**",
"2",
"return",
"math",
".",
"sqrt",
"(",
"sq_sum",
")"
] | Computes the magnitude of the input vector.
:param vector_in: input vector
:type vector_in: list, tuple
:return: magnitude of the vector
:rtype: float | [
"Computes",
"the",
"magnitude",
"of",
"the",
"input",
"vector",
"."
] | b1c6a8b51cf143ff58761438e93ba6baef470627 | https://github.com/orbingol/NURBS-Python/blob/b1c6a8b51cf143ff58761438e93ba6baef470627/geomdl/linalg.py#L223-L234 |
244,185 | orbingol/NURBS-Python | geomdl/linalg.py | vector_angle_between | def vector_angle_between(vector1, vector2, **kwargs):
""" Computes the angle between the two input vectors.
If the keyword argument ``degrees`` is set to *True*, then the angle will be in degrees. Otherwise, it will be
in radians. By default, ``degrees`` is set to *True*.
:param vector1: vector
:t... | python | def vector_angle_between(vector1, vector2, **kwargs):
degrees = kwargs.get('degrees', True)
magn1 = vector_magnitude(vector1)
magn2 = vector_magnitude(vector2)
acos_val = vector_dot(vector1, vector2) / (magn1 * magn2)
angle_radians = math.acos(acos_val)
if degrees:
return math.degrees(an... | [
"def",
"vector_angle_between",
"(",
"vector1",
",",
"vector2",
",",
"*",
"*",
"kwargs",
")",
":",
"degrees",
"=",
"kwargs",
".",
"get",
"(",
"'degrees'",
",",
"True",
")",
"magn1",
"=",
"vector_magnitude",
"(",
"vector1",
")",
"magn2",
"=",
"vector_magnitu... | Computes the angle between the two input vectors.
If the keyword argument ``degrees`` is set to *True*, then the angle will be in degrees. Otherwise, it will be
in radians. By default, ``degrees`` is set to *True*.
:param vector1: vector
:type vector1: list, tuple
:param vector2: vector
:type ... | [
"Computes",
"the",
"angle",
"between",
"the",
"two",
"input",
"vectors",
"."
] | b1c6a8b51cf143ff58761438e93ba6baef470627 | https://github.com/orbingol/NURBS-Python/blob/b1c6a8b51cf143ff58761438e93ba6baef470627/geomdl/linalg.py#L237-L258 |
244,186 | orbingol/NURBS-Python | geomdl/linalg.py | vector_is_zero | def vector_is_zero(vector_in, tol=10e-8):
""" Checks if the input vector is a zero vector.
:param vector_in: input vector
:type vector_in: list, tuple
:param tol: tolerance value
:type tol: float
:return: True if the input vector is zero, False otherwise
:rtype: bool
"""
if not isin... | python | def vector_is_zero(vector_in, tol=10e-8):
if not isinstance(vector_in, (list, tuple)):
raise TypeError("Input vector must be a list or a tuple")
res = [False for _ in range(len(vector_in))]
for idx in range(len(vector_in)):
if abs(vector_in[idx]) < tol:
res[idx] = True
retur... | [
"def",
"vector_is_zero",
"(",
"vector_in",
",",
"tol",
"=",
"10e-8",
")",
":",
"if",
"not",
"isinstance",
"(",
"vector_in",
",",
"(",
"list",
",",
"tuple",
")",
")",
":",
"raise",
"TypeError",
"(",
"\"Input vector must be a list or a tuple\"",
")",
"res",
"=... | Checks if the input vector is a zero vector.
:param vector_in: input vector
:type vector_in: list, tuple
:param tol: tolerance value
:type tol: float
:return: True if the input vector is zero, False otherwise
:rtype: bool | [
"Checks",
"if",
"the",
"input",
"vector",
"is",
"a",
"zero",
"vector",
"."
] | b1c6a8b51cf143ff58761438e93ba6baef470627 | https://github.com/orbingol/NURBS-Python/blob/b1c6a8b51cf143ff58761438e93ba6baef470627/geomdl/linalg.py#L261-L278 |
244,187 | orbingol/NURBS-Python | geomdl/linalg.py | point_translate | def point_translate(point_in, vector_in):
""" Translates the input points using the input vector.
:param point_in: input point
:type point_in: list, tuple
:param vector_in: input vector
:type vector_in: list, tuple
:return: translated point
:rtype: list
"""
try:
if point_in ... | python | def point_translate(point_in, vector_in):
try:
if point_in is None or len(point_in) == 0 or vector_in is None or len(vector_in) == 0:
raise ValueError("Input arguments cannot be empty")
except TypeError as e:
print("An error occurred: {}".format(e.args[-1]))
raise TypeError("... | [
"def",
"point_translate",
"(",
"point_in",
",",
"vector_in",
")",
":",
"try",
":",
"if",
"point_in",
"is",
"None",
"or",
"len",
"(",
"point_in",
")",
"==",
"0",
"or",
"vector_in",
"is",
"None",
"or",
"len",
"(",
"vector_in",
")",
"==",
"0",
":",
"rai... | Translates the input points using the input vector.
:param point_in: input point
:type point_in: list, tuple
:param vector_in: input vector
:type vector_in: list, tuple
:return: translated point
:rtype: list | [
"Translates",
"the",
"input",
"points",
"using",
"the",
"input",
"vector",
"."
] | b1c6a8b51cf143ff58761438e93ba6baef470627 | https://github.com/orbingol/NURBS-Python/blob/b1c6a8b51cf143ff58761438e93ba6baef470627/geomdl/linalg.py#L281-L303 |
244,188 | orbingol/NURBS-Python | geomdl/linalg.py | point_distance | def point_distance(pt1, pt2):
""" Computes distance between two points.
:param pt1: point 1
:type pt1: list, tuple
:param pt2: point 2
:type pt2: list, tuple
:return: distance between input points
:rtype: float
"""
if len(pt1) != len(pt2):
raise ValueError("The input points ... | python | def point_distance(pt1, pt2):
if len(pt1) != len(pt2):
raise ValueError("The input points should have the same dimension")
dist_vector = vector_generate(pt1, pt2, normalize=False)
distance = vector_magnitude(dist_vector)
return distance | [
"def",
"point_distance",
"(",
"pt1",
",",
"pt2",
")",
":",
"if",
"len",
"(",
"pt1",
")",
"!=",
"len",
"(",
"pt2",
")",
":",
"raise",
"ValueError",
"(",
"\"The input points should have the same dimension\"",
")",
"dist_vector",
"=",
"vector_generate",
"(",
"pt1... | Computes distance between two points.
:param pt1: point 1
:type pt1: list, tuple
:param pt2: point 2
:type pt2: list, tuple
:return: distance between input points
:rtype: float | [
"Computes",
"distance",
"between",
"two",
"points",
"."
] | b1c6a8b51cf143ff58761438e93ba6baef470627 | https://github.com/orbingol/NURBS-Python/blob/b1c6a8b51cf143ff58761438e93ba6baef470627/geomdl/linalg.py#L306-L321 |
244,189 | orbingol/NURBS-Python | geomdl/linalg.py | point_mid | def point_mid(pt1, pt2):
""" Computes the midpoint of the input points.
:param pt1: point 1
:type pt1: list, tuple
:param pt2: point 2
:type pt2: list, tuple
:return: midpoint
:rtype: list
"""
if len(pt1) != len(pt2):
raise ValueError("The input points should have the same d... | python | def point_mid(pt1, pt2):
if len(pt1) != len(pt2):
raise ValueError("The input points should have the same dimension")
dist_vector = vector_generate(pt1, pt2, normalize=False)
half_dist_vector = vector_multiply(dist_vector, 0.5)
return point_translate(pt1, half_dist_vector) | [
"def",
"point_mid",
"(",
"pt1",
",",
"pt2",
")",
":",
"if",
"len",
"(",
"pt1",
")",
"!=",
"len",
"(",
"pt2",
")",
":",
"raise",
"ValueError",
"(",
"\"The input points should have the same dimension\"",
")",
"dist_vector",
"=",
"vector_generate",
"(",
"pt1",
... | Computes the midpoint of the input points.
:param pt1: point 1
:type pt1: list, tuple
:param pt2: point 2
:type pt2: list, tuple
:return: midpoint
:rtype: list | [
"Computes",
"the",
"midpoint",
"of",
"the",
"input",
"points",
"."
] | b1c6a8b51cf143ff58761438e93ba6baef470627 | https://github.com/orbingol/NURBS-Python/blob/b1c6a8b51cf143ff58761438e93ba6baef470627/geomdl/linalg.py#L324-L339 |
244,190 | orbingol/NURBS-Python | geomdl/linalg.py | matrix_transpose | def matrix_transpose(m):
""" Transposes the input matrix.
The input matrix :math:`m` is a 2-dimensional array.
:param m: input matrix with dimensions :math:`(n \\times m)`
:type m: list, tuple
:return: transpose matrix with dimensions :math:`(m \\times n)`
:rtype: list
"""
num_cols = l... | python | def matrix_transpose(m):
num_cols = len(m)
num_rows = len(m[0])
m_t = []
for i in range(num_rows):
temp = []
for j in range(num_cols):
temp.append(m[j][i])
m_t.append(temp)
return m_t | [
"def",
"matrix_transpose",
"(",
"m",
")",
":",
"num_cols",
"=",
"len",
"(",
"m",
")",
"num_rows",
"=",
"len",
"(",
"m",
"[",
"0",
"]",
")",
"m_t",
"=",
"[",
"]",
"for",
"i",
"in",
"range",
"(",
"num_rows",
")",
":",
"temp",
"=",
"[",
"]",
"fo... | Transposes the input matrix.
The input matrix :math:`m` is a 2-dimensional array.
:param m: input matrix with dimensions :math:`(n \\times m)`
:type m: list, tuple
:return: transpose matrix with dimensions :math:`(m \\times n)`
:rtype: list | [
"Transposes",
"the",
"input",
"matrix",
"."
] | b1c6a8b51cf143ff58761438e93ba6baef470627 | https://github.com/orbingol/NURBS-Python/blob/b1c6a8b51cf143ff58761438e93ba6baef470627/geomdl/linalg.py#L342-L360 |
244,191 | orbingol/NURBS-Python | geomdl/linalg.py | triangle_center | def triangle_center(tri, uv=False):
""" Computes the center of mass of the input triangle.
:param tri: triangle object
:type tri: elements.Triangle
:param uv: if True, then finds parametric position of the center of mass
:type uv: bool
:return: center of mass of the triangle
:rtype: tuple
... | python | def triangle_center(tri, uv=False):
if uv:
data = [t.uv for t in tri]
mid = [0.0, 0.0]
else:
data = tri.vertices
mid = [0.0, 0.0, 0.0]
for vert in data:
mid = [m + v for m, v in zip(mid, vert)]
mid = [float(m) / 3.0 for m in mid]
return tuple(mid) | [
"def",
"triangle_center",
"(",
"tri",
",",
"uv",
"=",
"False",
")",
":",
"if",
"uv",
":",
"data",
"=",
"[",
"t",
".",
"uv",
"for",
"t",
"in",
"tri",
"]",
"mid",
"=",
"[",
"0.0",
",",
"0.0",
"]",
"else",
":",
"data",
"=",
"tri",
".",
"vertices... | Computes the center of mass of the input triangle.
:param tri: triangle object
:type tri: elements.Triangle
:param uv: if True, then finds parametric position of the center of mass
:type uv: bool
:return: center of mass of the triangle
:rtype: tuple | [
"Computes",
"the",
"center",
"of",
"mass",
"of",
"the",
"input",
"triangle",
"."
] | b1c6a8b51cf143ff58761438e93ba6baef470627 | https://github.com/orbingol/NURBS-Python/blob/b1c6a8b51cf143ff58761438e93ba6baef470627/geomdl/linalg.py#L396-L415 |
244,192 | orbingol/NURBS-Python | geomdl/linalg.py | lu_decomposition | def lu_decomposition(matrix_a):
""" LU-Factorization method using Doolittle's Method for solution of linear systems.
Decomposes the matrix :math:`A` such that :math:`A = LU`.
The input matrix is represented by a list or a tuple. The input matrix is **2-dimensional**, i.e. list of lists of
integers and... | python | def lu_decomposition(matrix_a):
# Check if the 2-dimensional input matrix is a square matrix
q = len(matrix_a)
for idx, m_a in enumerate(matrix_a):
if len(m_a) != q:
raise ValueError("The input must be a square matrix. " +
"Row " + str(idx + 1) + " has a size... | [
"def",
"lu_decomposition",
"(",
"matrix_a",
")",
":",
"# Check if the 2-dimensional input matrix is a square matrix",
"q",
"=",
"len",
"(",
"matrix_a",
")",
"for",
"idx",
",",
"m_a",
"in",
"enumerate",
"(",
"matrix_a",
")",
":",
"if",
"len",
"(",
"m_a",
")",
"... | LU-Factorization method using Doolittle's Method for solution of linear systems.
Decomposes the matrix :math:`A` such that :math:`A = LU`.
The input matrix is represented by a list or a tuple. The input matrix is **2-dimensional**, i.e. list of lists of
integers and/or floats.
:param matrix_a: Input ... | [
"LU",
"-",
"Factorization",
"method",
"using",
"Doolittle",
"s",
"Method",
"for",
"solution",
"of",
"linear",
"systems",
"."
] | b1c6a8b51cf143ff58761438e93ba6baef470627 | https://github.com/orbingol/NURBS-Python/blob/b1c6a8b51cf143ff58761438e93ba6baef470627/geomdl/linalg.py#L441-L462 |
244,193 | orbingol/NURBS-Python | geomdl/linalg.py | forward_substitution | def forward_substitution(matrix_l, matrix_b):
""" Forward substitution method for the solution of linear systems.
Solves the equation :math:`Ly = b` using forward substitution method
where :math:`L` is a lower triangular matrix and :math:`b` is a column matrix.
:param matrix_l: L, lower triangular mat... | python | def forward_substitution(matrix_l, matrix_b):
q = len(matrix_b)
matrix_y = [0.0 for _ in range(q)]
matrix_y[0] = float(matrix_b[0]) / float(matrix_l[0][0])
for i in range(1, q):
matrix_y[i] = float(matrix_b[i]) - sum([matrix_l[i][j] * matrix_y[j] for j in range(0, i)])
matrix_y[i] /= flo... | [
"def",
"forward_substitution",
"(",
"matrix_l",
",",
"matrix_b",
")",
":",
"q",
"=",
"len",
"(",
"matrix_b",
")",
"matrix_y",
"=",
"[",
"0.0",
"for",
"_",
"in",
"range",
"(",
"q",
")",
"]",
"matrix_y",
"[",
"0",
"]",
"=",
"float",
"(",
"matrix_b",
... | Forward substitution method for the solution of linear systems.
Solves the equation :math:`Ly = b` using forward substitution method
where :math:`L` is a lower triangular matrix and :math:`b` is a column matrix.
:param matrix_l: L, lower triangular matrix
:type matrix_l: list, tuple
:param matrix_... | [
"Forward",
"substitution",
"method",
"for",
"the",
"solution",
"of",
"linear",
"systems",
"."
] | b1c6a8b51cf143ff58761438e93ba6baef470627 | https://github.com/orbingol/NURBS-Python/blob/b1c6a8b51cf143ff58761438e93ba6baef470627/geomdl/linalg.py#L465-L484 |
244,194 | orbingol/NURBS-Python | geomdl/linalg.py | backward_substitution | def backward_substitution(matrix_u, matrix_y):
""" Backward substitution method for the solution of linear systems.
Solves the equation :math:`Ux = y` using backward substitution method
where :math:`U` is a upper triangular matrix and :math:`y` is a column matrix.
:param matrix_u: U, upper triangular ... | python | def backward_substitution(matrix_u, matrix_y):
q = len(matrix_y)
matrix_x = [0.0 for _ in range(q)]
matrix_x[q - 1] = float(matrix_y[q - 1]) / float(matrix_u[q - 1][q - 1])
for i in range(q - 2, -1, -1):
matrix_x[i] = float(matrix_y[i]) - sum([matrix_u[i][j] * matrix_x[j] for j in range(i, q)])
... | [
"def",
"backward_substitution",
"(",
"matrix_u",
",",
"matrix_y",
")",
":",
"q",
"=",
"len",
"(",
"matrix_y",
")",
"matrix_x",
"=",
"[",
"0.0",
"for",
"_",
"in",
"range",
"(",
"q",
")",
"]",
"matrix_x",
"[",
"q",
"-",
"1",
"]",
"=",
"float",
"(",
... | Backward substitution method for the solution of linear systems.
Solves the equation :math:`Ux = y` using backward substitution method
where :math:`U` is a upper triangular matrix and :math:`y` is a column matrix.
:param matrix_u: U, upper triangular matrix
:type matrix_u: list, tuple
:param matri... | [
"Backward",
"substitution",
"method",
"for",
"the",
"solution",
"of",
"linear",
"systems",
"."
] | b1c6a8b51cf143ff58761438e93ba6baef470627 | https://github.com/orbingol/NURBS-Python/blob/b1c6a8b51cf143ff58761438e93ba6baef470627/geomdl/linalg.py#L487-L506 |
244,195 | orbingol/NURBS-Python | geomdl/linalg.py | linspace | def linspace(start, stop, num, decimals=18):
""" Returns a list of evenly spaced numbers over a specified interval.
Inspired from Numpy's linspace function: https://github.com/numpy/numpy/blob/master/numpy/core/function_base.py
:param start: starting value
:type start: float
:param stop: end value... | python | def linspace(start, stop, num, decimals=18):
start = float(start)
stop = float(stop)
if abs(start - stop) <= 10e-8:
return [start]
num = int(num)
if num > 1:
div = num - 1
delta = stop - start
return [float(("{:." + str(decimals) + "f}").format((start + (float(x) * fl... | [
"def",
"linspace",
"(",
"start",
",",
"stop",
",",
"num",
",",
"decimals",
"=",
"18",
")",
":",
"start",
"=",
"float",
"(",
"start",
")",
"stop",
"=",
"float",
"(",
"stop",
")",
"if",
"abs",
"(",
"start",
"-",
"stop",
")",
"<=",
"10e-8",
":",
"... | Returns a list of evenly spaced numbers over a specified interval.
Inspired from Numpy's linspace function: https://github.com/numpy/numpy/blob/master/numpy/core/function_base.py
:param start: starting value
:type start: float
:param stop: end value
:type stop: float
:param num: number of samp... | [
"Returns",
"a",
"list",
"of",
"evenly",
"spaced",
"numbers",
"over",
"a",
"specified",
"interval",
"."
] | b1c6a8b51cf143ff58761438e93ba6baef470627 | https://github.com/orbingol/NURBS-Python/blob/b1c6a8b51cf143ff58761438e93ba6baef470627/geomdl/linalg.py#L509-L535 |
244,196 | orbingol/NURBS-Python | geomdl/linalg.py | convex_hull | def convex_hull(points):
""" Returns points on convex hull in counterclockwise order according to Graham's scan algorithm.
Reference: https://gist.github.com/arthur-e/5cf52962341310f438e96c1f3c3398b8
.. note:: This implementation only works in 2-dimensional space.
:param points: list of 2-dimensional... | python | def convex_hull(points):
turn_left, turn_right, turn_none = (1, -1, 0)
def cmp(a, b):
return (a > b) - (a < b)
def turn(p, q, r):
return cmp((q[0] - p[0])*(r[1] - p[1]) - (r[0] - p[0])*(q[1] - p[1]), 0)
def keep_left(hull, r):
while len(hull) > 1 and turn(hull[-2], hull[-1], r... | [
"def",
"convex_hull",
"(",
"points",
")",
":",
"turn_left",
",",
"turn_right",
",",
"turn_none",
"=",
"(",
"1",
",",
"-",
"1",
",",
"0",
")",
"def",
"cmp",
"(",
"a",
",",
"b",
")",
":",
"return",
"(",
"a",
">",
"b",
")",
"-",
"(",
"a",
"<",
... | Returns points on convex hull in counterclockwise order according to Graham's scan algorithm.
Reference: https://gist.github.com/arthur-e/5cf52962341310f438e96c1f3c3398b8
.. note:: This implementation only works in 2-dimensional space.
:param points: list of 2-dimensional points
:type points: list, t... | [
"Returns",
"points",
"on",
"convex",
"hull",
"in",
"counterclockwise",
"order",
"according",
"to",
"Graham",
"s",
"scan",
"algorithm",
"."
] | b1c6a8b51cf143ff58761438e93ba6baef470627 | https://github.com/orbingol/NURBS-Python/blob/b1c6a8b51cf143ff58761438e93ba6baef470627/geomdl/linalg.py#L565-L595 |
244,197 | orbingol/NURBS-Python | geomdl/linalg.py | is_left | def is_left(point0, point1, point2):
""" Tests if a point is Left|On|Right of an infinite line.
Ported from the C++ version: on http://geomalgorithms.com/a03-_inclusion.html
.. note:: This implementation only works in 2-dimensional space.
:param point0: Point P0
:param point1: Point P1
:param... | python | def is_left(point0, point1, point2):
return ((point1[0] - point0[0]) * (point2[1] - point0[1])) - ((point2[0] - point0[0]) * (point1[1] - point0[1])) | [
"def",
"is_left",
"(",
"point0",
",",
"point1",
",",
"point2",
")",
":",
"return",
"(",
"(",
"point1",
"[",
"0",
"]",
"-",
"point0",
"[",
"0",
"]",
")",
"*",
"(",
"point2",
"[",
"1",
"]",
"-",
"point0",
"[",
"1",
"]",
")",
")",
"-",
"(",
"(... | Tests if a point is Left|On|Right of an infinite line.
Ported from the C++ version: on http://geomalgorithms.com/a03-_inclusion.html
.. note:: This implementation only works in 2-dimensional space.
:param point0: Point P0
:param point1: Point P1
:param point2: Point P2
:return:
>0 for... | [
"Tests",
"if",
"a",
"point",
"is",
"Left|On|Right",
"of",
"an",
"infinite",
"line",
"."
] | b1c6a8b51cf143ff58761438e93ba6baef470627 | https://github.com/orbingol/NURBS-Python/blob/b1c6a8b51cf143ff58761438e93ba6baef470627/geomdl/linalg.py#L598-L613 |
244,198 | orbingol/NURBS-Python | geomdl/linalg.py | wn_poly | def wn_poly(point, vertices):
""" Winding number test for a point in a polygon.
Ported from the C++ version: http://geomalgorithms.com/a03-_inclusion.html
.. note:: This implementation only works in 2-dimensional space.
:param point: point to be tested
:type point: list, tuple
:param vertices... | python | def wn_poly(point, vertices):
wn = 0 # the winding number counter
v_size = len(vertices) - 1
# loop through all edges of the polygon
for i in range(v_size): # edge from V[i] to V[i+1]
if vertices[i][1] <= point[1]: # start y <= P.y
if vertices[i + 1][1] > point[1]: # an upward c... | [
"def",
"wn_poly",
"(",
"point",
",",
"vertices",
")",
":",
"wn",
"=",
"0",
"# the winding number counter",
"v_size",
"=",
"len",
"(",
"vertices",
")",
"-",
"1",
"# loop through all edges of the polygon",
"for",
"i",
"in",
"range",
"(",
"v_size",
")",
":",
"#... | Winding number test for a point in a polygon.
Ported from the C++ version: http://geomalgorithms.com/a03-_inclusion.html
.. note:: This implementation only works in 2-dimensional space.
:param point: point to be tested
:type point: list, tuple
:param vertices: vertex points of a polygon vertices[... | [
"Winding",
"number",
"test",
"for",
"a",
"point",
"in",
"a",
"polygon",
"."
] | b1c6a8b51cf143ff58761438e93ba6baef470627 | https://github.com/orbingol/NURBS-Python/blob/b1c6a8b51cf143ff58761438e93ba6baef470627/geomdl/linalg.py#L616-L644 |
244,199 | orbingol/NURBS-Python | geomdl/construct.py | construct_surface | def construct_surface(direction, *args, **kwargs):
""" Generates surfaces from curves.
Arguments:
* ``args``: a list of curve instances
Keyword Arguments (optional):
* ``degree``: degree of the 2nd parametric direction
* ``knotvector``: knot vector of the 2nd parametric direction
... | python | def construct_surface(direction, *args, **kwargs):
# Input validation
possible_dirs = ['u', 'v']
if direction not in possible_dirs:
raise GeomdlException("Possible direction values: " + ", ".join([val for val in possible_dirs]),
data=dict(input_dir=direction))
size... | [
"def",
"construct_surface",
"(",
"direction",
",",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"# Input validation",
"possible_dirs",
"=",
"[",
"'u'",
",",
"'v'",
"]",
"if",
"direction",
"not",
"in",
"possible_dirs",
":",
"raise",
"GeomdlException",
"(",... | Generates surfaces from curves.
Arguments:
* ``args``: a list of curve instances
Keyword Arguments (optional):
* ``degree``: degree of the 2nd parametric direction
* ``knotvector``: knot vector of the 2nd parametric direction
* ``rational``: flag to generate rational surfaces
... | [
"Generates",
"surfaces",
"from",
"curves",
"."
] | b1c6a8b51cf143ff58761438e93ba6baef470627 | https://github.com/orbingol/NURBS-Python/blob/b1c6a8b51cf143ff58761438e93ba6baef470627/geomdl/construct.py#L16-L100 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.