This shows you the differences between two versions of the page.
Both sides previous revisionPrevious revisionNext revision | Previous revisionNext revisionBoth sides next revision | ||
math [2019/07/04 20:44] – [AnglesToVector] korshun | math [2019/08/26 21:25] – [Dot product] 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: '' | ||
+ | |||
+ | '' | ||
+ | |||
+ | ==== 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, | ||
Line 292: | Line 305: | ||
Converts the vector' | Converts the vector' | ||
- | <note important> | + | <note important> |
=== Example usage === | === Example usage === | ||
Line 305: | Line 318: | ||
int pitch = r2; | int pitch = r2; | ||
SetActorAngle(tid, | SetActorAngle(tid, | ||
- | SetActorPitch(tid, | + | SetActorPitch(tid, |
} | } | ||
</ | </ | ||
Line 319: | Line 332: | ||
< | < | ||
- | AnglesToVector(GetActorAngle(0), | + | AnglesToVector(GetActorAngle(0), |
int dirX = r1; | int dirX = r1; | ||
int dirY = r2; | int dirY = r2; |