This shows you the differences between two versions of the page.
| Both sides previous revisionPrevious revisionNext revision | Previous revision | ||
| math [2019/07/05 19:38] – [VectorToAngles] korshun | math [2019/08/26 18:26] (current) – [Length] korshun | ||
|---|---|---|---|
| Line 162: | Line 162: | ||
| '' | '' | ||
| - | Returns x^y. Uses a simple multiplication loop. | + | Returns x<sup>y</ |
| ==== fpow ==== | ==== fpow ==== | ||
| '' | '' | ||
| - | returns x^y. Supports powers below '' | + | returns x<sup>y</ |
| Line 192: | Line 192: | ||
| ===== Vector math ===== | ===== Vector math ===== | ||
| - | ==== VectorLength3D ==== | + | Vector math functions come in 2D and 3D versions. All vector math functions operate only on fixed-point vectors. No integer versions are available. |
| - | '' | + | |
| - | A 3D version of [[zdoom> | + | Vectors are passed as arguments named '' |
| + | |||
| + | If a function returns a vector, it uses [[multiple return values]], returning vector components in the same XYZ order, so '' | ||
| + | |||
| + | If a function accepts more than one vector, the first vector is passed as '' | ||
| + | |||
| + | |||
| + | ==== Length ==== | ||
| + | |||
| + | * 2D: [[zdoom> | ||
| + | * 3D: '' | ||
| + | |||
| + | These functions return | ||
| + | |||
| + | ==== Dot product ==== | ||
| - | ==== dot ==== | ||
| * 2D: '' | * 2D: '' | ||
| * 3D: '' | * 3D: '' | ||
| - | Returns | + | These functions return the sum of components of a vector obtained by componentwise multiplication of the two input vectors, also known as the [[wp>dot product]]. |
| + | |||
| + | ==== Normalization ==== | ||
| - | ==== normalize ==== | ||
| * 2D: '' | * 2D: '' | ||
| * 3D: '' | * 3D: '' | ||
| - | [[wp> | + | These functions return the input vector scaled to have length '' |
| - | === Example usage === | + | === Examples |
| < | < | ||
| normalize3d(x, | normalize3d(x, | ||