Using NURBS in pyFormex.
The nurbs module defines functions and classes to manipulate NURBS curves and surface in pyFormex.
Classes defined in module nurbs
A collection of points represented by their homogeneous coordinates.
While most of the pyFormex implementation is based on the 3D Cartesian coordinates class Coords, some applications may benefit from using homogeneous coordinates. The class Coords4 provides some basic functions and conversion to and from cartesian coordinates. Through the conversion, all other pyFormex functions, such as transformations, are available.
Coords4 is implemented as a float type numpy.ndarray whose last axis has a length equal to 4. Each set of 4 values (x,y,z,w) along the last axis represents a single point in 3D space. The cartesian coordinates of the point are obtained by dividing the first three values by the fourth: (x/w, y/w, z/w). A zero w-value represents a point at infinity. Converting such points to Coords will result in Inf or NaN values in the resulting object.
The float datatype is only checked at creation time. It is the responsibility of the user to keep this consistent throughout the lifetime of the object.
Just like Coords, the class Coords4 is derived from numpy.ndarray.
Parameters
Methods
Normalize the homogeneous coordinates.
Two sets of homogeneous coordinates that differ only by a multiplicative constant refer to the same points in cartesian space. Normalization of the coordinates is a way to make the representation of a single point unique. Normalization is done so that the last component (w) is equal to 1.
The normalization of the coordinates is done in place.
Warning
Normalizing points at infinity will result in Inf or NaN values.
Denormalizes the homogeneous coordinates.
This multiplies the homogeneous coordinates with the values w. w normally is a constant or an array with shape self.shape[:-1]. It then multiplies all 4 coordinates of a point with the same value, thus resulting in a denormalization while keeping the position of the point unchanged.
The denormalization of the coordinates is done in place. If the Coords4 object was normalized, it will have precisely w as its 4-th coordinate value after the call.
Convert homogeneous coordinates to cartesian coordinates.
Returns a Coords object with the cartesian coordinates of the points. Points at infinity (w=0) will result in Inf or NaN value. If there are no points at infinity, the resulting Coords point set is equivalent to the Coords4 one.
Return the total number of points.
Return the x-plane
Return the y-plane
Return the z-plane
Return the w-plane
Return the bounding box of a set of points.
Returns the bounding box of the cartesian coordinates of the object.
Graphical representation
Functions defined in module nurbs
Convert cartesian coordinates to homogeneous
Returns a Coords4 object corresponding to the input cartesian coordinates.