shapes.line_segment#

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

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)

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().

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.  ]]