ddg.conversion.arrays module
- ddg.conversion.arrays.from_discrete_net(net, /)[source]
Compute all points and faces of a discrete net.
- Parameters:
- netddg.datastructures.nets.net.DiscreteNet
A net with
net.domain.bounded == True.
- Returns:
- tuple of numpy.ndarray and numpy.ndarray
The first array is of shape
(n, d)and comprises of thenpoints in R^d of the net. The second array is of shape(m, k)and comprises of themfaces ofnet.domain.face_data. Note thatkisn’t necessarily equal to 3.
- ddg.conversion.arrays.from_discrete_curve(curve, /)[source]
Compute all points of a discrete curve.
- Parameters:
- curveddg.datastructures.nets.net.DiscreteCurve
A curve with
curve.domain.bounded == True.
- Returns:
- tuple of numpy.ndarray and bool
The array is of shape
(n, d)and comprises of thenpoints in R^d of the curve. The bool is equal tocurve.domain.periodic.
- ddg.conversion.arrays.from_empty_net(_, /)[source]
Convert an empty net to an empty mesh.
- Parameters:
- _ddg.datastructures.nets.net.EmptyNet
- Returns:
- tuple of () and ()
- ddg.conversion.arrays.from_point_net(net, /)[source]
Convert a point net to a mesh of one point and no faces.
- Parameters:
- netddg.datastructures.nets.net.PointNet
- Returns:
- tuple of numpy.ndarray of shape ((1, n)) and ()
The array contains the value of
net(), which is a point in R^n.
- ddg.conversion.arrays.from_net_collection(net_collection, /)[source]
Convert a net collection to a list of curves and meshes.
- Parameters:
- netsddg.datastructures.nets.net.NetCollection
Every net in the collection has to be a DiscreteCurve or DiscreteNet with bounded domain or a PointNet or an EmptyNet.
- Returns:
- list of curves and meshes
A curve is a pair of points and periodicity. A mesh is a pair of points and faces.
- ddg.conversion.arrays.from_half_edge_surface(surface, coordinate_attribute='co', /)[source]
Get the points, isolated edges and faces of a half edge surface.
- Parameters:
- surfaceddg.datastructures.halfedge.Surface
- coordinate_attributestr (default=”co”)
- Returns:
- tuple of numpy.ndarray, numpy.ndarray and list
The first array is of shape (n, d), where n is the number of points lying in R^d. The second array is of shape (k, 2), where k is the number of edges which don’t belong to a face. The list contains tuples of integers. Each tuple corresponds to a face and each integer is the index of a vertex of that face.
- ddg.conversion.arrays.from_1d_subspace(line, length, /)[source]
Sample a 1-dimensional subspace.
- Parameters:
- lineddg.geometry.subspaces.Subspace
A subspace with
line.dimension == 1.- lengthfloat
Must be greater than or equal to 0.0.
- Returns:
- (a, b), False
aandbare of type numpy.ndarray.b - ahas lengthlengthandb - a / 2is the closest point of the line to the origin.
- Raises:
- ValueError
If
line.dimension != 1orlength < 0.0.
- ddg.conversion.arrays.from_2d_subspace(plane, side_length_1, side_length_2, /)[source]
Convert a 2-dimensional subspace to a mesh.
The mesh is given as two triangles:
d c ┌─────┐ ┐ │ /│ │ │ / │ │ │ x │ │ side_length_2 │ / │ │ │/ │ │ └─────┘ ┘ a b └─────┘ side_length_1
such that
xis the closest point of the subspace to the origin.- Parameters:
- planeddg.geometry.subspaces.Subspace
A subspace with
subspace.dimension == 2.- side_length_1float
Must be greater than or equal to 0.0.
- side_length_2float
Must be greater than or equal to 0.0.
- Returns:
- points, facestuple of numpy.ndarray and tuple
The first entry points has shape (4, 3) and comprises of a, b, c, d. The second entry faces comprises of two tuples of 3 integers encoding the two triangles.
- Raises:
- ValueError
If
plane.dimension != 2orside_length_1 < 0.0orside_length_2 < 0.0.
- ddg.conversion.arrays.from_quadric(quadric, /, *num_step)[source]
Convert a quadric to a curve or a mesh or a list thereof.
Every convertible quadric has a parametrization, which is sampled. These parametrizations are implementation details, but the following guarantees hold:
every parametrization is defined on a box I_1 x … x I_d, where d is the dimension of the quadric and I_1, …, I_d are possibly unbounded intervals
- the k-th
num_stepargument determines how I_k is sampled the first entry
numof the k-thnum_stepdetermines the number of samples of I_kif I_k is unbounded, the second entry
stepof the k-thnum_stepdetermines the step size between the samples of I_k
- the k-th
Consequently,
increasing the
numarguments increases the number of points and additionally the number of faces if the quadric is 2-dimensional.if I_k isn’t bounded, decreasing the respective
stepresults in a finer curve or mesh.
- Parameters:
- quadricddg.geometry.quadrics.Quadric
- *num_steptuple of an int and a float
The length of
num_stepmust be 0 ifquadric.dimensionis -1 or 0 and otherwise must be equal toquadric.dimension.
- Returns:
- curve or mesh or a list of curves and meshes
A curve is an tuple of points of type numpy.ndarray and the periodicity of type bool. A mesh is an tuple of points of type numpy.ndarray and the faces of type numpy.ndarray.
- Raises:
- ValueError
If the quadric is a (possibly empty) set of points and
num_stepis given.
- ddg.conversion.arrays.from_sphere(sphere, num, /)[source]
Convert a sphere to a curve or a mesh.
Circles are converted to curves and 2-dimensional spheres are converted to meshes.
- Parameters:
- sphereddg.geometry.spheres.Sphere
- numint
Increasing this number increases the number of samples in each direction of the sphere parametrization.
- Returns:
- curve or mesh
A curve is an tuple of points of type numpy.ndarray and the periodicity of type bool. A mesh is an tuple of points of type numpy.ndarray and the faces of type numpy.ndarray.