ddg.arrays module

Module for converting visualizable objects to discrete array based meshes or curves.

ddg.arrays.from_discrete_net(net, /)[source]

Compute all points and faces of a discrete net.

Parameters:
netddg.nets.DiscreteNet

A net with two-dimensional domain and net.domain.bounded == True.

Returns:
Mesh

Examples

>>> import ddg
>>> net = ddg.nets.DiscreteNet(lambda u, v: (u, v), ((0, 2), (-4, -1)))
>>> points, faces, _ = ddg.arrays.from_discrete_net(net)
>>> points
array([[ 0, -4],
       [ 0, -3],
       [ 0, -2],
       [ 0, -1],
       [ 1, -4],
       [ 1, -3],
       [ 1, -2],
       [ 1, -1],
       [ 2, -4],
       [ 2, -3],
       [ 2, -2],
       [ 2, -1]])
>>> faces
array([[ 0,  4,  5,  1],
       [ 1,  5,  6,  2],
       [ 2,  6,  7,  3],
       [ 4,  8,  9,  5],
       [ 5,  9, 10,  6],
       [ 6, 10, 11,  7]])
ddg.arrays.from_discrete_curve(curve, /)[source]

Compute all points of a discrete curve.

Parameters:
curveddg.nets.DiscreteCurve

A curve with curve.domain.bounded == True.

Returns:
Curve

Examples

>>> import ddg
>>> curve = ddg.nets.DiscreteCurve(lambda t: (t,), (-1, 1, False))
>>> points, periodicity = ddg.arrays.from_discrete_curve(curve)
>>> points
array([[-1],
       [ 0],
       [ 1]])
>>> periodicity
False
ddg.arrays.from_empty_net(_, /)[source]

Convert an empty net to an empty mesh.

Parameters:
_ddg.nets.EmptyNet
Returns:
Mesh

Examples

>>> import ddg
>>> empty_net = ddg.nets.EmptyNet(())
>>> points, faces, _ = ddg.arrays.from_empty_net(empty_net)
>>> points
array([], shape=(0, 3), dtype=float64)
>>> faces
()
ddg.arrays.from_point_net(net, /)[source]

Convert a point net to a mesh of one point and no faces.

Parameters:
netddg.nets.PointNet
Returns:
Points

The object contains the value of net(), which is a point in R^n.

Examples

>>> import ddg
>>> points_net = ddg.nets.PointNet((1, 2, 3))
>>> ddg.arrays.from_point_net(points_net)
Points(points=array([[1, 2, 3]]))
ddg.arrays.from_net_collection(net_collection, /, curve_sampling=(100, 0.1), surface_sampling=(30, 0.1))[source]

Convert a net collection to a (disconnected) curve or mesh.

Parameters:
netsddg.nets.NetCollection

Every net in nets has to be an instance of the same of one of these:

- a SmoothCurve
- a SmoothNet
- a DiscreteCurve with bounded domain
- a DiscreteNet with bounded domain
- a PointNet
- an EmptyNet

Additionally, the dimensions of the images each net in nets must be equal to one another.

curve_samplingtuple of an int and a float

(default=_default_curve_sampling) Determines the sample number and stepsize for curves

surface_samplingtuple of an int and a float

(default=_default_surface_sampling) Determines the sample number and stepsize for surfaces

Returns:
Points, CurveList or Mesh
Raises:
ValueError

If the nets contained in nets don’t satisfy the conditions in the description of nets.

Examples

>>> import ddg
>>> from ddg.arrays import from_net_collection
>>> curve_0 = ddg.nets.DiscreteCurve(lambda t: (t, 0), (0, 2, False))
>>> curve_1 = ddg.nets.DiscreteCurve(lambda t: (t, t**2), (0, 2, True))
>>> net_collection = ddg.nets.NetCollection([curve_0, curve_1])
>>> (points_0, periodicity_0), (points_1, periodicity_1) = from_net_collection(
...     net_collection
... )
>>> points_0
array([[0, 0],
       [1, 0],
       [2, 0]])
>>> periodicity_0
False
>>> points_1
array([[0, 0],
       [1, 1],
       [2, 4]])
>>> periodicity_1
True
>>> two_sheeted_hyperboloid = ddg.geometry.Quadric(np.diag([1, 1, -1, 1]))
>>> smooth_net_collection = ddg.to_smooth_net(two_sheeted_hyperboloid)
>>> mesh = ddg.arrays.from_net_collection(
...     smooth_net_collection, surface_sampling=(3, 0.1)
... )
>>> mesh.points
array([[ 0.        ,  0.        , -1.        ],
       [ 0.        ,  0.        , -1.        ],
       [ 0.        ,  0.        , -1.        ],
       [ 0.        , -0.10016675, -1.00500417],
       [ 0.08674695,  0.05008338, -1.00500417],
       [-0.08674695,  0.05008338, -1.00500417],
       [ 0.        , -0.201336  , -1.02006676],
       [ 0.17436209,  0.100668  , -1.02006676],
       [-0.17436209,  0.100668  , -1.02006676],
       [ 0.        ,  0.        ,  1.        ],
       [ 0.        ,  0.        ,  1.        ],
       [ 0.        ,  0.        ,  1.        ],
       [ 0.        , -0.10016675,  1.00500417],
       [ 0.08674695,  0.05008338,  1.00500417],
       [-0.08674695,  0.05008338,  1.00500417],
       [ 0.        , -0.201336  ,  1.02006676],
       [ 0.17436209,  0.100668  ,  1.02006676],
       [-0.17436209,  0.100668  ,  1.02006676]])
>>> mesh.faces
array([[ 0,  3,  4,  1],
       [ 1,  4,  5,  2],
       [ 3,  6,  7,  4],
       [ 4,  7,  8,  5],
       [ 0,  2,  5,  3],
       [ 3,  5,  8,  6],
       [ 9, 12, 13, 10],
       [10, 13, 14, 11],
       [12, 15, 16, 13],
       [13, 16, 17, 14],
       [ 9, 11, 14, 12],
       [12, 14, 17, 15]])
ddg.arrays.from_half_edge_surface(surface, coordinate_attribute='co', /)[source]

Get the points, isolated edges and faces of a half edge surface.

Parameters:
surfaceddg.halfedge.Surface
coordinate_attributestr (default=”co”)
Returns:
Mesh

Examples

>>> import ddg
>>> square = ddg.halfedge.grid((2, 2))
>>> (
...     points,
...     faces,
...     isolated_edges_square,
... ) = ddg.arrays.from_half_edge_surface(square)
>>> points
array([[0, 0],
       [1, 0],
       [0, 1],
       [1, 1]])
>>> faces
array([[1, 3, 2, 0]])
>>> isolated_edges_square
array([], shape=(0, 2), dtype=int64)
>>> surface = ddg.halfedge.grid((2, 2))
>>> vertex = ddg.halfedge.some_vertex(surface)
>>> isolated_vertex = surface.add_vertex()
>>> isolated_vertex.co = np.array([2, 2])
>>> surface.add_edge(vertex, isolated_vertex)
Edges(index=8, head=4, face=None, surface=...)
>>> (_, _, isolated_edges_surface) = ddg.arrays.from_half_edge_surface(surface)
>>> isolated_edges_surface
array([[4, 0]])
ddg.arrays.from_0d_subspace(point, /)[source]

Convert a point subspace to a mesh of one point and no faces.

Parameters:
pointddg.geometry.Subspace

A subspace with point.dimension == 0.

Returns:
Points

Examples

>>> import ddg
>>> point = ddg.geometry.subspace_from_affine_points((0, 0))
>>> ddg.arrays.from_0d_subspace(point)
Points(points=array([[0., 0.]]))
ddg.arrays.from_1d_subspace(line, length, /)[source]

Sample a 1-dimensional subspace.

Parameters:
lineddg.geometry.Subspace

A subspace with line.dimension == 1.

lengthfloat

Must be greater than or equal to 0.0.

Returns:
Curve(ab, False)

ab is an array_like of shape (subspace.ambient_dimension, 2) Let a = ab[0] and b = ab[1], then b - a has length length and b - a / 2 is the closest point of the line to the origin.

Raises:
ValueError

If line.dimension != 1 or length < 0.0.

Examples

>>> import ddg
>>> line = ddg.geometry.subspace_from_affine_points((0, 0, 0), (1, 0, 0))
>>> ab, periodicity = ddg.arrays.from_1d_subspace(line, 10)
>>> ab
array([[-5.,  0.,  0.],
       [ 5.,  0.,  0.]])
>>> periodicity
False
ddg.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 x is the closest point of the subspace to the origin.

Parameters:
planeddg.geometry.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:
Mesh(points, faces)

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 != 2 or side_length_1 < 0.0 or side_length_2 < 0.0.

Examples

>>> import ddg
>>> plane = ddg.geometry.subspace_from_affine_points(
...     (0, 0, 0), (1, 0, 0), (0, 1, 0)
... )
>>> points, faces, _ = ddg.arrays.from_2d_subspace(plane, 10, 4)
>>> points
array([[-5., -2.,  0.],
       [ 5., -2.,  0.],
       [ 5.,  2.,  0.],
       [-5.,  2.,  0.]])
>>> faces
array([[0, 1, 2],
       [0, 2, 3]])
ddg.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_step argument determines how I_k is sampled
    • the first entry num of the k-th num_step determines the number of samples of I_k

    • if I_k is unbounded, the second entry step of the k-th num_step determines the step size between the samples of I_k

Consequently,

  • increasing the num arguments 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 step results in a finer curve or mesh.

Parameters:
quadricddg.geometry.Quadric
*num_steptuple of an int and a float

The length of num_step must be 0 if quadric.dimension is -1 or 0 and otherwise must be equal to quadric.dimension.

Returns:
Points, Curve, CurveList or Mesh
Raises:
ValueError

If the quadric is a (possibly empty) set of points and num_step is given.

Examples

>>> import numpy as np
>>> import ddg
>>> xaxis = ddg.geometry.Quadric(np.diag([0, 1, 0]))
>>> xaxis_points, xaxis_periodicity = ddg.arrays.from_quadric(xaxis, (4, 0.1))
>>> xaxis_points
array([[ 0.1,  0. ],
       [ 0. ,  0. ],
       [-0.1,  0. ],
       [-0.2,  0. ]])
>>> xaxis_periodicity
False

A coarser sampling

>>> xaxis_points_coarser, _ = ddg.arrays.from_quadric(xaxis, (4, 0.5))
>>> xaxis_points_coarser
array([[ 0.5,  0. ],
       [ 0. ,  0. ],
       [-0.5,  0. ],
       [-1. ,  0. ]])
>>> two_sheeted_hyperboloid = ddg.geometry.Quadric(np.diag([1, 1, -1, 1]))
>>> mesh = ddg.arrays.from_quadric(two_sheeted_hyperboloid, (3, 0.1), (3, 0.1))
>>> mesh.points
array([[ 0.        ,  0.        , -1.        ],
       [ 0.        ,  0.        , -1.        ],
       [ 0.        ,  0.        , -1.        ],
       [ 0.        , -0.10016675, -1.00500417],
       [ 0.08674695,  0.05008338, -1.00500417],
       [-0.08674695,  0.05008338, -1.00500417],
       [ 0.        , -0.201336  , -1.02006676],
       [ 0.17436209,  0.100668  , -1.02006676],
       [-0.17436209,  0.100668  , -1.02006676],
       [ 0.        ,  0.        ,  1.        ],
       [ 0.        ,  0.        ,  1.        ],
       [ 0.        ,  0.        ,  1.        ],
       [ 0.        , -0.10016675,  1.00500417],
       [ 0.08674695,  0.05008338,  1.00500417],
       [-0.08674695,  0.05008338,  1.00500417],
       [ 0.        , -0.201336  ,  1.02006676],
       [ 0.17436209,  0.100668  ,  1.02006676],
       [-0.17436209,  0.100668  ,  1.02006676]])
>>> mesh.faces
array([[ 0,  3,  4,  1],
       [ 1,  4,  5,  2],
       [ 3,  6,  7,  4],
       [ 4,  7,  8,  5],
       [ 0,  2,  5,  3],
       [ 3,  5,  8,  6],
       [ 9, 12, 13, 10],
       [10, 13, 14, 11],
       [12, 15, 16, 13],
       [13, 16, 17, 14],
       [ 9, 11, 14, 12],
       [12, 14, 17, 15]])
ddg.arrays.from_quadric_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.QuadricSphere

A sphere that can be represented as a quadric.

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 array_like and the periodicity of type bool. A mesh is an tuple of points of type array_like and the faces of type array_like.

Examples

>>> import numpy as np
>>> import ddg
>>> euc = ddg.geometry.euclidean(3)
>>> s1 = euc.sphere((0, 0, 1), 1)
>>> s1_points, periodicity = ddg.arrays.from_quadric_sphere(s1, 4)
>>> s1_points
array([[-1.0000000e+00,  0.0000000e+00],
       [-6.1232340e-17, -1.0000000e+00],
       [ 1.0000000e+00, -1.2246468e-16],
       [ 1.8369702e-16,  1.0000000e+00]])
>>> periodicity
True
>>> s2 = euc.sphere((0, 0, 0, 1), 1)
>>> s2_points, faces, _ = ddg.arrays.from_quadric_sphere(s2, 4)
>>> s2_points
array([[ 1.00000000e+00,  0.00000000e+00,  0.00000000e+00],
       [ 1.00000000e+00,  0.00000000e+00,  0.00000000e+00],
       [ 1.00000000e+00,  0.00000000e+00,  0.00000000e+00],
       ...
       [-1.00000000e+00, -7.49879891e-33, -1.22464680e-16],
       [-1.00000000e+00,  1.22464680e-16, -1.49975978e-32],
       [-1.00000000e+00,  2.24963967e-32,  1.22464680e-16]])
>>> faces
array([[ 0,  4,  5,  1],
       [ 1,  5,  6,  2],
       [ 2,  6,  7,  3],
       ...
       [ 0,  3,  7,  4],
       [ 4,  7, 11,  8],
       [ 8, 11, 15, 12]])
ddg.arrays.from_indexed_face_set(ifs, coordinate_key='co', /)[source]

Get the points, and faces of an indexed face set.

Parameters:
ifsddg.indexedfaceset.IndexedFaceSet
coordinate_attributestr (default=”co”)
Returns:
Mesh

Examples

>>> import ddg
>>> cube = ddg.indexedfaceset.cube()
>>> points, faces, _ = ddg.arrays.from_indexed_face_set(cube)
>>> points
array([[-1, -1, -1],
       [ 1, -1, -1],
       [ 1, -1,  1],
       [-1, -1,  1],
       [-1,  1, -1],
       [ 1,  1, -1],
       [ 1,  1,  1],
       [-1,  1,  1]])
>>> faces
array([[4, 5, 1, 0],
       [6, 2, 1, 5],
       [7, 3, 2, 6],
       [4, 0, 3, 7],
       [1, 2, 3, 0],
       [7, 6, 5, 4]])
ddg.arrays.convert(convertible, /, curve_sampling=(100, 0.1), surface_sampling=(30, 0.1), subspace_size=100)[source]

Convert pyddg objects to points, curves and meshes encoded by array_like.

Parameters:
convertible

This must be an instance of:

- `ddg.geometry.Subspace` of dimension <= 2
- `ddg.geometry.Quadric` of dimension <= 2
- `ddg.geometry.spheres.QuadricSphere` of dimension <= 2
- `ddg.indexedfaceset.IndexedFaceSet` with coordinate attribute "co"
- `ddg.halfedge.Surface` with coordinate attribute "co"
- `ddg.nets.SmoothCurve`
- `ddg.nets.SmoothNet`
- `ddg.nets.DiscreteCurve`
- `ddg.nets.DiscreteNet`
- `ddg.nets.PointNet`
- `ddg.nets.EmptyNet`
- `ddg.nets.NetCollection` of smooth or discrete nets of the same dimension
- `ddg.arrays.Points`
- `ddg.arrays.Curve`
- `ddg.arrays.CurveList`
- `ddg.arrays.Mesh`
curve_samplingtuple of an int and a float

(default=_default_curve_sampling) Determines the sample number and stepsize for curves

surface_samplingtuple of an int and a float

(default=_default_surface_sampling) Determines the sample number and stepsize for surfaces

subspace_sizefloat

(default=_default_subspace_size) Determines the size of subspaces

Returns:
Points, Curve, CurveList or Mesh

Examples

>>> import ddg
>>> line = ddg.geometry.subspace_from_affine_points((0, 0, 0), (1, 0, 0))
>>> (a, b), periodicity = ddg.arrays.convert(line)
>>> a
array([-50.,   0.,   0.])
>>> b
array([50.,  0.,  0.])
>>> periodicity
False
>>> plane = ddg.geometry.subspace_from_affine_points(
...     (0, 0, 0), (1, 0, 0), (0, 1, 0)
... )
>>> points, faces, _ = ddg.arrays.convert(plane)
>>> points
array([[-50., -50.,   0.],
       [ 50., -50.,   0.],
       [ 50.,  50.,   0.],
       [-50.,  50.,   0.]])
>>> faces
array([[0, 1, 2],
       [0, 2, 3]])
class ddg.arrays.Curve(points, periodicity, /)[source]

Bases: object

A discrete curve in R^d for d <= 3.

The curve consists of the line segments between its points. This class should not be confused with ddg.nets.DiscreteCurve!

Parameters:
pointsarray_like of shape (num_points, d) and integer or floating point dtype

The dimension d may be at most 3.

periodicitybool

If True, there is an additional line segment between the last and the first point. If False, there is no such line segment.

Attributes:
pointsnumpy.ndarray of shape (num_points, d) and integer or floating point dtype

This is an actual ndarray and not just an array_like.

periodicitybool
points: ndarray
periodicity: bool
class ddg.arrays.CurveList(curves, /)[source]

Bases: list

A list of ddg.arrays.Curve.

Parameters:
curvessequence of ddg.array.Curve
append(object, /)

Append object to the end of the list.

clear(/)

Remove all items from list.

copy(/)

Return a shallow copy of the list.

count(value, /)

Return number of occurrences of value.

extend(iterable, /)

Extend list by appending elements from the iterable.

index(value, start=0, stop=sys.maxsize, /)

Return first index of value.

Raises ValueError if the value is not present.

insert(index, object, /)

Insert object before index.

pop(index=-1, /)

Remove and return item at index (default last).

Raises IndexError if list is empty or index is out of range.

remove(value, /)

Remove first occurrence of value.

Raises ValueError if the value is not present.

reverse(/)

Reverse IN PLACE.

sort(*, key=None, reverse=False)

Sort the list in ascending order and return None.

The sort is in-place (i.e. the list itself is modified) and stable (i.e. the order of two equal elements is maintained).

If a key function is given, apply it once to each list item and sort them, ascending or descending, according to their function values.

The reverse flag can be set to sort in descending order.

class ddg.arrays.Mesh(points, faces, non_manifold_edges=array([], shape=(0, 2), dtype=int64), /)[source]

Bases: object

A mesh in R^d for d <= 3.

This is the standard representation of a polygon mesh. See

https://en.wikipedia.org/wiki/Polygon_mesh#Face-vertex_meshes

for more details. This class should not be confused with ddg.indexedfaceset.IndexedFaceSet!

Parameters:
pointsarray_like of shape (num_points, d) and integer or floating point dtype

The dimension d may be at most 3.

facesarray_like or sequence

If this is an array_like, it must have shape (num_faces, n) and integer dtype. In particular, every face must have n vertices. Every row represents a face. If this is a sequence, then its elements must themselves be sequences of integers, which represent faces. They don’t need to have the same number of vertices.

non_manifold_edgesarray_like of shape (num_edges, 2) and integer dtype

Additional edges that are distinct from the boundary edges of the faces. Each row (i, j) represents an edge from the i-th to the j-th vertex.

Attributes:
pointsnumpy.ndarray of shape (num_points, d) and integer or floating point dtype

This is an actual ndarray and not just an array_like.

facesnumpy.ndarray or sequence

If this is a numpy.ndarray, then it has shape (num_faces, n) and integer dtype. If this is a sequence, then it is a sequence of integer sequences. The numpy.ndarray representation is preferred - faces is always a numpy.ndarray if every face has the same number of vertices.

non_manifold_edgesarray_like of shape (num_edges, 2) and integer dtype

This is an actual ndarray and not just an array_like.

points: ndarray
faces: numpy.ndarray | collections.abc.Sequence[collections.abc.Sequence[int]]
non_manifold_edges: ndarray = array([], shape=(0, 2), dtype=int64)
class ddg.arrays.Points(points, /)[source]

Bases: object

Points in R^d for d <= 3.

Parameters:
pointsarray_like of shape (num_points, d) and integer or floating point dtype

The dimension d may be at most 3.

Attributes:
pointsnumpy.ndarray of shape (num_points, d) and integer or floating point dtype

This is an actual ndarray and not just an array_like.

points: ndarray
ddg.arrays.mesh_union(meshes, /)[source]

Union of meshes.

Parameters:
meshessequence of ddg.arrays.Mesh
Returns:
ddg.arrays.Mesh

Examples

>>> import ddg
>>> triangle_1 = ddg.arrays.Mesh(
...     np.array([(0, 0, 0), (1, 0, 0), (1, 1, 0)]), [(0, 1, 2)]
... )
>>> triangle_2 = ddg.arrays.Mesh(
...     np.array([(0, 0, 0), (0, 1, 0), (0, 0, 1)]), [(0, 1, 2)]
... )
>>> points, faces, non_manifold_edges = ddg.arrays.mesh_union(
...     (triangle_1, triangle_2)
... )
>>> points
array([[0, 0, 0],
       [1, 0, 0],
       [1, 1, 0],
       [0, 0, 0],
       [0, 1, 0],
       [0, 0, 1]])
>>> faces
array([[0, 1, 2],
       [3, 4, 5]])
>>> non_manifold_edges
array([], shape=(0, 2), dtype=int64)
ddg.arrays.edges(mesh, /)[source]
ddg.arrays.line_segment_from_points(point0, point1, /, domain=(0, 1))[source]

Get a line segment defined by two points as a curve.

Returns the line segment between the two points:

(1 - domain[0]) * point0 + domain[0] * point1,
(1 - domain[1]) * point0 + domain[1] * point1.
Parameters:
point0, point1ddg.geometry.Point, Points, or array_like

The points defining the line segment or their affine coordinates. Must be at most 3-dimensional.

domaintuple[float, float], optinal

Defines the end points of the line segment in relation to the first point and the direction vector between the two points.

Returns:
ddg.arrays.Curve
Raises:
ValueError

If a given point is at infinity.

Examples

>>> import ddg
>>> line_segment = ddg.arrays.line_segment_from_points(
...     [0, 0, 0], ddg.geometry.Point([2, 2, 2, 1]), [-0.5, 1]
... )
>>> line_segment
Curve(points=array([[-1., -1., -1.],
       [ 2.,  2.,  2.]]), periodicity=False)
ddg.arrays.line_segment_from_point_and_direction(point, direction, domain=(0, 1), normalized=False)[source]

Get a line segment defined by a point and a direction vector as a curve.

Returns the line segment between the two points:

point + domain[0] * direction,
point + domain[1] * direction

where `direction` may have been normalized before.
Parameters:
pointddg.geometry.Point, Points or array_like

Location point of the line segment. Must be at most 3-dimensional.

directionddg.geometry.Point or array_like

Direction vector of the line segment as a Point at infinity or as a coordinate vector. The dimension must match the one of point.

domaintuple[float, float], optional

Defines the end points of the line segment in relation to the location point and the direction vector.

normalizedbool, optional

Whether the direction vector should be normalized. If this is set to True, the length of the line segment coincides with the length of the domain.

Returns:
ddg.arrays.Curve
Raises:
ValueError

If the location point lies at infinity. If the direction vector is an object of type ddg.geometry.Point which is not at infinity.

Examples

>>> import ddg
>>> line_segment = ddg.arrays.line_segment_from_point_and_direction(
...     [1, 1, 1], ddg.geometry.Point([1, 1, 1, 0]), [-1, 1]
... )
>>> line_segment
Curve(points=array([[0., 0., 0.],
       [2., 2., 2.]]), periodicity=False)
>>> line_segment = ddg.arrays.line_segment_from_point_and_direction(
...     [1, 1, 1], ddg.geometry.Point([10, 10, 10, 0]), [-1, 1], True
... )
>>> line_segment
Curve(points=array([[0.42264973, 0.42264973, 0.42264973],
       [1.57735027, 1.57735027, 1.57735027]]), periodicity=False)