Update
This commit is contained in:
parent
5604db85d2
commit
d8f1711fa8
33 changed files with 2096 additions and 2036 deletions
16
line.md
16
line.md
|
@ -1,8 +1,8 @@
|
|||
# Line
|
||||
|
||||
Line is one of the most basic geometric shapes, it is straight, continuous, [infinitely](infinity.md) 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*. Considering normal, finite dimensional non-curved space/geometry without any obstacles etc., the shortest path between any two distinct points always lies on a line, which is also the only line that goes through both of these points.
|
||||
Line is one of the most primitive and basic [geometric](geometry.md) shapes, it is straight, continuous, [infinitely](infinity.md) 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*. Assuming normal, finite dimensional non-curved space/geometry without any obstacles etc., the shortest path between any two distinct [points](point.md) always lies on a line, which is also the only line that goes through both of these points.
|
||||
|
||||
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.).
|
||||
Line is a one [dimensional](dimension.md) shape, i.e. any of its points can be directly identified by a single [number](number.md) -- the signed [distance](distance.md) 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.).
|
||||
|
||||
{ In my favorite book [Flatland](flatland.md) line segments, being the most primitive shape, represent [women](woman.md). ~drummyfish }
|
||||
|
||||
|
@ -17,10 +17,10 @@ Line is a one [dimensional](dimension.md) shape, i.e. any of its points can be d
|
|||
|
||||
## Representing Lines With Equations
|
||||
|
||||
Mathematically lines can be defined by [equations](equation.md) with space coordinates (see [analytic geometry](analytic_geometry.md)) -- this is pretty important for example for [programming](programming.md) as many times we need to compute intersections with lines; for example [ray casting](raycasting.md) is a method of 3D rendering that "shoots lines from camera" and looks at which objects the lines intersect. Line equations can have different "formats", the two most important are:
|
||||
[Mathematically](math.md) lines can be defined by [equations](equation.md) with space coordinates (see [analytic geometry](analytic_geometry.md)) -- this is pretty important for example for [programming](programming.md) as many times we need to compute intersections with lines; for example [ray casting](raycasting.md) is a method of [3D rendering](3d_rendering.md) that "casts lines from camera" and looks at which objects the lines intersect. Line equations can have different "formats", the two most important are:
|
||||
|
||||
- **point-slope**: This equation only works in 2D space (in 3D this kind of equation will not describe a line but rather a [plane](plane.md)) and only for lines that aren't completely vertical (lines close to vertical may also pose problems in computers with limited precision numbers). The advantage is that we have a single, pretty simple equation. The equation is of form *y = k * x + q* where *x* and *y* are space coordinates, *k* is the [slope](slope.md) of the line and *q* is an offset. See examples below for more details.
|
||||
- **parametric**: This is a system of *N* equations, where *N* is the number of dimensions of the space the line is in. This way can describe any line in any dimensional space -- obviously the advantage here is that we can can use this form in any situation. The equations are of form *Xn = Pn + t * Dn* where *Xn* is *n*th coordinate (*x*, *y*, *z*, ...), *Pn* is *n*th coordinate of some point *P* that lies on the line, *Dn* is *n*th coordinate of the line's direction [vector](vector.md) and *t* is a variable parameter (plugging in different numbers for *t* will yield different points that lie on the line). DON'T PANIC if you don't understand this, see the examples below :)
|
||||
- **point-slope**: This equation only works in 2D space (in 3D this kind of equation will not describe a line but rather a [plane](plane.md)) and only for lines that aren't completely vertical (lines close to vertical may also pose problems in computers with limited precision numbers). It expresses the *y* coordinate as the [function](function.md) of the *x* coordinate. The advantage is that we have a single, pretty simple and straightforward equation. The equation is of form *y = k * x + q* where *x* and *y* are space coordinates, *k* is the [slope](slope.md) of the line and *q* is an offset. See examples below for more details.
|
||||
- **parametric**: This is a system of *N* equations, where *N* is the number of dimensions of the space the line inhabits. This way can describe any line in any dimensional space -- obviously the advantage here is that we can can use this form in any situation. The equations are of form *Xn = Pn + t * Dn* where *Xn* is *n*th coordinate (*x*, *y*, *z*, ...), *Pn* is *n*th coordinate of some point *P* that lies on the line, *Dn* is *n*th coordinate of the line's direction [vector](vector.md) and *t* is a variable parameter (plugging in different numbers for *t* will yield different points that lie on the line). DON'T PANIC if you don't understand this, see the examples below :)
|
||||
|
||||
As an equation for line segment we simply limit the equation for an infinite line, for example with the parametric equations we limit the possible values of *t* by an interval that corresponds to the two boundary points.
|
||||
|
||||
|
@ -48,7 +48,7 @@ Now for whatever *t* we plug into these equations we get the *[x,y]* coordinates
|
|||
|
||||
## Formulas
|
||||
|
||||
Here let be formulas for computing various things related to lines and line segments.
|
||||
This section is a collection of formulas and equations related to lines and line segments.
|
||||
|
||||
First let's take a look at lines in 2D. Consider two dimensional plane. Let *L* be a line (or line segment) going from point *L1 = [L1x,L1y]* to point *L2 = [L2x,L2y]*. Let *dx = L2x - L1x* and *dy = L2y - L1y*. Let *K* be another line (or line segment). Let *P = [Px,Py]* be a point.
|
||||
|
||||
|
@ -65,9 +65,9 @@ TODO: 3D lines
|
|||
|
||||
## Line Drawing Algorithms
|
||||
|
||||
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) ([pixel](pixel.md)s!), let's from now on focus only on such devices. It is worth spending some time on [optimizing](optimization.md) your line drawing function as it constitutes a very basic operation -- consider that you will for example be using it for [wireframe](wireframe.md) rendering of a large 3D scene which will require drawing tens of thousands lines each frame -- having a fast line drawing function here can significantly improve your [FPS](fps.md).
|
||||
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) ([pixel](pixel.md)s!), let's from now on focus only on such devices. It is worth spending some time on [optimizing](optimization.md) your line drawing function as it constitutes a very common operation -- imagine that you will for example be using it for [wireframe](wireframe.md) rendering of a large 3D scene which will require rasterizing tens of thousands lines each frame -- in this case a fast line drawing function can significantly improve your [FPS](fps.md).
|
||||
|
||||
There are many [algorithms](algorithm.md) for line [rasterization](rasterization.md). They differ in attributes such as:
|
||||
There are many [algorithms](algorithm.md) for line [rasterization](rasterization.md). They vary 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))
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue