This commit is contained in:
Miloslav Ciz 2023-02-03 16:05:52 +01:00
parent dca5de8c96
commit e931e47a1f
10 changed files with 98 additions and 24 deletions

43
line.md
View file

@ -1,17 +1,17 @@
# Line
Line is one of the most basic geometric shapes, it is straight, continuous, infinitely long and infinitely thin. A finite continuous part of a line is called **line segment**, though in practice we sometimes call line segments also just *lines*. Shortest path between any two points always lies on a line. { At least I hope :D ~drummyfish }
Line is one of the most basic geometric shapes, it is straight, continuous, infinitely long and infinitely thin. A finite continuous part of a line is called **line segment**, though in practice we sometimes call line segments also just *lines*. In flat, non-curved geometries shortest path between any two points always lies on a line.
Line is a one [dimensional](dimension.md) shape, i.e. any of its points can be identified by a single straightforward number (signed distance from a certain point on the line). But of course a line itself may exist in more than one dimensional spaces (just as a two dimensional sheet of paper can exist in our three dimensional space etc.).
Line is a one [dimensional](dimension.md) shape, i.e. any of its points can be directly identified by a single number -- the signed distance from a certain point on the line. But of course a line itself may exist in more than one dimensional spaces (just as a two dimensional sheet of paper can exist in our three dimensional space etc.).
```
/ | \
/ ________ | \
/ | \
/ | \
/ | \ .'
/ ________ | \ .'
/ | \ .'
/ | \ .'
```
*some lines, in case you haven't see one yet*
*some lines, in case you haven't seen one yet*
## Equations
@ -46,4 +46,31 @@ Now for whatever *t* we plug into these equations we get the *[x,y]* coordinates
## Line Drawing Algorithms
TODO
Drawing lines with computers is a subject of [computer graphics](graphics.md). On specific devices such as [vector monitors](vector_monitor.md) this may be a trivial task, however as most display devices nowadays work with [raster graphics](raster_graphics.md), let's from now on focus only on such devices.
There are many [algorithms](algorithm.md) for line [rasterization](rasterization.md). They differ in attributes such as:
- complexity of implementation
- speed/efficiency (some algorithms avoid the use of [floating point](float.md) which requires special [hardware](hardware.md))
- support of [antialiasing](antialiasing.md) ("smooth" vs "pixelated" lines)
- [subpixel](subpixel.md) precision (whether start and end point of the line has to lie exactly on integer pixel coordinates; subpixel precision makes for smoother animation)
- support for different width lines (and additionally e.g. the shape of line segment ends etc.)
- ...
```
.
XXX XX .aXa
XX XX lXa.
XX XX .lXl
XXX XXX .aal
XX XX lXa.
XX XXX .aXl
XX XX a.
pixel subpixel subpixel accuracy
accuracy accuracy + anti-aliasing
```
One of the most basic line rasterization algorithms is the [DDA](dda.md) (Digital differential analyzer), however it is usually better to use at least the [Bresenham's line algorithm](bresenham.md) which is still simple and considerably improves on DDA.
TODO: more algorithms, code example, general form (dealing with different direction etc.)