Line

Line[{p1,p2,}]

represents the line segments joining a sequence for points pi.

Line[{{p11,p12,},{p21,},}]

represents a collection of lines.

Details and Options

Background & Context

  • Line is a graphics and geometry primitive that represents a geometric line segment or sequence of connected line segments (a "poly-line"). The location of a Line connecting points in -dimensional space is specified as a list argument consisting of sublists, with each sublist containing Cartesian coordinate values. The coordinate sublists of Line objects may consist of exact or approximate values, where RegionEmbeddingDimension can be used to determine the dimension for a given Line expression. A collection of lines (or poly-lines) may be represented as a nested lists of -tuples inside a single Line primitive (a "multiline"). The coordinates of Line objects may have exact or approximate values.
  • Line objects can be visually formatted in two and three dimensions using Graphics and Graphics3D, respectively. Line objects can also be used in geographical maps using GeoGraphics and GeoPosition (e.g. GeoGraphics[Line[GeoPosition[{{38.9,-77.0},{40.1,-88.3}}]]]). In addition, Line may serve as a region specification over which a computation should be performed.
  • While lines themselves have dimension 1 (as reported by the RegionDimension function) with zero thickness, Line objects in formatted graphics expressions are by default styled to appear "thicker" than a one-dimensional mathematical line. Furthermore, in graphical visualizations, lines are displayed at the same size regardless of varying distances from the view point. The appearance of Line objects in graphics can be modified by specifying thickness directives such as Thickness, AbsoluteThickness, Thick, and Thin; dashing directives such as Dashing, AbsoluteDashing, Dashed, Dotted, and DotDashed; edge and cap directives EdgeForm and CapForm; color directives such as Red; the transparency directive Opacity; and the style option Antialiasing. In addition, the colors of multilines may be specified using VertexColors, while the shading and simulated lighting of multilines within Graphics3D may be specified using VertexNormals.
  • GeometricTransformation and more specific transformation functions such as Translate and Rotate can be used to change the coordinates at which a Line object is displayed while leaving the underlying Line expression untouched.
  • Other graphics primitives such as Tube, Arrow, HalfLine, and InfiniteLine may resemble those of stylized Line objects. While poly-lines consist only of straight line segments, smooth curves may be constructed via splines using BSplineCurve or BezierCurve or via an interpolating function using Interpolation. A function related to Line as a geometric region is Interval, which interprets pairs of numbers as endpoints of a line segment lying on the number line and which can be directly operated on using arithmetic and relational operators.
  • While the Line primitive explicitly appears in graphics and geometric region specification expressions, it should be noted that coordinates are commonly represented as bare lists in other contexts in the Wolfram Language. However, a number of graphics functions including Plot, ParametricPlot, ParametricPlot3D, and ContourPlot return graphical expressions that explicitly include Line objects.

Examples

open allclose all

Basic Examples  (4)

A line primitive:

Differently styled 2D lines:

Differently styled 3D lines:

Compute the ArcLength of a line:

Centroid:

Scope  (24)

Graphics  (14)

Specification  (3)

Single line segment:

Multiple connected line segments:

Multiple disconnected line segments:

Styling  (8)

Lines with different thicknesses:

Thickness in scaled size:

Thickness in printer's points:

Dashed lines:

Colored lines:

Line caps can be specified using CapForm:

Joining of line segments can be specified using JoinForm:

Colors can be specified at vertices using VertexColors:

Normals can be specified at vertices using VertexNormals for 3D lines:

Coordinates  (3)

Use Scaled coordinates:

Use ImageScaled coordinates in 2D:

Use Offset coordinates in 2D:

Regions  (10)

Embedding dimension is the dimension of the space in which the line lives:

Geometric dimension:

Point membership test:

Get conditions for point membership:

Length:

Centroid:

Distance to a line:

Visualize it:

Signed distance from a line segment:

Signed distance to a line segment:

Nearest point in the region:

Nearest points:

A line segment is bounded:

Get its range:

Integrate over a polygonal curve:

Optimize over a polygonal curve:

Solve equations in a polygonal curve:

Options  (3)

VertexColors  (2)

Line with vertex colors:

Specify vertex colors for 3D lines:

VertexNormals  (1)

Specify vertex normals for 3D lines:

Applications  (6)

Complete graph with 11 nodes:

The tangent bundle for a quadratic curve:

A vector field:

2D random walk on a regular lattice:

3D random walk on a regular lattice:

Replace Polygon with Line to have special rendering effects:

Use a random collection of light sources:

Use lines to estimate the length of a curve:

Increase the number of line segments for a better estimate:

Properties & Relations  (4)

Several visualization functions produce Line objects:

Use directive styles appropriate for lines:

You can also transform the output:

The same idea applies in 3D:

This shows the points at which it was sampled:

ImplicitRegion can be used to represent any Line region:

ParametricRegion can be used to represent any Line region:

Possible Issues  (1)

Line objects need to be specified using numbers that can be represented by machine numbers:

Neat Examples  (4)

A random collection of lines:

Lines with lighting:

Moiré pattern:

Tangent vectors along an elliptic curve:

Wolfram Research (1988), Line, Wolfram Language function, https://reference.wolfram.com/language/ref/Line.html (updated 2014).

Text

Wolfram Research (1988), Line, Wolfram Language function, https://reference.wolfram.com/language/ref/Line.html (updated 2014).

CMS

Wolfram Language. 1988. "Line." Wolfram Language & System Documentation Center. Wolfram Research. Last Modified 2014. https://reference.wolfram.com/language/ref/Line.html.

APA

Wolfram Language. (1988). Line. Wolfram Language & System Documentation Center. Retrieved from https://reference.wolfram.com/language/ref/Line.html

BibTeX

@misc{reference.wolfram_2024_line, author="Wolfram Research", title="{Line}", year="2014", howpublished="\url{https://reference.wolfram.com/language/ref/Line.html}", note=[Accessed: 21-November-2024 ]}

BibLaTeX

@online{reference.wolfram_2024_line, organization={Wolfram Research}, title={Line}, year={2014}, url={https://reference.wolfram.com/language/ref/Line.html}, note=[Accessed: 21-November-2024 ]}