Вы находитесь на странице: 1из 92

NURBS-Python Documentation

Release

Onur Rauf Bingol

Jan 28, 2018


Introduction

1 Motivation 3
1.1 Algorithms Implemented . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3
1.2 Citing NURBS-Python . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4
1.3 Author . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4
1.4 Acknowledgments . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4

2 Questions and Answers 5


2.1 What is NURBS? . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5
2.2 Why NURBS-Python? . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5
2.3 Minimum Requirements . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6
2.4 Installing NURBS-Python . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6

3 Installation 7
3.1 Using Pip . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7
3.2 Manual Method . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7

4 Using the Library 9

5 File Formats 11
5.1 TXT Files . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 11
5.2 CSV Files . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 13

6 Visualization 15
6.1 Visualization Component . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 15
6.2 Advanced Visualization Options . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 15
6.3 Examples . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 15

7 Package Name 31

8 Included Modules 33
8.1 B-Spline Module . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 33
8.2 NURBS Module . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 51
8.3 Utilities Module . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 70
8.4 Control Points Generator Module . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 73
8.5 Visualization . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 77

Python Module Index 83

i
ii
NURBS-Python Documentation, Release

Welcome to the NURBS-Python Library documentation! NURBS-Python Library contains native Python implemen-
tations of several The NURBS Book algorithms. These algorithms are used for generating Non-Uniform Rational
B-Spline (NURBS) 2D/3D curves and surfaces.
NURBS-Python also provides a convenient and easy-to-use data structure for storing curve and surface descriptions.
All elements of the provided data structures are documented under Modules.

Note: I would be glad if you cite this repository using the DOI provided as a badge at the top. The link will open up
a new page where you can find all the bibliographic information.

This documentation is organized into a couple sections:


• Introduction
• Examples
• Modules

Introduction 1
NURBS-Python Documentation, Release

2 Introduction
CHAPTER 1

Motivation

NURBS-Python is an object-oriented Python library containing implementations of NURBS 2D/3D curve and surface
generation and evaluation algorithms. It also provides a convenient and easy-to-use data structure for storing curve
and surface descriptions.
Some significant features of NURBS-Python are:
• Fully object-oriented API
• Data structures for storing surface and 2D/3D curve descriptions
• Helper functions, such as automatic uniform knot vector generator and many more
• Control points grid generator for surfaces
• Visualization component, plus a Matplotlib implementation
• CSV export functionality with customizable meshing options
• Python 2.x and 3.x compatibility
• No external C/C++ library dependencies
• No compilation steps necessary, everything is implemented with Python
• Easy to install via pip install NURBS-Python

1.1 Algorithms Implemented

NURBS-Python currently implements the following algorithms from The NURBS Book (2nd Edition) by Piegl &
Tiller:
• A2.1 FindSpan (page 68)
• A2.2 BasisFuns (page 70)
• A2.3 DersBasisFuns (pages 72,73)
• A3.1 CurvePoint (page 82)

3
NURBS-Python Documentation, Release

• A3.2 CurveDerivsAlg1 (page 93)


• A3.3 CurveDerivCpts (page 98)
• A3.4 CurveDerivsAlg2 (pages 99,100)
• A3.5 SurfacePoint (page 103)
• A3.6 SurfaceDerivsAlg1 (pages 111,112)
• A4.1 CurvePoint (page 124)
• A4.2 RatCurveDerivs (page 127)
• A4.3 SurfacePoint (page 134)
• A4.4 RatSurfaceDerivs (pages 137,138)
• A5.1 CurveKnotIns (page 151)
• A5.3 SurfaceKnotIns (pages 155-157)

1.2 Citing NURBS-Python

I would be glad if you cite this repository using the DOI provided. You can also find it as a badge on the main page of
this documentation.

1.3 Author

Onur Rauf Bingol


• E-mail: contact@onurbingol.net
• Twitter: https://twitter.com/orbingol

1.4 Acknowledgments

I would like to thank my PhD adviser, Dr. Adarsh Krishnamurthy, for his guidance and supervision throughout the
course of this project.

4 Chapter 1. Motivation
CHAPTER 2

Questions and Answers

2.1 What is NURBS?

NURBS is an acronym for Non-Uniform Rational Basis Spline and it represents a mathematical model for generation
of curves and surfaces in a flexible way. It is a well-accepted industry standard and used as a basis for nearly all of the
3D modeling and CAD/CAM software packages as well as modeling and visualization frameworks.
Please see the related Wikipedia article or The NURBS Book, a very nice and informative book written by Les A.
Piegl and Wayne Tiller.

2.2 Why NURBS-Python?

The main purpose is implementing the well-known NURBS algorithms in native Python in an organized way and
without using any converters or wrappers, like SWIG or Boost.Python.
Although these wrappers are lifesavers by means of converting C++ code to Python when there are too many deadlines,
their support on the source language might be limited or you might need to learn the wrapper’s own language to get
the things done in your way. Personally speaking, I had to learn Python’s C API to understand how SWIG’s typemap
system works. It takes so much time when you are not well-acquainted with the low-level programming or not willing
to learn a programming language’s internals.
On the other hand, NURBS-Python is designed to get the things done in a fast way. I used object-oriented approach
as much as possible and tried to make the code look more Pythonic and optimized. Since all the code is implemented
in Python natively with no external dependencies, it is possible to use this library in every platform which core Python
programming language is supported or integrate into embedded systems/distributions. Using native implementation
approach also allows users to debug and extend this library very easily.

5
NURBS-Python Documentation, Release

2.3 Minimum Requirements

NURBS-Python is tested on Python versions 2.7.13 and 3.5.3+. It doesn’t require any additional packages, such
as NumPy, so that you can run it even on a plain Python installation as well as on a scientific distribution, such as
Anaconda.

2.4 Installing NURBS-Python

Please see Installation section for details.

Note: Please use the issue tracker on GitHub to report bugs. If you have any questions and/or comments, please feel
free to email the author.

6 Chapter 2. Questions and Answers


CHAPTER 3

Installation

3.1 Using Pip

You can find the NURBS-Python library on Python Package Index and install using the following command:
pip install NURBS-Python

3.2 Manual Method

Included setup.py script will take care of the installation and automatically copy the required files to site-packages
directory. Please run the following from the command line:
python setup.py install
If you don’t want to put the files into your Python distribution’s site-packages directory for some reason, you can run
python setup.py develop
from the command line to generate a link to the package directory inside site-packages.

7
NURBS-Python Documentation, Release

8 Chapter 3. Installation
CHAPTER 4

Using the Library

Please check the Examples repository to find some example scripts on how to use this library.
Please note that I only provide some Python scripts in the Examples repository, nothing fancy. If you are an avid user
of Jupyter, I believe that it would be very easy for you to convert these scripts into Jupyter notebook format.

9
NURBS-Python Documentation, Release

10 Chapter 4. Using the Library


CHAPTER 5

File Formats

5.1 TXT Files

NURBS-Python library provides 2 functions in each class included for reading and saving the control points list.
These are:
• read_ctrlpts_from_txt: Reads control points list from a text file
• save_ctrlpts_to_txt: Saves control points list to a text file
The format of the text file depends on the type of the geometric element, i.e. curve or surface, that you are trying to
export. The following explains the file formats for .txt files which contain control points.

5.1.1 2D Curves

To generate a 2D B-Spline Curve, you need a list of (x, y) coordinates representing the control points (P), where
• x: value representing the x-coordinate
• y: value representing the y-coordinate
The format of the control points file for generating 2D B-Spline curves is as follows:

x y
x1 y1
x2 y2
x3 y3

The control points file format of the NURBS curves are very similiar to B-Spline ones with the difference of weights.
To generate a 2D NURBS curve, you need a list of (x*w, y*w, w) coordinates representing the weighted control points
(Pw ) where,
• x: value representing the x-coordinate
• y: value representing the y-coordinate

11
NURBS-Python Documentation, Release

• w: value representing the weight


The format of the control points file for generating 2D NURBS curves is as follows:

x*w y*w w
x1 *w1 y1 *w1 w1
x2 *w2 y2 *w2 w2
x3 *w3 y3 *w3 w3

5.1.2 3D Curves

To generate a 3D B-Spline curve, you need a list of (x, y, z) coordinates representing the control points (P), where
• x: value representing the x-coordinate
• y: value representing the y-coordinate
• z: value representing the z-coordinate
The format of the control points file for generating 3D B-Spline curves is as follows:

x y z
x1 y1 z1
x2 y2 z2
x3 y3 z3

To generate a 3D NURBS curve, you need a list of (x*w, y*w, z*w, w) coordinates representing the weighted control
points (Pw ) where,
• x: value representing the x-coordinate
• y: value representing the y-coordinate
• z: value representing the z-coordinate
• w: value representing the weight
The format of the control points file for generating 3D NURBS curves is as follows:

x*w y*w z*w w


x1 *w1 y1 *w1 z1 *w1 w1
x2 *w2 y2 *w2 z2 *w2 w2
x3 *w3 y3 *w3 z3 *w3 w3

5.1.3 Surfaces

Control points file for generating B-Spline and NURBS has 2 options:
First option is very similar to the curve control points files with one noticeable difference to process u and v indices.
In this list, the v index varies first. That is, a row of v control points for the first u value is found first. Then, the row of
v control points for the next u value.
The second option sets the rows as v and columns as u. To generate a B-Spline surface using this option, you need a
list of (x, y, z) coordinates representing the control points (P) where,
• x: value representing the x-coordinate

12 Chapter 5. File Formats


NURBS-Python Documentation, Release

• y: value representing the y-coordinate


• z: value representing the z-coordinate
The format of the control points file for generating B-Spline surfaces is as follows:

v0 v1 v2 v3 v4
u0 (x, y, z) (x, y, z) (x, y, z) (x, y, z) (x, y, z)
u1 (x, y, z) (x, y, z) (x, y, z) (x, y, z) (x, y, z)
u2 (x, y, z) (x, y, z) (x, y, z) (x, y, z) (x, y, z)

To generate a NURBS surface using the 2nd option, you need a list of (x*w, y*w, z*w, w) coordinates representing the
weighted control points (Pw ) where,
• x: value representing the x-coordinate
• y: value representing the y-coordinate
• z: value representing the z-coordinate
• w: value representing the weight
The format of the control points file for generating NURBS surfaces is as follows:

v0 v1 v2 v3
u0 (x*w, y*w, z*w, w) (x*w, y*w, z*w, w) (x*w, y*w, z*w, w) (x*w, y*w, z*w, w)
u1 (x*w, y*w, z*w, w) (x*w, y*w, z*w, w) (x*w, y*w, z*w, w) (x*w, y*w, z*w, w)
u2 (x*w, y*w, z*w, w) (x*w, y*w, z*w, w) (x*w, y*w, z*w, w) (x*w, y*w, z*w, w)

Note: The control points correspond to a right-handed coordinate system.

5.2 CSV Files

NURBS-Python library provides 2 functions in each class for exporting control points and evaluted points as CSV
files. These functions are:
For all classes:
• export_ctrlpts_to_csv: Saves control points list as a CSV file
For Curve and Curve2D classes:
• export_curvepts_to_csv: Saves evaluated curve points as a CSV file
For Surface class:
• export_surfpts_to_csv: Saves evaluted surface points as a CSV file

5.2.1 Customization Options

The control points and the evaluated curve points list are always linear and there are no customization options. On the
other hand, CSV exports from surface classes have some customization options.

5.2. CSV Files 13


NURBS-Python Documentation, Release

Surface Control Points

The following modes are available via mode= parameter of the export_ctrlpts_to_csv method:
• linear: Default mode, saves the stored point array without any change
• zigzag: Generates a zig-zag shape
• wireframe: Generates a wireframe

Evaluated Surface Points

The following modes are available via mode= parameter of the export_surfpts_to_csv method:
• linear: Default mode, saves the stored point array without any change
• zigzag: Generates a zig-zag shape
• wireframe: Generates a wireframe/quad mesh
• triangle: Generates a triangular mesh

14 Chapter 5. File Formats


CHAPTER 6

Visualization

6.1 Visualization Component

NURBS-Python v3.x series included an optional visualization module for plotting evaluated curves and surfaces.
Examples repository contains some examples on how to use the visualization component with surfaces and 2D/3D
curves.

6.2 Advanced Visualization Options

visualization/ directory in the Examples repository contains customizable scripts for more advanced visualiza-
tion using Matplotlib.

6.3 Examples

The following examples illustrate the visualization component which comes with the NURBS-Python package and the
advanced visualization options using the scripts in the Examples repository.

6.3.1 Surfaces

The following figures are generated using Matplotlib v2.1.0 from the outputs of the examples shared in the Examples
repository. Please see File Formats section on details of CSV exporting capabilities. Visualization scripts can be found
in the Examples repository under visualization directory.

ex_surface01.py

• Control points CSV export mode: wireframe


• Surface points CSV export mode: linear

15
NURBS-Python Documentation, Release

• Evaluation delta: 0.05


• Script used: mpl_wframe_trisurf.py

• Control points CSV export mode: wireframe


• Surface points CSV export mode: wireframe
• Evaluation delta: 0.005
• Script used: mpl_wframe_wframe.py

16 Chapter 6. Visualization
NURBS-Python Documentation, Release

ex_surface02.py

• Control points CSV export mode: wireframe


• Surface points CSV export mode: linear
• Evaluation delta: 0.05
• Script used: mpl_wframe_trisurf.py

6.3. Examples 17
NURBS-Python Documentation, Release

ex_surface03.py

• Control points CSV export mode: linear


• Surface points CSV export mode: wireframe
• Evaluation delta: 0.05
• Script used: mpl_scatter_wframe.py

18 Chapter 6. Visualization
NURBS-Python Documentation, Release

mpl_trisurf_vectors.py

The following figure illustrates tangent and normal vectors on ex_surface02.py example. The example script
can be found in Examples repository under the visualization directory.

6.3. Examples 19
NURBS-Python Documentation, Release

6.3.2 Curves

The following examples use the visualization component which comes with the NURBS-Python package.

20 Chapter 6. Visualization
NURBS-Python Documentation, Release

ex_curve01.py

6.3. Examples 21
NURBS-Python Documentation, Release

ex_curve02.py

22 Chapter 6. Visualization
NURBS-Python Documentation, Release

ex_curve03.py

6.3. Examples 23
NURBS-Python Documentation, Release

ex_curve04.py

24 Chapter 6. Visualization
NURBS-Python Documentation, Release

ex_curve3d01.py

6.3. Examples 25
NURBS-Python Documentation, Release

ex_curve3d02.py

mpl_curve2d_tangents.py

This example illustrates a more advanced visualization option for plotting the 2D curve tangents alongside with the
control points grid and the evaluated curve. The example script can be found in Examples repository under the
visualization directory.

26 Chapter 6. Visualization
NURBS-Python Documentation, Release

mpl_curve3d_tangents.py

This example illustrates a more advanced visualization option for plotting the 3D curve tangents alongside with the
control points grid and the evaluated curve. The example script can be found in Examples repository under the
visualization directory.

6.3. Examples 27
NURBS-Python Documentation, Release

mpl_curve3d_vectors.py

This example illustrates a visualization option for plotting the 3D curve tangent, normal and binnormal vectors along-
side with the control points grid and the evaluated curve. The example script can be found in Examples repository
under the visualization directory.
Please note that binormal vector evaluation method for the curves is added on version 3.0.6.

28 Chapter 6. Visualization
NURBS-Python Documentation, Release

6.3. Examples 29
NURBS-Python Documentation, Release

30 Chapter 6. Visualization
CHAPTER 7

Package Name

The package name is geomdl which is the shortened version of geometric modeling.
Prior to v3.x series of the NURBS-Python library, the package name was nurbs. However, using a generic name like
that might seem to cause conflicts with other packages, and therefore in v3.x of the library, it is renamed to geomdl.

31
NURBS-Python Documentation, Release

32 Chapter 7. Package Name


CHAPTER 8

Included Modules

The NURBS-Python library is more than a simple NURBS library. It includes 2D/3D curve and surface classes which
contains a convenient data structure implemented with Python properties and evaluation functionality. Everything is
self-contained, there is no need for loading external modules.
Following modules are included in this library:

8.1 B-Spline Module

BSpline module provides data storage and evaluation functions for B-Spline (NUBS) 2D/3D curves and surfaces.

8.1.1 3D B-Spline Curve

class geomdl.BSpline.Curve
Bases: object
A data storage and evaluation class for 3D B-Spline (NUBS) curves.
Data Storage
The following properties are present in this class:
• order
• degree
• knotvector
• delta
• ctrlpts
• curvepts

33
NURBS-Python Documentation, Release

The function read_ctrlpts_from_txt() provides an easy way to read weighted control points from a
text file. Additional details on the file formats can be found in the documentation.

Note: Control points are stored as a list of (x, y, z) coordinates

Evaluation
The evaluation methods are:
• evaluate()
• derivatives()
• tangent()
• insert_knot()
Please check the function reference for the details.

Note: If you update any of the data storage elements after the curve evaluation, the surface points stored in
curvepts property will be deleted automatically.

order
Curve order.
Defined as order = degree + 1
Getter Gets the curve order
Setter Sets the curve order
Type integer
degree
Curve degree.
Getter Gets the curve degree
Setter Sets the curve degree
Type integer
ctrlpts
Control points.
Getter Gets the control points
Setter Sets the control points
Type list
set_ctrlpts(ctrlpts)
Sets control points.
Parameters ctrlpts (list) – input control points as a list of coordinates
Returns None
knotvector
Knot vector.
Getter Gets the knot vector
Setter Sets the knot vector

34 Chapter 8. Included Modules


NURBS-Python Documentation, Release

Type list
delta
Curve evaluation delta.

Note: The delta value is 0.1 by default.

Getter Gets the delta value


Setter Sets the delta value
Type float

curvepts
Evaluated curve points.
Getter (x, y) coordinates of the evaluated surface points
Type list
vis
Visualization component.

Note: The visualization component is completely optional to use.

Getter Gets the visualization component


Setter Sets the visualization component
Type float

render(cpcolor=’blue’, curvecolor=’black’)
Renders the curve using the loaded visualization component
The visualization component must be set using vis property before calling this method.
Parameters
• cpcolor (str) – Color of the control points polygon
• curvecolor (str) – Color of the curve
Returns None
read_ctrlpts_from_txt(filename=”)
Loads control points from a text file.
Parameters filename (str) – input file name
Returns True if control points are loaded correctly, False otherwise
Return type bool
save_ctrlpts_to_txt(filename=”)
Saves control points to a text file.
Parameters filename (str) – output file name
Returns True if control points are saved correctly, False otherwise
Return type bool

8.1. B-Spline Module 35


NURBS-Python Documentation, Release

save_ctrlpts_to_csv(filename=”, scalar=0)
Saves control points to a comma separated text file.
Parameters
• filename (str) – output file name
• scalar (int) – value of the scalar column in the output, defaults to 0
Returns True if control points are saved correctly, False otherwise
Return type bool
save_curvepts_to_csv(filename=”, scalar=0)
Saves evaluated curve points to a comma separated text file.
Parameters
• filename (str) – output file name
• scalar (int) – value of the scalar column in the output, defaults to 0
Returns True if curve points are saved correctly, False otherwise
Return type bool
curvept(u=-1, check_vars=True, get_ctrlpts=False)
Evaluates the B-Spline curve at the given u parameter.
Parameters
• u (float) – parameter
• check_vars (bool) – flag to disable variable checking (only for internal eval functions)
• get_ctrlpts – flag to add a list of control points associated with the curve evaluation
to return value
• get_ctrlpts – bool
Returns evaluated curve point at the given knot value
Return type list
evaluate()
Evaluates the B-Spline curve.

Note: The evaluated surface points are stored in curvepts.

Returns None

derivatives2(u=-1, order=0)
Evaluates n-th order curve derivatives at the given u using Algorithm A3.2.
Parameters
• u (float) – knot value
• order (integer) – derivative order
Returns A list containing up to {order}-th derivative of the curve
Return type list

36 Chapter 8. Included Modules


NURBS-Python Documentation, Release

derivatives_ctrlpts(order=0, r1=0, r2=0)


Computes the control points of all derivative curves up to and including the {degree}-th derivative.
Implements Algorithm A3.3. Output is PK[k][i], i-th control point of the k-th derivative curve where 0 <=
k <= degree and r1 <= i <= r2-k
Parameters
• order (integer) – derivative order
• r1 (integer) – minimum span
• r2 (integer) – maximum span
Returns PK, a 2D list of control points
Return type list
derivatives(u=-1, order=0)
Evaluates n-th order curve derivatives at the given u using Algorithm A3.4.
Parameters
• u (float) – knot value
• order (integer) – derivative order
Returns A list containing up to {order}-th derivative of the curve
Return type list
tangent(u=-1, normalize=False)
Evaluates the curve tangent at the given u parameter.
The output returns a list containing the starting point (i.e. origin) of the vector and the vector itself.
Parameters
• u (float) – knot value
• normalize (bool) – if True, the returned vector is converted to a unit vector
Returns a list in the order of “curve point” and “tangent”
Return type list
tangents(u_list=(), normalize=False)
Evaluates the curve tangent at all u values in the input list.
Parameters
• u_list (tuple, list) – knot value
• normalize (bool) – if True, the returned vector is converted to a unit vector
Returns a list of starting points and the vectors
Return type list
normal(u=-1, normalize=True)
Evaluates the curve normal at the given u parameter.
Curve normal is basically the second derivative of the curve. The output returns a list containing the
starting point (i.e. origin) of the vector and the vector itself.
Parameters
• u (float) – knot value

8.1. B-Spline Module 37


NURBS-Python Documentation, Release

• normalize (bool) – if True, the returned vector is converted to a unit vector


Returns a list in the order of “curve point” and “normal”
Return type list
normals(u_list=(), normalize=False)
Evaluates the curve normal at all u values in the input list.
Parameters
• u_list (tuple, list) – knot value
• normalize (bool) – if True, the returned vector is converted to a unit vector
Returns a list of starting points and the vectors
Return type list
binormal(u=-1, normalize=True)
Evaluates the curve binormal 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.
Parameters
• u (float) – knot value
• normalize (bool) – if True, the returned vector is converted to a unit vector
Returns a list in the order of “curve point” and “binormal”
Return type list
binormals(u_list=(), normalize=False)
Evaluates the curve binormal at all u values in the input list.
Parameters
• u_list (tuple, list) – knot value
• normalize (bool) – if True, the returned vector is converted to a unit vector
Returns a list of starting points and the vectors
Return type list
insert_knot(u, r=1)
Inserts the given knot and updates the control points array and the knot vector.
Parameters
• u (float) – Knot to be inserted
• r (int) – number of knot insertions
Returns None

8.1.2 2D B-Spline Curve

class geomdl.BSpline.Curve2D
Bases: geomdl.BSpline.Curve
A data storage and evaluation class for 2D B-Spline (NUBS) curves.
Data Storage

38 Chapter 8. Included Modules


NURBS-Python Documentation, Release

The following properties are present in this class:


• order
• degree
• knotvector
• delta
• ctrlpts
• curvepts
The function read_ctrlpts_from_txt() provides an easy way to read weighted control points from a
text file. Additional details on the file formats can be found in the documentation.

Note: Control points are stored as a list of (x, y) coordinates

Evaluation
The evaluation methods are:
• evaluate()
• derivatives()
• tangent()
• insert_knot()
Please check the function reference for the details.

Note: If you update any of the data storage elements after the curve evaluation, the surface points stored in
curvepts property will be deleted automatically.

binormal(u=-1, normalize=True)
Evaluates the curve binormal 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.
Parameters
• u (float) – knot value
• normalize (bool) – if True, the returned vector is converted to a unit vector
Returns a list in the order of “curve point” and “binormal”
Return type list
binormals(u_list=(), normalize=False)
Evaluates the curve binormal at all u values in the input list.
Parameters
• u_list (tuple, list) – knot value
• normalize (bool) – if True, the returned vector is converted to a unit vector
Returns a list of starting points and the vectors
Return type list

8.1. B-Spline Module 39


NURBS-Python Documentation, Release

ctrlpts
Control points.
Getter Gets the control points
Setter Sets the control points
Type list
curvept(u=-1, check_vars=True, get_ctrlpts=False)
Evaluates the B-Spline curve at the given u parameter.
Parameters
• u (float) – parameter
• check_vars (bool) – flag to disable variable checking (only for internal eval functions)
• get_ctrlpts – flag to add a list of control points associated with the curve evaluation
to return value
• get_ctrlpts – bool
Returns evaluated curve point at the given knot value
Return type list
curvepts
Evaluated curve points.
Getter (x, y) coordinates of the evaluated surface points
Type list
degree
Curve degree.
Getter Gets the curve degree
Setter Sets the curve degree
Type integer
delta
Curve evaluation delta.

Note: The delta value is 0.1 by default.

Getter Gets the delta value


Setter Sets the delta value
Type float

derivatives(u=-1, order=0)
Evaluates n-th order curve derivatives at the given u using Algorithm A3.4.
Parameters
• u (float) – knot value
• order (integer) – derivative order
Returns A list containing up to {order}-th derivative of the curve

40 Chapter 8. Included Modules


NURBS-Python Documentation, Release

Return type list


derivatives2(u=-1, order=0)
Evaluates n-th order curve derivatives at the given u using Algorithm A3.2.
Parameters
• u (float) – knot value
• order (integer) – derivative order
Returns A list containing up to {order}-th derivative of the curve
Return type list
derivatives_ctrlpts(order=0, r1=0, r2=0)
Computes the control points of all derivative curves up to and including the {degree}-th derivative.
Implements Algorithm A3.3. Output is PK[k][i], i-th control point of the k-th derivative curve where 0 <=
k <= degree and r1 <= i <= r2-k
Parameters
• order (integer) – derivative order
• r1 (integer) – minimum span
• r2 (integer) – maximum span
Returns PK, a 2D list of control points
Return type list
evaluate()
Evaluates the B-Spline curve.

Note: The evaluated surface points are stored in curvepts.

Returns None

insert_knot(u, r=1)
Inserts the given knot and updates the control points array and the knot vector.
Parameters
• u (float) – Knot to be inserted
• r (int) – number of knot insertions
Returns None
knotvector
Knot vector.
Getter Gets the knot vector
Setter Sets the knot vector
Type list
normal(u=-1, normalize=True)
Evaluates the curve normal at the given u parameter.
Curve normal is basically the second derivative of the curve. The output returns a list containing the
starting point (i.e. origin) of the vector and the vector itself.

8.1. B-Spline Module 41


NURBS-Python Documentation, Release

Parameters
• u (float) – knot value
• normalize (bool) – if True, the returned vector is converted to a unit vector
Returns a list in the order of “curve point” and “normal”
Return type list
normals(u_list=(), normalize=False)
Evaluates the curve normal at all u values in the input list.
Parameters
• u_list (tuple, list) – knot value
• normalize (bool) – if True, the returned vector is converted to a unit vector
Returns a list of starting points and the vectors
Return type list
order
Curve order.
Defined as order = degree + 1
Getter Gets the curve order
Setter Sets the curve order
Type integer
read_ctrlpts_from_txt(filename=”)
Loads control points from a text file.
Parameters filename (str) – input file name
Returns True if control points are loaded correctly, False otherwise
Return type bool
render(cpcolor=’blue’, curvecolor=’black’)
Renders the curve using the loaded visualization component
The visualization component must be set using vis property before calling this method.
Parameters
• cpcolor (str) – Color of the control points polygon
• curvecolor (str) – Color of the curve
Returns None
save_ctrlpts_to_csv(filename=”, scalar=0)
Saves control points to a comma separated text file.
Parameters
• filename (str) – output file name
• scalar (int) – value of the scalar column in the output, defaults to 0
Returns True if control points are saved correctly, False otherwise
Return type bool

42 Chapter 8. Included Modules


NURBS-Python Documentation, Release

save_ctrlpts_to_txt(filename=”)
Saves control points to a text file.
Parameters filename (str) – output file name
Returns True if control points are saved correctly, False otherwise
Return type bool
save_curvepts_to_csv(filename=”, scalar=0)
Saves evaluated curve points to a comma separated text file.
Parameters
• filename (str) – output file name
• scalar (int) – value of the scalar column in the output, defaults to 0
Returns True if curve points are saved correctly, False otherwise
Return type bool
set_ctrlpts(ctrlpts)
Sets control points.
Parameters ctrlpts (list) – input control points as a list of coordinates
Returns None
tangent(u=-1, normalize=False)
Evaluates the curve tangent at the given u parameter.
The output returns a list containing the starting point (i.e. origin) of the vector and the vector itself.
Parameters
• u (float) – knot value
• normalize (bool) – if True, the returned vector is converted to a unit vector
Returns a list in the order of “curve point” and “tangent”
Return type list
tangents(u_list=(), normalize=False)
Evaluates the curve tangent at all u values in the input list.
Parameters
• u_list (tuple, list) – knot value
• normalize (bool) – if True, the returned vector is converted to a unit vector
Returns a list of starting points and the vectors
Return type list
vis
Visualization component.

Note: The visualization component is completely optional to use.

Getter Gets the visualization component


Setter Sets the visualization component

8.1. B-Spline Module 43


NURBS-Python Documentation, Release

Type float

8.1.3 B-Spline Surface

class geomdl.BSpline.Surface
Bases: object
A data storage and evaluation class for B-Spline (NUBS) surfaces.
Data Storage
The following properties are present in this class:
• order_u
• order_v
• degree_u
• degree_v
• knotvector_u
• knotvector_v
• delta
• ctrlpts
• ctrlpts2d
• surfpts
Details on Control Points
Control points are stored as a list of (x, y, z) coordinates. The function read_ctrlpts_from_txt()
provides an easy way to read control points from a text file. Additional details on the file formats can be found
on the documentation.
Evaluation
The evaluation methods are:
• evaluate()
• derivatives()
• tangent()
• normal()
• insert_knot()
Please check the function reference for the details.

Note: If you update any of the data storage elements after the surface evaluation, the surface points stored in
surfpts property will be deleted automatically.

order_u
Surface order for U direction.
Follows the following equality: order = degree + 1
Getter Gets the surface order for U direction

44 Chapter 8. Included Modules


NURBS-Python Documentation, Release

Setter Sets the surface order for U direction


Type integer
order_v
Surface order for V direction.
Follows the following equality: order = degree + 1
Getter Gets the surface order for V direction
Setter Sets the surface order for V direction
Type integer
degree_u
Surface degree for U direction.
Getter Gets the surface degree for U direction
Setter Sets the surface degree for U direction
Type integer
degree_v
Surface degree for V direction.
Getter Gets the surface degree V for V direction
Setter Sets the surface degree V for V direction
Type integer
ctrlpts
Control points.

Note: The v index varies first. That is, a row of v control points for the first u value is found first. Then,
the row of v control points for the next u value.

Getter Gets the control points


Setter Sets the control points
Type list

ctrlpts2d
Control points.
The getter returns a tuple of 2D control points (weighted control points + weights if NURBS) in [u][v] for-
mat. The rows of the returned tuple correspond to V-direction and the columns correspond to U-direction.
The following example can be used to traverse 2D control points:
# Create a BSpline surface
surf_bs = BSpline.Surface()

# Do degree, control points and knot vector assignments here

# Each u includes a row of v values


for u in surf_bs.ctrlpts2d:
# Each row contains the coordinates of the control points
for v in u:
print(str(v)) # will be something like (1.0, 2.0, 3.0)

8.1. B-Spline Module 45


NURBS-Python Documentation, Release

# Create a NURBS surface


surf_nb = NURBS.Surface()

# Do degree, weighted control points and knot vector assignments here

# Each u includes a row of v values


for u in surf_nb.ctrlpts2d:
# Each row contains the coordinates of the weighted control points
for v in u:
print(str(v)) # will be something like (0.5, 1.0, 1.5, 0.5)

When using NURBS.Surface class, the output of ctrlpts2d property could be confusing since,
ctrlpts always returns the unweighted control points, i.e. ctrlpts property returns 3D control
points all divided by the weights and you can use weights property to access the weights vector, but
ctrlpts2d returns the weighted ones plus weights as the last element. This difference is intentionally
added for compatibility and interoperability purposes.
To explain this situation in a simple way;
• If you need the weighted control points directly, use ctrlpts2d
• If you need the control points and the weights separately, use ctrlpts and weights

Note: Please note that the setter doesn’t check for inconsistencies and using the setter is not recommended.
Instead of the setter property, please use set_ctrlpts() function.

Getter Gets the control points in U and V directions


Setter Sets the control points in U and V directions
Type list

ctrlpts_size_u
Size of the control points array in U-direction.
Getter Gets number of control points in U-direction
Setter Sets number of control points in U-direction
Type int
ctrlpts_size_v
Size of the control points array in V-direction.
Getter Gets number of control points in V-direction
Setter Sets number of control points in V-direction
Type int
set_ctrlpts(ctrlpts, size_u, size_v)
Sets 1D control points.
This function expects a list coordinates which is also a list. For instance, if you are working in 3D space,
then your coordinates will be a list of 3 elements representing (x, y, z) coordinates.
This function also generates 2D control points in [u][v] format which can be accessed via ctrlpts2d
property.

46 Chapter 8. Included Modules


NURBS-Python Documentation, Release

Note: The v index varies first. That is, a row of v control points for the first u value is found first. Then,
the row of v control points for the next u value.

Parameters
• ctrlpts (list) – input control points as a list of coordinates
• size_u (int) – size of the control points grid in U-direction
• size_v (int) – size of the control points grid in V-direction
Returns None

knotvector_u
Knot vector for U direction.
Getter Gets the knot vector for U direction
Setter Sets the knot vector for U direction
Type list
knotvector_v
Knot vector for V direction.
Getter Gets the knot vector for V direction
Setter Sets the knot vector for V direction
Type list
delta
Surface evaluation delta.

Note: The delta value is 0.01 by default.

Getter Gets the delta value


Setter Sets the delta value
Type float

surfpts
Evaluated surface points.
Getter (x, y, z) coordinates of the evaluated surface points
Type list
vis
Visualization component.

Note: The visualization component is completely optional to use.

Getter Gets the visualization component


Setter Sets the visualization component

8.1. B-Spline Module 47


NURBS-Python Documentation, Release

Type float

render(cpcolor=’blue’, surfcolor=’green’)
Renders the surface using the loaded visualization component
The visualization component must be set using vis property before calling this method.
Parameters
• cpcolor (str) – Color of the control points grid
• surfcolor (str) – Color of the surface
Returns None
read_ctrlpts_from_txt(filename=”, two_dimensional=True, size_u=0, size_v=0)
Loads control points from a text file.
The control points loaded from the file should follow the right-hand rule. In case two_dimensional = False,
then the following rules apply.
• The v index varies first. That is, a row of v control points for the first u value is found first.
• Then, the row of v control points for the next u value.

Parameters
• filename (str) – input file name
• two_dimensional (bool) – flag to control point list. one dimensional or two dimen-
sional
• size_u (int) – length of the control points array in U-direction
• size_v (int) – length of the control points array in V-direction
Returns True if control points are loaded correctly, False otherwise
Return type bool

save_ctrlpts_to_txt(filename=”, two_dimensional=True)
Saves control points to a text file.
The control points saved to the file follow the right-hand rule. In case two_dimensional = False, then the
following rules apply.
• The v index varies first. That is, a row of v control points for the first u value is found first.
• Then, the row of v control points for the next u value.

Parameters
• filename (str) – output file name
• two_dimensional (bool) – flag to control point list
Returns True if control points are saved correctly, False otherwise
Return type bool

save_ctrlpts_to_csv(filename=”, scalar=0, mode=’linear’)


Saves control points to a comma separated text file.
Available Modes
The following modes are available via mode= parameter:

48 Chapter 8. Included Modules


NURBS-Python Documentation, Release

• linear: Default mode, saves the stored point array without any change
• zigzag: Generates a zig-zag shape
• wireframe: Generates a wireframe
Please note that mode parameter does not modify the stored points in the object instance.
Parameters
• filename (str) – output file name
• scalar (int) – value of the scalar column in the output, defaults to 0
• mode – sets the arrangement of the points, default is linear
Type str
Returns True if control points are saved correctly, False otherwise
Return type bool
save_surfpts_to_csv(filename=”, scalar=0, mode=’linear’)
Saves evaluated surface points to a comma separated text file.
Available Modes
The following modes are available via mode= parameter:
• linear: Default mode, saves the stored point array without any change
• zigzag: Generates a zig-zag shape
• wireframe: Generates a wireframe/quad mesh
• triangle: Generates a triangular mesh
Please note that mode parameter does not modify the stored points in the object instance.
Parameters
• filename (str) – output file name
• scalar (int) – value of the scalar column in the output, defaults to 0
• mode – sets the arrangement of the points, default is linear
Type str
Returns True if surface points are saved correctly, False otherwise
Return type bool
transpose()
Transposes the surface by swapping U and V directions.
Returns None
surfpt(u=-1, v=-1, check_vars=True, get_ctrlpts=False)
Evaluates the B-Spline surface at the given (u,v) parameters.
Parameters
• u (float) – parameter in the U direction
• v (float) – parameter in the V direction
• check_vars (bool) – flag to disable variable checking (only for internal eval functions)

8.1. B-Spline Module 49


NURBS-Python Documentation, Release

• get_ctrlpts – flag to add a list of control points associated with the surface evaluation
to return value
• get_ctrlpts – bool
Returns evaluated surface point at the given knot values
Return type list
evaluate()
Evaluates the surface.

Note: The evaluated surface points are stored in surfpts.

Returns None

derivatives(u=-1, v=-1, order=0)


Evaluates n-th order surface derivatives at the given (u,v) parameter.
• SKL[0][0] will be the surface point itself
• SKL[0][1] will be the 1st derivative w.r.t. v
• SKL[2][1] will be the 2nd derivative w.r.t. u and 1st derivative w.r.t. v

Parameters
• u (float) – parameter in the U direction
• v (float) – parameter in the V direction
• order (integer) – derivative order
Returns A list SKL, where SKL[k][l] is the derivative of the surface S(u,v) w.r.t. u k times and
v l times
Return type list

tangent(u=-1, v=-1, normalize=False)


Evaluates the surface tangent at the given (u, v) parameter.
The output returns a list containing the starting point (i.e. origin) of the vector and the vectors themselves.
Parameters
• u (float) – parameter in the U direction
• v (float) – parameter in the V direction
• normalize (bool) – if True, the returned tangent vector is converted to a unit vector
Returns A list in the order of “surface point”, “derivative w.r.t. u” and “derivative w.r.t. v”
Return type list
tangents(uv_list=(), normalize=False)
Evaluates the surface tangent at all (u, v) values in the input list.
The input list should be arranged as [[u1, v1], [u2, v2], . . . ]
Parameters
• uv_list (tuple, list) – knot values

50 Chapter 8. Included Modules


NURBS-Python Documentation, Release

• normalize (bool) – if True, the returned vector is converted to a unit vector


Returns a list of starting points and the vectors
Return type list
normal(u=-1, v=-1, normalize=True)
Evaluates the surface normal vector at the given (u, v) parameter.
The output returns a list containing the starting point (i.e. origin) of the vector and the vector itself.
Parameters
• u (float) – parameter in the U direction
• v (float) – parameter in the V direction
• normalize (bool) – if True, the returned normal vector is converted to a unit vector
Returns a list in the order of “surface point” and “normal vector”
Return type list
normals(uv_list=(), normalize=False)
Evaluates the surface normal at all (u, v) values in the input list.
The input list should be arranged as [[u1, v1], [u2, v2], . . . ]
Parameters
• uv_list (tuple, list) – knot values
• normalize (bool) – if True, the returned vector is converted to a unit vector
Returns a list of starting points and the vectors
Return type list
insert_knot(u=None, v=None, r=1)
Inserts the given knots and updates the control points array and the knot vectors.
Parameters
• u (float) – Knot to be inserted in U-direction
• v (float) – Knot to be inserted in V-direction
• r (int) – Number of knot insertions
Returns None

8.2 NURBS Module

NURBS module provides data storage and evaluation functions for NURBS 2D/3D curves and surfaces.

8.2.1 3D NURBS Curve

class geomdl.NURBS.Curve
Bases: geomdl.BSpline.Curve
A data storage and evaluation class for 3D NURBS curves.
Data Storage

8.2. NURBS Module 51


NURBS-Python Documentation, Release

The following properties are present in this class:


• order
• degree
• knotvector
• delta
• ctrlpts
• weights
• curvepts
The function read_ctrlpts_from_txt() provides an easy way to read weighted control points from a
text file. Additional details on the file formats can be found in the documentation.

Note: Control points are stored as a list of (x*w, y*w, z*w, w) coordinates

Evaluation
The evaluation methods are:
• evaluate()
• derivatives()
• tangent()
• insert_knot()
Please check the function reference for the details.

Note: If you update any of the data storage elements after the curve evaluation, the surface points stored in
curvepts property will be deleted automatically.

ctrlpts
Control points.
Getter Gets un-weighted control points. Use weights to get weights vector.
Setter Sets weighted control points
Type list
weights
Weights vector.
Getter Extracts the weights vector from weighted control points array
Type list
curvept(u=-1, check_vars=True, get_ctrlpts=False)
Evaluates the NURBS curve at the given u parameter.
Parameters
• u (float) – parameter
• check_vars (bool) – flag to disable variable checking (only for internal eval functions)

52 Chapter 8. Included Modules


NURBS-Python Documentation, Release

• get_ctrlpts – flag to add a list of control points associated with the curve evaluation
to return value
• get_ctrlpts – bool
Returns evaluated curve point at the given knot value
Return type list
derivatives(u=-1, order=0)
Evaluates n-th order curve derivatives at the given u from the rational curve.
Parameters
• u (float) – knot value
• order (integer) – derivative order
Returns A list containing up to {order}-th derivative of the curve
Return type list
derivatives2(u=-1, order=0)
Evaluates n-th order curve derivatives at the given u from the rational curve.
Parameters
• u (float) – knot value
• order (integer) – derivative order
Returns A list containing up to {order}-th derivative of the curve
Return type list
binormal(u=-1, normalize=True)
Evaluates the curve binormal 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.
Parameters
• u (float) – knot value
• normalize (bool) – if True, the returned vector is converted to a unit vector
Returns a list in the order of “curve point” and “binormal”
Return type list
binormals(u_list=(), normalize=False)
Evaluates the curve binormal at all u values in the input list.
Parameters
• u_list (tuple, list) – knot value
• normalize (bool) – if True, the returned vector is converted to a unit vector
Returns a list of starting points and the vectors
Return type list
curvepts
Evaluated curve points.
Getter (x, y) coordinates of the evaluated surface points

8.2. NURBS Module 53


NURBS-Python Documentation, Release

Type list
degree
Curve degree.
Getter Gets the curve degree
Setter Sets the curve degree
Type integer
delta
Curve evaluation delta.

Note: The delta value is 0.1 by default.

Getter Gets the delta value


Setter Sets the delta value
Type float

derivatives_ctrlpts(order=0, r1=0, r2=0)


Computes the control points of all derivative curves up to and including the {degree}-th derivative.
Implements Algorithm A3.3. Output is PK[k][i], i-th control point of the k-th derivative curve where 0 <=
k <= degree and r1 <= i <= r2-k
Parameters
• order (integer) – derivative order
• r1 (integer) – minimum span
• r2 (integer) – maximum span
Returns PK, a 2D list of control points
Return type list
evaluate()
Evaluates the B-Spline curve.

Note: The evaluated surface points are stored in curvepts.

Returns None

insert_knot(u, r=1)
Inserts the given knot and updates the control points array and the knot vector.
Parameters
• u (float) – Knot to be inserted
• r (int) – number of knot insertions
Returns None
knotvector
Knot vector.

54 Chapter 8. Included Modules


NURBS-Python Documentation, Release

Getter Gets the knot vector


Setter Sets the knot vector
Type list
normal(u=-1, normalize=True)
Evaluates the curve normal at the given u parameter.
Curve normal is basically the second derivative of the curve. The output returns a list containing the
starting point (i.e. origin) of the vector and the vector itself.
Parameters
• u (float) – knot value
• normalize (bool) – if True, the returned vector is converted to a unit vector
Returns a list in the order of “curve point” and “normal”
Return type list
normals(u_list=(), normalize=False)
Evaluates the curve normal at all u values in the input list.
Parameters
• u_list (tuple, list) – knot value
• normalize (bool) – if True, the returned vector is converted to a unit vector
Returns a list of starting points and the vectors
Return type list
order
Curve order.
Defined as order = degree + 1
Getter Gets the curve order
Setter Sets the curve order
Type integer
read_ctrlpts_from_txt(filename=”)
Loads control points from a text file.
Parameters filename (str) – input file name
Returns True if control points are loaded correctly, False otherwise
Return type bool
render(cpcolor=’blue’, curvecolor=’black’)
Renders the curve using the loaded visualization component
The visualization component must be set using vis property before calling this method.
Parameters
• cpcolor (str) – Color of the control points polygon
• curvecolor (str) – Color of the curve
Returns None

8.2. NURBS Module 55


NURBS-Python Documentation, Release

save_ctrlpts_to_csv(filename=”, scalar=0)
Saves control points to a comma separated text file.
Parameters
• filename (str) – output file name
• scalar (int) – value of the scalar column in the output, defaults to 0
Returns True if control points are saved correctly, False otherwise
Return type bool
save_ctrlpts_to_txt(filename=”)
Saves control points to a text file.
Parameters filename (str) – output file name
Returns True if control points are saved correctly, False otherwise
Return type bool
save_curvepts_to_csv(filename=”, scalar=0)
Saves evaluated curve points to a comma separated text file.
Parameters
• filename (str) – output file name
• scalar (int) – value of the scalar column in the output, defaults to 0
Returns True if curve points are saved correctly, False otherwise
Return type bool
set_ctrlpts(ctrlpts)
Sets control points.
Parameters ctrlpts (list) – input control points as a list of coordinates
Returns None
tangent(u=-1, normalize=False)
Evaluates the curve tangent at the given u parameter.
The output returns a list containing the starting point (i.e. origin) of the vector and the vector itself.
Parameters
• u (float) – knot value
• normalize (bool) – if True, the returned vector is converted to a unit vector
Returns a list in the order of “curve point” and “tangent”
Return type list
tangents(u_list=(), normalize=False)
Evaluates the curve tangent at all u values in the input list.
Parameters
• u_list (tuple, list) – knot value
• normalize (bool) – if True, the returned vector is converted to a unit vector
Returns a list of starting points and the vectors
Return type list

56 Chapter 8. Included Modules


NURBS-Python Documentation, Release

vis
Visualization component.

Note: The visualization component is completely optional to use.

Getter Gets the visualization component


Setter Sets the visualization component
Type float

8.2.2 2D NURBS Curve

class geomdl.NURBS.Curve2D
Bases: geomdl.NURBS.Curve
A data storage and evaluation class for 2D NURBS curves.
Data Storage
The following properties are present in this class:
• order
• degree
• knotvector
• delta
• ctrlpts
• weights
• curvepts
The function read_ctrlpts_from_txt() provides an easy way to read weighted control points from a
text file. Additional details on the file formats can be found in the documentation.

Note: Control points are stored as a list of (x*w, y*w, w) coordinates

Evaluation
The evaluation methods are:
• evaluate()
• derivatives()
• tangent()
• insert_knot()
Please check the function reference for the details.

Note: If you update any of the data storage elements after the curve evaluation, the surface points stored in
curvepts property will be deleted automatically.

8.2. NURBS Module 57


NURBS-Python Documentation, Release

binormal(u=-1, normalize=True)
Evaluates the curve binormal 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.
Parameters
• u (float) – knot value
• normalize (bool) – if True, the returned vector is converted to a unit vector
Returns a list in the order of “curve point” and “binormal”
Return type list
binormals(u_list=(), normalize=False)
Evaluates the curve binormal at all u values in the input list.
Parameters
• u_list (tuple, list) – knot value
• normalize (bool) – if True, the returned vector is converted to a unit vector
Returns a list of starting points and the vectors
Return type list
ctrlpts
Control points.
Getter Gets un-weighted control points. Use weights to get weights vector.
Setter Sets weighted control points
Type list
curvept(u=-1, check_vars=True, get_ctrlpts=False)
Evaluates the NURBS curve at the given u parameter.
Parameters
• u (float) – parameter
• check_vars (bool) – flag to disable variable checking (only for internal eval functions)
• get_ctrlpts – flag to add a list of control points associated with the curve evaluation
to return value
• get_ctrlpts – bool
Returns evaluated curve point at the given knot value
Return type list
curvepts
Evaluated curve points.
Getter (x, y) coordinates of the evaluated surface points
Type list
degree
Curve degree.
Getter Gets the curve degree
Setter Sets the curve degree

58 Chapter 8. Included Modules


NURBS-Python Documentation, Release

Type integer
delta
Curve evaluation delta.

Note: The delta value is 0.1 by default.

Getter Gets the delta value


Setter Sets the delta value
Type float

derivatives(u=-1, order=0)
Evaluates n-th order curve derivatives at the given u from the rational curve.
Parameters
• u (float) – knot value
• order (integer) – derivative order
Returns A list containing up to {order}-th derivative of the curve
Return type list
derivatives2(u=-1, order=0)
Evaluates n-th order curve derivatives at the given u from the rational curve.
Parameters
• u (float) – knot value
• order (integer) – derivative order
Returns A list containing up to {order}-th derivative of the curve
Return type list
derivatives_ctrlpts(order=0, r1=0, r2=0)
Computes the control points of all derivative curves up to and including the {degree}-th derivative.
Implements Algorithm A3.3. Output is PK[k][i], i-th control point of the k-th derivative curve where 0 <=
k <= degree and r1 <= i <= r2-k
Parameters
• order (integer) – derivative order
• r1 (integer) – minimum span
• r2 (integer) – maximum span
Returns PK, a 2D list of control points
Return type list
evaluate()
Evaluates the B-Spline curve.

Note: The evaluated surface points are stored in curvepts.

8.2. NURBS Module 59


NURBS-Python Documentation, Release

Returns None

insert_knot(u, r=1)
Inserts the given knot and updates the control points array and the knot vector.
Parameters
• u (float) – Knot to be inserted
• r (int) – number of knot insertions
Returns None
knotvector
Knot vector.
Getter Gets the knot vector
Setter Sets the knot vector
Type list
normal(u=-1, normalize=True)
Evaluates the curve normal at the given u parameter.
Curve normal is basically the second derivative of the curve. The output returns a list containing the
starting point (i.e. origin) of the vector and the vector itself.
Parameters
• u (float) – knot value
• normalize (bool) – if True, the returned vector is converted to a unit vector
Returns a list in the order of “curve point” and “normal”
Return type list
normals(u_list=(), normalize=False)
Evaluates the curve normal at all u values in the input list.
Parameters
• u_list (tuple, list) – knot value
• normalize (bool) – if True, the returned vector is converted to a unit vector
Returns a list of starting points and the vectors
Return type list
order
Curve order.
Defined as order = degree + 1
Getter Gets the curve order
Setter Sets the curve order
Type integer
read_ctrlpts_from_txt(filename=”)
Loads control points from a text file.
Parameters filename (str) – input file name
Returns True if control points are loaded correctly, False otherwise

60 Chapter 8. Included Modules


NURBS-Python Documentation, Release

Return type bool


render(cpcolor=’blue’, curvecolor=’black’)
Renders the curve using the loaded visualization component
The visualization component must be set using vis property before calling this method.
Parameters
• cpcolor (str) – Color of the control points polygon
• curvecolor (str) – Color of the curve
Returns None
save_ctrlpts_to_csv(filename=”, scalar=0)
Saves control points to a comma separated text file.
Parameters
• filename (str) – output file name
• scalar (int) – value of the scalar column in the output, defaults to 0
Returns True if control points are saved correctly, False otherwise
Return type bool
save_ctrlpts_to_txt(filename=”)
Saves control points to a text file.
Parameters filename (str) – output file name
Returns True if control points are saved correctly, False otherwise
Return type bool
save_curvepts_to_csv(filename=”, scalar=0)
Saves evaluated curve points to a comma separated text file.
Parameters
• filename (str) – output file name
• scalar (int) – value of the scalar column in the output, defaults to 0
Returns True if curve points are saved correctly, False otherwise
Return type bool
set_ctrlpts(ctrlpts)
Sets control points.
Parameters ctrlpts (list) – input control points as a list of coordinates
Returns None
tangent(u=-1, normalize=False)
Evaluates the curve tangent at the given u parameter.
The output returns a list containing the starting point (i.e. origin) of the vector and the vector itself.
Parameters
• u (float) – knot value
• normalize (bool) – if True, the returned vector is converted to a unit vector
Returns a list in the order of “curve point” and “tangent”

8.2. NURBS Module 61


NURBS-Python Documentation, Release

Return type list


tangents(u_list=(), normalize=False)
Evaluates the curve tangent at all u values in the input list.
Parameters
• u_list (tuple, list) – knot value
• normalize (bool) – if True, the returned vector is converted to a unit vector
Returns a list of starting points and the vectors
Return type list
vis
Visualization component.

Note: The visualization component is completely optional to use.

Getter Gets the visualization component


Setter Sets the visualization component
Type float

weights
Weights vector.
Getter Extracts the weights vector from weighted control points array
Type list

8.2.3 NURBS Surface

class geomdl.NURBS.Surface
Bases: geomdl.BSpline.Surface
A data storage and evaluation class for NURBS surfaces.
Data Storage
The following properties are present in this class:
• order_u
• order_v
• degree_u
• degree_v
• knotvector_u
• knotvector_v
• delta
• ctrlpts
• ctrlpts2d
• weights

62 Chapter 8. Included Modules


NURBS-Python Documentation, Release

• surfpts
Details on Control Points
Control points are stored as a list of (x*w, y*w, z*w, w) coordinates, where w corresponds to the weight.
The function read_ctrlpts_from_txt() provides an easy way to read control points from a text file.
Additional details on the file formats can be found on the documentation.
Evaluation
The evaluation methods are:
• evaluate()
• derivatives()
• tangent()
• normal()
• insert_knot()
Please check the function reference for the details.

Note: If you update any of the data storage elements after the surface evaluation, the surface points stored in
surfpts property will be deleted automatically.

ctrlpts
Control points.
Getter Gets un-weighted control points. Use weights to get weights vector.
Setter Sets weighted control points.
Type list
weights
Weights vector.
Getter Extracts the weights vector from weighted control points array
Type list
ctrlpts2d
Control points.
The getter returns a tuple of 2D control points (weighted control points + weights if NURBS) in [u][v] for-
mat. The rows of the returned tuple correspond to V-direction and the columns correspond to U-direction.
The following example can be used to traverse 2D control points:

# Create a BSpline surface


surf_bs = BSpline.Surface()

# Do degree, control points and knot vector assignments here

# Each u includes a row of v values


for u in surf_bs.ctrlpts2d:
# Each row contains the coordinates of the control points
for v in u:
print(str(v)) # will be something like (1.0, 2.0, 3.0)

# Create a NURBS surface

8.2. NURBS Module 63


NURBS-Python Documentation, Release

surf_nb = NURBS.Surface()

# Do degree, weighted control points and knot vector assignments here

# Each u includes a row of v values


for u in surf_nb.ctrlpts2d:
# Each row contains the coordinates of the weighted control points
for v in u:
print(str(v)) # will be something like (0.5, 1.0, 1.5, 0.5)

When using NURBS.Surface class, the output of ctrlpts2d property could be confusing since,
ctrlpts always returns the unweighted control points, i.e. ctrlpts property returns 3D control
points all divided by the weights and you can use weights property to access the weights vector, but
ctrlpts2d returns the weighted ones plus weights as the last element. This difference is intentionally
added for compatibility and interoperability purposes.
To explain this situation in a simple way;
• If you need the weighted control points directly, use ctrlpts2d
• If you need the control points and the weights separately, use ctrlpts and weights

Note: Please note that the setter doesn’t check for inconsistencies and using the setter is not recommended.
Instead of the setter property, please use set_ctrlpts() function.

Getter Gets the control points in U and V directions


Setter Sets the control points in U and V directions
Type list

ctrlpts_size_u
Size of the control points array in U-direction.
Getter Gets number of control points in U-direction
Setter Sets number of control points in U-direction
Type int
ctrlpts_size_v
Size of the control points array in V-direction.
Getter Gets number of control points in V-direction
Setter Sets number of control points in V-direction
Type int
degree_u
Surface degree for U direction.
Getter Gets the surface degree for U direction
Setter Sets the surface degree for U direction
Type integer
degree_v
Surface degree for V direction.
Getter Gets the surface degree V for V direction

64 Chapter 8. Included Modules


NURBS-Python Documentation, Release

Setter Sets the surface degree V for V direction


Type integer
delta
Surface evaluation delta.

Note: The delta value is 0.01 by default.

Getter Gets the delta value


Setter Sets the delta value
Type float

evaluate()
Evaluates the surface.

Note: The evaluated surface points are stored in surfpts.

Returns None

insert_knot(u=None, v=None, r=1)


Inserts the given knots and updates the control points array and the knot vectors.
Parameters
• u (float) – Knot to be inserted in U-direction
• v (float) – Knot to be inserted in V-direction
• r (int) – Number of knot insertions
Returns None
knotvector_u
Knot vector for U direction.
Getter Gets the knot vector for U direction
Setter Sets the knot vector for U direction
Type list
knotvector_v
Knot vector for V direction.
Getter Gets the knot vector for V direction
Setter Sets the knot vector for V direction
Type list
normal(u=-1, v=-1, normalize=True)
Evaluates the surface normal vector at the given (u, v) parameter.
The output returns a list containing the starting point (i.e. origin) of the vector and the vector itself.
Parameters
• u (float) – parameter in the U direction

8.2. NURBS Module 65


NURBS-Python Documentation, Release

• v (float) – parameter in the V direction


• normalize (bool) – if True, the returned normal vector is converted to a unit vector
Returns a list in the order of “surface point” and “normal vector”
Return type list
normals(uv_list=(), normalize=False)
Evaluates the surface normal at all (u, v) values in the input list.
The input list should be arranged as [[u1, v1], [u2, v2], . . . ]
Parameters
• uv_list (tuple, list) – knot values
• normalize (bool) – if True, the returned vector is converted to a unit vector
Returns a list of starting points and the vectors
Return type list
order_u
Surface order for U direction.
Follows the following equality: order = degree + 1
Getter Gets the surface order for U direction
Setter Sets the surface order for U direction
Type integer
order_v
Surface order for V direction.
Follows the following equality: order = degree + 1
Getter Gets the surface order for V direction
Setter Sets the surface order for V direction
Type integer
read_ctrlpts_from_txt(filename=”, two_dimensional=True, size_u=0, size_v=0)
Loads control points from a text file.
The control points loaded from the file should follow the right-hand rule. In case two_dimensional = False,
then the following rules apply.
• The v index varies first. That is, a row of v control points for the first u value is found first.
• Then, the row of v control points for the next u value.

Parameters
• filename (str) – input file name
• two_dimensional (bool) – flag to control point list. one dimensional or two dimen-
sional
• size_u (int) – length of the control points array in U-direction
• size_v (int) – length of the control points array in V-direction
Returns True if control points are loaded correctly, False otherwise
Return type bool

66 Chapter 8. Included Modules


NURBS-Python Documentation, Release

render(cpcolor=’blue’, surfcolor=’green’)
Renders the surface using the loaded visualization component
The visualization component must be set using vis property before calling this method.
Parameters
• cpcolor (str) – Color of the control points grid
• surfcolor (str) – Color of the surface
Returns None
save_ctrlpts_to_csv(filename=”, scalar=0, mode=’linear’)
Saves control points to a comma separated text file.
Available Modes
The following modes are available via mode= parameter:
• linear: Default mode, saves the stored point array without any change
• zigzag: Generates a zig-zag shape
• wireframe: Generates a wireframe
Please note that mode parameter does not modify the stored points in the object instance.
Parameters
• filename (str) – output file name
• scalar (int) – value of the scalar column in the output, defaults to 0
• mode – sets the arrangement of the points, default is linear
Type str
Returns True if control points are saved correctly, False otherwise
Return type bool
save_ctrlpts_to_txt(filename=”, two_dimensional=True)
Saves control points to a text file.
The control points saved to the file follow the right-hand rule. In case two_dimensional = False, then the
following rules apply.
• The v index varies first. That is, a row of v control points for the first u value is found first.
• Then, the row of v control points for the next u value.

Parameters
• filename (str) – output file name
• two_dimensional (bool) – flag to control point list
Returns True if control points are saved correctly, False otherwise
Return type bool

save_surfpts_to_csv(filename=”, scalar=0, mode=’linear’)


Saves evaluated surface points to a comma separated text file.
Available Modes
The following modes are available via mode= parameter:

8.2. NURBS Module 67


NURBS-Python Documentation, Release

• linear: Default mode, saves the stored point array without any change
• zigzag: Generates a zig-zag shape
• wireframe: Generates a wireframe/quad mesh
• triangle: Generates a triangular mesh
Please note that mode parameter does not modify the stored points in the object instance.
Parameters
• filename (str) – output file name
• scalar (int) – value of the scalar column in the output, defaults to 0
• mode – sets the arrangement of the points, default is linear
Type str
Returns True if surface points are saved correctly, False otherwise
Return type bool
set_ctrlpts(ctrlpts, size_u, size_v)
Sets 1D control points.
This function expects a list coordinates which is also a list. For instance, if you are working in 3D space,
then your coordinates will be a list of 3 elements representing (x, y, z) coordinates.
This function also generates 2D control points in [u][v] format which can be accessed via ctrlpts2d
property.

Note: The v index varies first. That is, a row of v control points for the first u value is found first. Then,
the row of v control points for the next u value.

Parameters
• ctrlpts (list) – input control points as a list of coordinates
• size_u (int) – size of the control points grid in U-direction
• size_v (int) – size of the control points grid in V-direction
Returns None

surfpt(u=-1, v=-1, check_vars=True, get_ctrlpts=False)


Evaluates the NURBS surface at the given (u,v) parameters.
Parameters
• u (float) – parameter in the U direction
• v (float) – parameter in the V direction
• check_vars (bool) – flag to disable variable checking (only for internal eval functions)
• get_ctrlpts – flag to add a list of control points associated with the surface evaluation
to return value
• get_ctrlpts – bool
Returns evaluated surface point at the given knot values
Return type list

68 Chapter 8. Included Modules


NURBS-Python Documentation, Release

surfpts
Evaluated surface points.
Getter (x, y, z) coordinates of the evaluated surface points
Type list
tangent(u=-1, v=-1, normalize=False)
Evaluates the surface tangent at the given (u, v) parameter.
The output returns a list containing the starting point (i.e. origin) of the vector and the vectors themselves.
Parameters
• u (float) – parameter in the U direction
• v (float) – parameter in the V direction
• normalize (bool) – if True, the returned tangent vector is converted to a unit vector
Returns A list in the order of “surface point”, “derivative w.r.t. u” and “derivative w.r.t. v”
Return type list
tangents(uv_list=(), normalize=False)
Evaluates the surface tangent at all (u, v) values in the input list.
The input list should be arranged as [[u1, v1], [u2, v2], . . . ]
Parameters
• uv_list (tuple, list) – knot values
• normalize (bool) – if True, the returned vector is converted to a unit vector
Returns a list of starting points and the vectors
Return type list
transpose()
Transposes the surface by swapping U and V directions.
Returns None
vis
Visualization component.

Note: The visualization component is completely optional to use.

Getter Gets the visualization component


Setter Sets the visualization component
Type float

derivatives(u=-1, v=-1, order=0)


Evaluates n-th order surface derivatives at the given (u,v) parameter from the rational surface.
• SKL[0][0] will be the surface point itself
• SKL[0][1] will be the 1st derivative w.r.t. v
• SKL[2][1] will be the 2nd derivative w.r.t. u and 1st derivative w.r.t. v

Parameters

8.2. NURBS Module 69


NURBS-Python Documentation, Release

• u (float) – parameter in the U direction


• v (float) – parameter in the V direction
• order (integer) – derivative order
Returns A list SKL, where SKL[k][l] is the derivative of the surface S(u,v) w.r.t. u k times and
v l times
Return type list

8.3 Utilities Module

utilities module contains common helper functions for B-spline and NURBS curve and surface evaluation. In
addition, it contains conversion operations related to control points, such as flipping arrays and adding weights.
geomdl.utilities.flip_ctrlpts(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.
Parameters
• file_in (str) – name of the input file (to be read)
• file_out (str) – name of the output file (to be saved)
Returns None
geomdl.utilities.generate_ctrlptsw(file_in=”, file_out=’ctrlptsw.txt’)
Generates weighted control points from unweighted ones.
This function takes in a 2D control points file whose coordinates are organized like (x, y, z, w), converts into
(x*w, y*w, z*w, w), and saves it to a file. Therefore, it could be a direct input of the NURBS.Surface class.
Parameters
• file_in (str) – name of the input file (to be read)
• file_out (str) – name of the output file (to be saved)
Returns None
geomdl.utilities.generate_ctrlpts_weights(file_in=”, file_out=’ctrlpts_weights.txt’)
Generates unweighted control points from weighted ones.
This function takes in a 2D control points file whose coordinates are organized like (x*w, y*w, z*w, w), converts
into (x, y, z, w), and saves it to a file.
Parameters
• file_in (str) – name of the input file (to be read)
• file_out (str) – name of the output file (to be saved)
Returns None
geomdl.utilities.make_zigzag(points, row_size)
Changes linearly ordered list of points into a zig-zag shape.
This function is designed to create input for the visualization software. It orders the points to draw a zig-zag
shape which enables generating properly connected lines without any scanlines. Please see the below sketch on
the functionality of the row_size parameter:

70 Chapter 8. Included Modules


NURBS-Python Documentation, Release

row size
<-=============->
------->>-------|
|------<<-------|
|------>>-------|
-------<<-------|

Please note that this function does not detect the ordering of the input points to detect the input points have
already been processed to generate a zig-zag shape.
Parameters
• points (list) – list of points to be ordered
• row_size – number of elements in a row which the zig-zag generated
• row_size – int
Returns re-ordered points
Return type list
geomdl.utilities.make_quad(points, row_size, col_size)
Generates a quad mesh from linearly ordered list of points.
Parameters
• points (list, tuple) – list of points to be ordered
• row_size – number of elements in a row
• row_size – int
• col_size – number of elements in a column
• col_size – int
Returns re-ordered points
Return type list
geomdl.utilities.make_triangle(points, row_size, col_size)
Generates a triangular mesh from linearly ordered list of points.
Parameters
• points (list, tuple) – list of points to be ordered
• row_size – number of elements in a row
• row_size – int
• col_size – number of elements in a column
• col_size – int
Returns re-ordered points
Return type list
geomdl.utilities.frange(start, stop, step=1.0, decimals=7)
Implementation of Python’s range() function which works with floats.
Reference to this implementation: https://stackoverflow.com/a/47877721
Parameters
• start (float) – start value

8.3. Utilities Module 71


NURBS-Python Documentation, Release

• stop (float) – end value


• step (float) – increment
• decimals (int) – rounding number
Returns float
Return type generator
geomdl.utilities.normalize_knot_vector(knot_vector=())
Normalizes the input knot vector between 0 and 1.
Parameters knot_vector (tuple) – input knot vector
Returns normalized knot vector
Return type list
geomdl.utilities.generate_knot_vector(degree=0, control_points_size=0)
Generates a uniformly-spaced knot vector using the degree and the number of control points.
Parameters
• degree (integer) – degree of the knot vector direction
• control_points_size (integer) – number of control points on that direction
Returns knot vector
Return type list
geomdl.utilities.vector_generate(start_pt=(), end_pt=(), normalize=False)
Generates a vector from 2 input 3D points
The input points must be a list with length 3.
Parameters
• start_pt (list, tuple) – starting point of the vector
• end_pt (list, tuple) – ending point of the vector
• normalize (bool) – if True, the generated vector is normalized
Returns a vector from start_pt to end_pt
Return type list
geomdl.utilities.vector_cross(vector1=(), vector2=())
Computes the cross-product of the input vectors.
Parameters
• vector1 (tuple) – input vector 1
• vector2 (tuple) – input vector 2
Returns result of the cross product
Return type list
geomdl.utilities.vector_dot(vector1=(), vector2=())
Computes the dot-product of the input vectors.
Parameters
• vector1 (tuple) – input vector 1
• vector2 (tuple) – input vector 2

72 Chapter 8. Included Modules


NURBS-Python Documentation, Release

Returns result of the dot product


Return type list
geomdl.utilities.vector_normalize(vector_in=())
Generates a unit vector from the input.
Parameters vector_in (tuple) – vector to be normalized
Returns the normalized vector (i.e. the unit vector)
Return type list
geomdl.utilities.point_translate(point_in=(), vector_in=())
Translates the input points using the given vector.
Parameters
• point_in (tuple) – input point (as a list/tuple of 3 elements)
• vector_in (tuple) – input vector (as a list/tuple of 3 elements)
Returns translated point
Return type list
geomdl.utilities.binomial_coefficient(k, i)
Computes the binomial coefficient (denoted by k choose i).
Please see the following website for details: http://mathworld.wolfram.com/BinomialCoefficient.html
Parameters
• k (int) – size of the set of distinct elements
• i (int) – size of the subsets
Returns combination of k and i
Return type float

8.4 Control Points Generator Module

CPGen module allows users to generate control points grids as an input to BSpline.Surface and NURBS.
Surface classes. This module is designed to enable more testing cases in a very simple way and it doesn’t have
the capabilities of a fully-featured grid generator, but it should be enough to be used side by side with BSpline and
NURBS modules.
CPGen.Grid class provides an easy way to generate control point grids for use with BSpline.Surface class and
CPGen.GridWeighted does the same for NURBS.Surface class.

8.4.1 Grid

class geomdl.CPGen.Grid(size_x, size_y)


Bases: object
Simple grid generator to use with B-Spline surfaces.
This class stores grid points in [x, y, z] format.

8.4. Control Points Generator Module 73


NURBS-Python Documentation, Release

Note: Additional details on the file formats can be found in the documentation.

Parameters
• size_x (float) – width of the grid
• size_y (float) – height of the grid

grid()
Returns the generated grid.
Returns 2D list of points in [u][v] format
generate(num_u, num_v)
Generates grid using the input division parameters.
Parameters
• num_u (int) – number of divisions in x-direction
• num_v (int) – number of divisions in y-direction
Returns None
rotate_z(angle=0.0)
Rotates the grid about the z-axis.
Parameters angle (float) – angle of rotation about the z-axis
Returns None
rotate_y(angle=0.0)
Rotates the grid about the y-axis.
Parameters angle (float) – angle of rotation about the y-axis
Returns None
rotate_x(angle=0.0)
Rotates the grid about the x-axis.
Parameters angle (float) – angle of rotation about the x-axis
Returns None
translate(pt=(0.0, 0.0, 0.0))
Translates the grid origin to the input position.
Grid origin is (0, 0, 0) at instantiation and always represents the bottom left corner of the 2D grid.
Parameters pt (list) – new origin point
Returns None
save(filename=’grid.txt’)
Saves the generated grid to a text file.
Parameters filename (str) – File name to be saved
Returns True if grid is saved correctly, False otherwise
Return type bool

74 Chapter 8. Included Modules


NURBS-Python Documentation, Release

bumps(num_bumps=0, all_positive=False, bump_height=3)


Generates random bumps (i.e. hills) on the 2D grid.
This method generates hills on the grid defined by the num_bumps parameter. The direction of the gen-
erated hills are chosen randomly by default, but this behavior can be controlled by all_positive parameter.
It is also possible to control the z-value using bump_height parameter.
Please note that, not all grids can be modified to have num_bumps number of bumps. Therefore, this
function uses a trial-and-error method to determine whether the bumps can be generated or not. For
instance:

testgrid = Grid(5, 10) # generates a 5x10 rectangle


testgrid.generate(2, 2) # splits the rectangle into 4 pieces
testgrid.bumps(100) # impossible, it will return an error message
testgrid.bumps(1) # You will get a bump at the center of the generated grid

Parameters
• num_bumps (int) – Number of bumps (i.e. hills) to be generated on the 2D grid
• all_positive (bool) – Generate all bumps on the positive z direction
• bump_height (float) – z-value of the generated bumps on the grid
Returns None

8.4.2 Weighted Grid

class geomdl.CPGen.GridWeighted(size_x, size_y)


Bases: geomdl.CPGen.Grid
Simple grid generator to use with NURBS surfaces.
This class stores grid points in [x*w, y*w, z*w, w] format.

Note: Additional details for the file formats can be found in the documentation.

Parameters
• size_x (float) – width of the grid
• size_y (float) – height of the grid

add_weight(w=1.0)
Adds a uniform weight to grid points.
All grid points are divided by the input weight and weight value is added as the last element of the coordi-
nate array. Grid points can be accessed via grid() function and can be saved as a text file via save()
function.
Parameters w (float) – weight value to be added
Returns None
modify_weight(w=-1.0)
Modifies weight value of the grid points.
Parameters w (float) – weight value to be added
Returns None

8.4. Control Points Generator Module 75


NURBS-Python Documentation, Release

bumps(num_bumps=0, all_positive=False, bump_height=3)


Generates random bumps (i.e. hills) on the 2D grid.
This method generates hills on the grid defined by the num_bumps parameter. The direction of the gen-
erated hills are chosen randomly by default, but this behavior can be controlled by all_positive parameter.
It is also possible to control the z-value using bump_height parameter.
Please note that, not all grids can be modified to have num_bumps number of bumps. Therefore, this
function uses a trial-and-error method to determine whether the bumps can be generated or not. For
instance:

testgrid = Grid(5, 10) # generates a 5x10 rectangle


testgrid.generate(2, 2) # splits the rectangle into 4 pieces
testgrid.bumps(100) # impossible, it will return an error message
testgrid.bumps(1) # You will get a bump at the center of the generated grid

Parameters
• num_bumps (int) – Number of bumps (i.e. hills) to be generated on the 2D grid
• all_positive (bool) – Generate all bumps on the positive z direction
• bump_height (float) – z-value of the generated bumps on the grid
Returns None

generate(num_u, num_v)
Generates grid using the input division parameters.
Parameters
• num_u (int) – number of divisions in x-direction
• num_v (int) – number of divisions in y-direction
Returns None
grid()
Returns the generated grid.
Returns 2D list of points in [u][v] format
rotate_x(angle=0.0)
Rotates the grid about the x-axis.
Parameters angle (float) – angle of rotation about the x-axis
Returns None
rotate_y(angle=0.0)
Rotates the grid about the y-axis.
Parameters angle (float) – angle of rotation about the y-axis
Returns None
rotate_z(angle=0.0)
Rotates the grid about the z-axis.
Parameters angle (float) – angle of rotation about the z-axis
Returns None
save(filename=’grid.txt’)
Saves the generated grid to a text file.

76 Chapter 8. Included Modules


NURBS-Python Documentation, Release

Parameters filename (str) – File name to be saved


Returns True if grid is saved correctly, False otherwise
Return type bool
translate(pt=(0.0, 0.0, 0.0))
Translates the grid origin to the input position.
Grid origin is (0, 0, 0) at instantiation and always represents the bottom left corner of the 2D grid.
Parameters pt (list) – new origin point
Returns None

8.5 Visualization

NURBS-Python provides an optional-to-use visualization module with a sample implementation that uses Matplotlib.
Please see the documentation of the following modules for details:

8.5.1 Visualization Base Class

The visualization component in the NURBS-Python package provides an easy way to visualise the surfaces and the
2D/3D curves generated using the library. VisAbstract class provides the abstract base for all visualization com-
ponents.
class geomdl.visualization.VisBase.VisAbstract(plot_ctrlpts=True)
Bases: object
Visualization abstract class
Uses Python’s Abstract Base Class implementation to define a base for all common visualization options in
NURBS-Python package.
Parameters plot_ctrlpts (bool) – enables/disables display of control points plot on the final
figure
clear()
Clears the points, colors and names lists.
add(ptsarr=(), size=0, name=None, color=None)
Adds points sets to the visualization instance for plotting.
Parameters
• ptsarr (list, tuple) – control, curve or surface points
• size (int, list) – size in all directions
• name (str) – name of the point on the legend
• color (str) – color of the point on the legend
render()
Abstract method for rendering plots of the point sets.
This method must be implemented in all subclasses of VisAbstract class.
class geomdl.visualization.VisBase.VisAbstractSurf(plot_ctrlpts=True)
Bases: geomdl.visualization.VisBase.VisAbstract
Visualization abstract class for surfaces

8.5. Visualization 77
NURBS-Python Documentation, Release

Implements VisABstract class and also uses Python’s Abstract Base Class implementation to define a base
for surface visualization options in NURBS-Python package.
Parameters plot_ctrlpts (bool) – enables/disables display of control points plot on the final
figure
set_ctrlpts_offset(offset_value)
Sets an offset for the control points grid plot.
Parameters offset_value (float) – offset value
render()
Abstract method for rendering plots of the point sets.
This method must be implemented in all subclasses of VisAbstractSurf class.
add(ptsarr=(), size=0, name=None, color=None)
Adds points sets to the visualization instance for plotting.
Parameters
• ptsarr (list, tuple) – control, curve or surface points
• size (int, list) – size in all directions
• name (str) – name of the point on the legend
• color (str) – color of the point on the legend
clear()
Clears the points, colors and names lists.

8.5.2 Matplotlib Implementation

This module provides Matplotlib visualization implementation.


class geomdl.visualization.VisMPL.VisCurve2D(plot_ctrlpts=True)
Bases: geomdl.visualization.VisBase.VisAbstract
Visualization module for 2D Curves
render()
Plots the 2D curve and the control points polygon
add(ptsarr=(), size=0, name=None, color=None)
Adds points sets to the visualization instance for plotting.
Parameters
• ptsarr (list, tuple) – control, curve or surface points
• size (int, list) – size in all directions
• name (str) – name of the point on the legend
• color (str) – color of the point on the legend
clear()
Clears the points, colors and names lists.
class geomdl.visualization.VisMPL.VisCurve3D(plot_ctrlpts=True)
Bases: geomdl.visualization.VisBase.VisAbstract
Visualization module for 3D Curves

78 Chapter 8. Included Modules


NURBS-Python Documentation, Release

render()
Plots the 3D curve and the control points polygon
add(ptsarr=(), size=0, name=None, color=None)
Adds points sets to the visualization instance for plotting.
Parameters
• ptsarr (list, tuple) – control, curve or surface points
• size (int, list) – size in all directions
• name (str) – name of the point on the legend
• color (str) – color of the point on the legend
clear()
Clears the points, colors and names lists.
class geomdl.visualization.VisMPL.VisSurface(plot_ctrlpts=True)
Bases: geomdl.visualization.VisBase.VisAbstractSurf
Visualization module for Surfaces
Triangular mesh plot for the surface and wireframe plot for the control points grid
render()
Plots the surface and the control points grid
add(ptsarr=(), size=0, name=None, color=None)
Adds points sets to the visualization instance for plotting.
Parameters
• ptsarr (list, tuple) – control, curve or surface points
• size (int, list) – size in all directions
• name (str) – name of the point on the legend
• color (str) – color of the point on the legend
clear()
Clears the points, colors and names lists.
set_ctrlpts_offset(offset_value)
Sets an offset for the control points grid plot.
Parameters offset_value (float) – offset value
class geomdl.visualization.VisMPL.VisSurfWireframe(plot_ctrlpts=True)
Bases: geomdl.visualization.VisBase.VisAbstractSurf
Visualization module for Surfaces
Scatter plot for the control points and wireframe for the surface points
render()
Plots the surface and the control points grid
add(ptsarr=(), size=0, name=None, color=None)
Adds points sets to the visualization instance for plotting.
Parameters
• ptsarr (list, tuple) – control, curve or surface points
• size (int, list) – size in all directions

8.5. Visualization 79
NURBS-Python Documentation, Release

• name (str) – name of the point on the legend


• color (str) – color of the point on the legend
clear()
Clears the points, colors and names lists.
set_ctrlpts_offset(offset_value)
Sets an offset for the control points grid plot.
Parameters offset_value (float) – offset value
class geomdl.visualization.VisMPL.VisSurfTriangle(plot_ctrlpts=True)
Bases: geomdl.visualization.VisBase.VisAbstractSurf
Visualization module for Surfaces
Wireframe plot for the control points and triangulated plot for the surface points
render()
Plots the surface and the control points grid
add(ptsarr=(), size=0, name=None, color=None)
Adds points sets to the visualization instance for plotting.
Parameters
• ptsarr (list, tuple) – control, curve or surface points
• size (int, list) – size in all directions
• name (str) – name of the point on the legend
• color (str) – color of the point on the legend
clear()
Clears the points, colors and names lists.
set_ctrlpts_offset(offset_value)
Sets an offset for the control points grid plot.
Parameters offset_value (float) – offset value
class geomdl.visualization.VisMPL.VisSurfScatter(plot_ctrlpts=True)
Bases: geomdl.visualization.VisBase.VisAbstractSurf
Visualization module for Surfaces
Wireframe plot for the control points and scatter plot for the surface points
render()
Plots the surface and the control points grid
add(ptsarr=(), size=0, name=None, color=None)
Adds points sets to the visualization instance for plotting.
Parameters
• ptsarr (list, tuple) – control, curve or surface points
• size (int, list) – size in all directions
• name (str) – name of the point on the legend
• color (str) – color of the point on the legend
clear()
Clears the points, colors and names lists.

80 Chapter 8. Included Modules


NURBS-Python Documentation, Release

set_ctrlpts_offset(offset_value)
Sets an offset for the control points grid plot.
Parameters offset_value (float) – offset value
Although there exists a visualization component, the users are completely free to use any visualization method or
software. For instance, CSV exporting facility of the curve and surface classes can be used to draw control points,
curves and surfaces using a software, such as Paraview.
The NURBS-Python Library is developed by Onur Rauf Bingol and all the code released under The MIT License.

8.5. Visualization 81
NURBS-Python Documentation, Release

82 Chapter 8. Included Modules


Python Module Index

g
geomdl.utilities, 70
geomdl.visualization.VisBase, 77
geomdl.visualization.VisMPL, 78

u
utilities (Unix, Windows), 70

v
VisBase (Unix, Windows), 77
VisMPL (Unix, Windows), 78

83
NURBS-Python Documentation, Release

84 Python Module Index


Index

A clear() (geomdl.visualization.VisMPL.VisCurve3D
add() (geomdl.visualization.VisBase.VisAbstract method), 79
method), 77 clear() (geomdl.visualization.VisMPL.VisSurface
add() (geomdl.visualization.VisBase.VisAbstractSurf method), 79
method), 78 clear() (geomdl.visualization.VisMPL.VisSurfScatter
add() (geomdl.visualization.VisMPL.VisCurve2D method), 80
method), 78 clear() (geomdl.visualization.VisMPL.VisSurfTriangle
add() (geomdl.visualization.VisMPL.VisCurve3D method), 80
method), 79 clear() (geomdl.visualization.VisMPL.VisSurfWireframe
add() (geomdl.visualization.VisMPL.VisSurface method), 80
method), 79 ctrlpts (geomdl.BSpline.Curve attribute), 34
add() (geomdl.visualization.VisMPL.VisSurfScatter ctrlpts (geomdl.BSpline.Curve2D attribute), 39
method), 80 ctrlpts (geomdl.BSpline.Surface attribute), 45
add() (geomdl.visualization.VisMPL.VisSurfTriangle ctrlpts (geomdl.NURBS.Curve attribute), 52
method), 80 ctrlpts (geomdl.NURBS.Curve2D attribute), 58
add() (geomdl.visualization.VisMPL.VisSurfWireframe ctrlpts (geomdl.NURBS.Surface attribute), 63
method), 79 ctrlpts2d (geomdl.BSpline.Surface attribute), 45
add_weight() (geomdl.CPGen.GridWeighted method), 75 ctrlpts2d (geomdl.NURBS.Surface attribute), 63
ctrlpts_size_u (geomdl.BSpline.Surface attribute), 46
B ctrlpts_size_u (geomdl.NURBS.Surface attribute), 64
ctrlpts_size_v (geomdl.BSpline.Surface attribute), 46
binomial_coefficient() (in module geomdl.utilities), 73
ctrlpts_size_v (geomdl.NURBS.Surface attribute), 64
binormal() (geomdl.BSpline.Curve method), 38
Curve (class in geomdl.BSpline), 33
binormal() (geomdl.BSpline.Curve2D method), 39
Curve (class in geomdl.NURBS), 51
binormal() (geomdl.NURBS.Curve method), 53
Curve2D (class in geomdl.BSpline), 38
binormal() (geomdl.NURBS.Curve2D method), 57
Curve2D (class in geomdl.NURBS), 57
binormals() (geomdl.BSpline.Curve method), 38
curvept() (geomdl.BSpline.Curve method), 36
binormals() (geomdl.BSpline.Curve2D method), 39
curvept() (geomdl.BSpline.Curve2D method), 40
binormals() (geomdl.NURBS.Curve method), 53
curvept() (geomdl.NURBS.Curve method), 52
binormals() (geomdl.NURBS.Curve2D method), 58
curvept() (geomdl.NURBS.Curve2D method), 58
bumps() (geomdl.CPGen.Grid method), 74
curvepts (geomdl.BSpline.Curve attribute), 35
bumps() (geomdl.CPGen.GridWeighted method), 75
curvepts (geomdl.BSpline.Curve2D attribute), 40
curvepts (geomdl.NURBS.Curve attribute), 53
C curvepts (geomdl.NURBS.Curve2D attribute), 58
clear() (geomdl.visualization.VisBase.VisAbstract
method), 77 D
clear() (geomdl.visualization.VisBase.VisAbstractSurf degree (geomdl.BSpline.Curve attribute), 34
method), 78 degree (geomdl.BSpline.Curve2D attribute), 40
clear() (geomdl.visualization.VisMPL.VisCurve2D degree (geomdl.NURBS.Curve attribute), 54
method), 78 degree (geomdl.NURBS.Curve2D attribute), 58

85
NURBS-Python Documentation, Release

degree_u (geomdl.BSpline.Surface attribute), 45 I


degree_u (geomdl.NURBS.Surface attribute), 64 insert_knot() (geomdl.BSpline.Curve method), 38
degree_v (geomdl.BSpline.Surface attribute), 45 insert_knot() (geomdl.BSpline.Curve2D method), 41
degree_v (geomdl.NURBS.Surface attribute), 64 insert_knot() (geomdl.BSpline.Surface method), 51
delta (geomdl.BSpline.Curve attribute), 35 insert_knot() (geomdl.NURBS.Curve method), 54
delta (geomdl.BSpline.Curve2D attribute), 40 insert_knot() (geomdl.NURBS.Curve2D method), 60
delta (geomdl.BSpline.Surface attribute), 47 insert_knot() (geomdl.NURBS.Surface method), 65
delta (geomdl.NURBS.Curve attribute), 54
delta (geomdl.NURBS.Curve2D attribute), 59 K
delta (geomdl.NURBS.Surface attribute), 65
knotvector (geomdl.BSpline.Curve attribute), 34
derivatives() (geomdl.BSpline.Curve method), 37
knotvector (geomdl.BSpline.Curve2D attribute), 41
derivatives() (geomdl.BSpline.Curve2D method), 40
knotvector (geomdl.NURBS.Curve attribute), 54
derivatives() (geomdl.BSpline.Surface method), 50
knotvector (geomdl.NURBS.Curve2D attribute), 60
derivatives() (geomdl.NURBS.Curve method), 53
knotvector_u (geomdl.BSpline.Surface attribute), 47
derivatives() (geomdl.NURBS.Curve2D method), 59
knotvector_u (geomdl.NURBS.Surface attribute), 65
derivatives() (geomdl.NURBS.Surface method), 69
knotvector_v (geomdl.BSpline.Surface attribute), 47
derivatives2() (geomdl.BSpline.Curve method), 36
knotvector_v (geomdl.NURBS.Surface attribute), 65
derivatives2() (geomdl.BSpline.Curve2D method), 41
derivatives2() (geomdl.NURBS.Curve method), 53 M
derivatives2() (geomdl.NURBS.Curve2D method), 59
derivatives_ctrlpts() (geomdl.BSpline.Curve method), 36 make_quad() (in module geomdl.utilities), 71
derivatives_ctrlpts() (geomdl.BSpline.Curve2D method), make_triangle() (in module geomdl.utilities), 71
41 make_zigzag() (in module geomdl.utilities), 70
derivatives_ctrlpts() (geomdl.NURBS.Curve method), 54 modify_weight() (geomdl.CPGen.GridWeighted
derivatives_ctrlpts() (geomdl.NURBS.Curve2D method), method), 75
59
N
E normal() (geomdl.BSpline.Curve method), 37
evaluate() (geomdl.BSpline.Curve method), 36 normal() (geomdl.BSpline.Curve2D method), 41
evaluate() (geomdl.BSpline.Curve2D method), 41 normal() (geomdl.BSpline.Surface method), 51
evaluate() (geomdl.BSpline.Surface method), 50 normal() (geomdl.NURBS.Curve method), 55
evaluate() (geomdl.NURBS.Curve method), 54 normal() (geomdl.NURBS.Curve2D method), 60
evaluate() (geomdl.NURBS.Curve2D method), 59 normal() (geomdl.NURBS.Surface method), 65
evaluate() (geomdl.NURBS.Surface method), 65 normalize_knot_vector() (in module geomdl.utilities), 72
normals() (geomdl.BSpline.Curve method), 38
F normals() (geomdl.BSpline.Curve2D method), 42
normals() (geomdl.BSpline.Surface method), 51
flip_ctrlpts() (in module geomdl.utilities), 70
normals() (geomdl.NURBS.Curve method), 55
frange() (in module geomdl.utilities), 71
normals() (geomdl.NURBS.Curve2D method), 60
normals() (geomdl.NURBS.Surface method), 66
G
generate() (geomdl.CPGen.Grid method), 74 O
generate() (geomdl.CPGen.GridWeighted method), 76
order (geomdl.BSpline.Curve attribute), 34
generate_ctrlpts_weights() (in module geomdl.utilities),
order (geomdl.BSpline.Curve2D attribute), 42
70
order (geomdl.NURBS.Curve attribute), 55
generate_ctrlptsw() (in module geomdl.utilities), 70
order (geomdl.NURBS.Curve2D attribute), 60
generate_knot_vector() (in module geomdl.utilities), 72
order_u (geomdl.BSpline.Surface attribute), 44
geomdl.utilities (module), 70
order_u (geomdl.NURBS.Surface attribute), 66
geomdl.visualization.VisBase (module), 77
order_v (geomdl.BSpline.Surface attribute), 45
geomdl.visualization.VisMPL (module), 78
order_v (geomdl.NURBS.Surface attribute), 66
Grid (class in geomdl.CPGen), 73
grid() (geomdl.CPGen.Grid method), 74
grid() (geomdl.CPGen.GridWeighted method), 76
P
GridWeighted (class in geomdl.CPGen), 75 point_translate() (in module geomdl.utilities), 73

86 Index
NURBS-Python Documentation, Release

R save_ctrlpts_to_csv() (geomdl.NURBS.Curve2D
read_ctrlpts_from_txt() (geomdl.BSpline.Curve method), method), 61
35 save_ctrlpts_to_csv() (geomdl.NURBS.Surface method),
read_ctrlpts_from_txt() (geomdl.BSpline.Curve2D 67
method), 42 save_ctrlpts_to_txt() (geomdl.BSpline.Curve method), 35
read_ctrlpts_from_txt() (geomdl.BSpline.Surface save_ctrlpts_to_txt() (geomdl.BSpline.Curve2D method),
method), 48 42
read_ctrlpts_from_txt() (geomdl.NURBS.Curve method), save_ctrlpts_to_txt() (geomdl.BSpline.Surface method),
55 48
read_ctrlpts_from_txt() (geomdl.NURBS.Curve2D save_ctrlpts_to_txt() (geomdl.NURBS.Curve method),
method), 60 56
read_ctrlpts_from_txt() (geomdl.NURBS.Surface save_ctrlpts_to_txt() (geomdl.NURBS.Curve2D
method), 66 method), 61
render() (geomdl.BSpline.Curve method), 35 save_ctrlpts_to_txt() (geomdl.NURBS.Surface method),
render() (geomdl.BSpline.Curve2D method), 42 67
render() (geomdl.BSpline.Surface method), 48 save_curvepts_to_csv() (geomdl.BSpline.Curve method),
render() (geomdl.NURBS.Curve method), 55 36
render() (geomdl.NURBS.Curve2D method), 61 save_curvepts_to_csv() (geomdl.BSpline.Curve2D
render() (geomdl.NURBS.Surface method), 67 method), 43
render() (geomdl.visualization.VisBase.VisAbstract save_curvepts_to_csv() (geomdl.NURBS.Curve method),
method), 77 56
render() (geomdl.visualization.VisBase.VisAbstractSurf save_curvepts_to_csv() (geomdl.NURBS.Curve2D
method), 78 method), 61
render() (geomdl.visualization.VisMPL.VisCurve2D save_surfpts_to_csv() (geomdl.BSpline.Surface method),
method), 78 49
render() (geomdl.visualization.VisMPL.VisCurve3D save_surfpts_to_csv() (geomdl.NURBS.Surface method),
method), 78 67
render() (geomdl.visualization.VisMPL.VisSurface set_ctrlpts() (geomdl.BSpline.Curve method), 34
method), 79 set_ctrlpts() (geomdl.BSpline.Curve2D method), 43
render() (geomdl.visualization.VisMPL.VisSurfScatter set_ctrlpts() (geomdl.BSpline.Surface method), 46
method), 80 set_ctrlpts() (geomdl.NURBS.Curve method), 56
render() (geomdl.visualization.VisMPL.VisSurfTriangle set_ctrlpts() (geomdl.NURBS.Curve2D method), 61
method), 80 set_ctrlpts() (geomdl.NURBS.Surface method), 68
render() (geomdl.visualization.VisMPL.VisSurfWireframe set_ctrlpts_offset() (ge-
method), 79 omdl.visualization.VisBase.VisAbstractSurf
rotate_x() (geomdl.CPGen.Grid method), 74 method), 78
rotate_x() (geomdl.CPGen.GridWeighted method), 76 set_ctrlpts_offset() (ge-
rotate_y() (geomdl.CPGen.Grid method), 74 omdl.visualization.VisMPL.VisSurface
rotate_y() (geomdl.CPGen.GridWeighted method), 76 method), 79
rotate_z() (geomdl.CPGen.Grid method), 74 set_ctrlpts_offset() (ge-
rotate_z() (geomdl.CPGen.GridWeighted method), 76 omdl.visualization.VisMPL.VisSurfScatter
method), 80
S set_ctrlpts_offset() (ge-
omdl.visualization.VisMPL.VisSurfTriangle
save() (geomdl.CPGen.Grid method), 74
method), 80
save() (geomdl.CPGen.GridWeighted method), 76
set_ctrlpts_offset() (ge-
save_ctrlpts_to_csv() (geomdl.BSpline.Curve method),
omdl.visualization.VisMPL.VisSurfWireframe
35
method), 80
save_ctrlpts_to_csv() (geomdl.BSpline.Curve2D
Surface (class in geomdl.BSpline), 44
method), 42
Surface (class in geomdl.NURBS), 62
save_ctrlpts_to_csv() (geomdl.BSpline.Surface method),
surfpt() (geomdl.BSpline.Surface method), 49
48
surfpt() (geomdl.NURBS.Surface method), 68
save_ctrlpts_to_csv() (geomdl.NURBS.Curve method),
surfpts (geomdl.BSpline.Surface attribute), 47
55
surfpts (geomdl.NURBS.Surface attribute), 68

Index 87
NURBS-Python Documentation, Release

T
tangent() (geomdl.BSpline.Curve method), 37
tangent() (geomdl.BSpline.Curve2D method), 43
tangent() (geomdl.BSpline.Surface method), 50
tangent() (geomdl.NURBS.Curve method), 56
tangent() (geomdl.NURBS.Curve2D method), 61
tangent() (geomdl.NURBS.Surface method), 69
tangents() (geomdl.BSpline.Curve method), 37
tangents() (geomdl.BSpline.Curve2D method), 43
tangents() (geomdl.BSpline.Surface method), 50
tangents() (geomdl.NURBS.Curve method), 56
tangents() (geomdl.NURBS.Curve2D method), 62
tangents() (geomdl.NURBS.Surface method), 69
translate() (geomdl.CPGen.Grid method), 74
translate() (geomdl.CPGen.GridWeighted method), 77
transpose() (geomdl.BSpline.Surface method), 49
transpose() (geomdl.NURBS.Surface method), 69

U
utilities (module), 70

V
vector_cross() (in module geomdl.utilities), 72
vector_dot() (in module geomdl.utilities), 72
vector_generate() (in module geomdl.utilities), 72
vector_normalize() (in module geomdl.utilities), 73
vis (geomdl.BSpline.Curve attribute), 35
vis (geomdl.BSpline.Curve2D attribute), 43
vis (geomdl.BSpline.Surface attribute), 47
vis (geomdl.NURBS.Curve attribute), 56
vis (geomdl.NURBS.Curve2D attribute), 62
vis (geomdl.NURBS.Surface attribute), 69
VisAbstract (class in geomdl.visualization.VisBase), 77
VisAbstractSurf (class in geomdl.visualization.VisBase),
77
VisBase (module), 77
VisCurve2D (class in geomdl.visualization.VisMPL), 78
VisCurve3D (class in geomdl.visualization.VisMPL), 78
VisMPL (module), 78
VisSurface (class in geomdl.visualization.VisMPL), 79
VisSurfScatter (class in geomdl.visualization.VisMPL),
80
VisSurfTriangle (class in geomdl.visualization.VisMPL),
80
VisSurfWireframe (class in ge-
omdl.visualization.VisMPL), 79

W
weights (geomdl.NURBS.Curve attribute), 52
weights (geomdl.NURBS.Curve2D attribute), 62
weights (geomdl.NURBS.Surface attribute), 63

88 Index

Вам также может понравиться