shapes.line_segment#

shapes.line_segment(p1=(0.0, 0.0, 0.0), p2=(1.0, 0.0, 0.0), div=None, elsize=None)#

Create a line segment between two points.

Parameters#

p1array_like of shape (3,)

Starting point of the line segment.

p2array_like of shape (3,)

End point of the line segment.

divint, list of float, or tuple (seed), optional

Subdivision specification. This is passed to smartSeed():

  • If int: number of equal subdivisions.

  • If list of floats: explicit subdivision values (must start with 0.0 and end with 1.0).

  • If tuple: (n, bias_start, bias_end), see smartSeed().

elsizefloat or sequence of two floats, optional

Target element size specification (mutually exclusive with div):

  • If float: uniform element size along the segment.

  • If [h1, h2]: element size at start and end with smooth grading.

Returns#

Mesh

A Mesh with eltype line2.

Examples#

>>> L1 = line_segment(div=5)
>>> print(L1)
Mesh: n_nodes: 6, n_elems: 5, plexitude: 2, level: 1, eltype: line2
BBox: [0. 0. 0.], [1. 0. 0.]
Size: [1. 0. 0.]
Length: 1.0
>>> print(L1.coords)
[[0.  0.  0. ]
[0.2 0.  0. ]
[0.4 0.  0. ]
[0.6 0.  0. ]
[0.8 0.  0. ]
[1.  0.  0. ]]

Specifying the subdivision using a list of floats:

>>> L2 = line_segment(div=[0.0, 0.1, 0.3, 0.7, 0.9, 1.0])
>>> print(L2.coords)
[[0.  0.  0. ]
[0.1 0.  0. ]
[0.3 0.  0. ]
[0.7 0.  0. ]
[0.9 0.  0. ]
[1.  0.  0. ]]

Specifying the subdivision using a tuple. First value determines the number of subdivisions, the second and third the attraction towards the start and end point respectively. A value larger than zero will attract the points, while a negative value will repulse them. See smartSeed().

>>> L3 = line_segment(div=(5, 1))
>>> print(L3.coords)
[[0.   0.   0.  ]
[0.04 0.   0.  ]
[0.16 0.   0.  ]
[0.36 0.   0.  ]
[0.64 0.   0.  ]
[1.   0.   0.  ]]

Using uniform element size:

>>> L4 = line_segment([0, 0, 0], [1, 0, 0], elsize=0.2)
>>> print(L4.coords)
[[0.  0.  0. ]
[0.2 0.  0. ]
[0.4 0.  0. ]
[0.6 0.  0. ]
[0.8 0.  0. ]
[1.  0.  0. ]]

Using graded element size (fine → coarse):

>>> L5 = line_segment([0, 0, 0], [1, 0, 0], elsize=[0.05, 0.2])
>>> print(L5.coords)
[[0.     0.     0.    ]
 [0.05   0.     0.    ]
 [0.1214 0.     0.    ]
 [0.2143 0.     0.    ]
 [0.3286 0.     0.    ]
 [0.4643 0.     0.    ]
 [0.6214 0.     0.    ]
 [0.8    0.     0.    ]
 [1.     0.     0.    ]]