ACSUtils Wiki

An ACS library for ZDoom-based ports

User Tools

Site Tools


math

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revisionPrevious revision
Next revision
Previous revision
Last revisionBoth sides next revision
math [2019/08/26 21:21] – [Vector math] korshunmath [2019/08/26 21:26] – [Length] korshun
Line 196: Line 196:
 Vectors are passed as arguments named ''x'', ''y'', ''z''. Vectors are passed as arguments named ''x'', ''y'', ''z''.
  
-If a function returns a vector, it uses [[multiple return values]], returning vector components in the same "X Y Z" order, so ''r1'' is X, ''r2'' is Y and ''r3'' is Z.+If a function returns a vector, it uses [[multiple return values]], returning vector components in the same XYZ order, so ''r1'' is X, ''r2'' is Y and ''r3'' is Z.
  
 If a function accepts more than one vector, the first vector is passed as ''x1'', ''y1'', ''z1'', and the second one as ''x2'', ''y2'', ''z2''. If a function accepts more than one vector, the first vector is passed as ''x1'', ''y1'', ''z1'', and the second one as ''x2'', ''y2'', ''z2''.
Line 206: Line 206:
   * 3D: ''fixed VectorLength3D(fixed x, fixed y, fixed Z)''   * 3D: ''fixed VectorLength3D(fixed x, fixed y, fixed Z)''
  
-''VectorLength3D'' is implemented efficiently as ''VectorLength(VectorLength(x, y), z)''.+These functions return the length of the input vector. ''VectorLength3D'' is implemented efficiently as ''VectorLength(VectorLength(x, y), z)''.
  
 ==== Dot product ==== ==== Dot product ====
Line 213: Line 213:
   * 3D: ''fixed dot3(fixed x1, fixed y1, fixed z1, fixed x2, fixed y2, fixed z2)''   * 3D: ''fixed dot3(fixed x1, fixed y1, fixed z1, fixed x2, fixed y2, fixed z2)''
  
-These functions return the [[wp>dot product]] of two vectors. They are shorthands for writing out ''FixedMul(x1, x2) + FixedMul(y1, y2) + ...''.+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]]. They are shorthands for writing out ''FixedMul(x1, x2) + FixedMul(y1, y2) + ...''.
  
 ==== Normalization ==== ==== Normalization ====
Line 220: Line 220:
   * 3D: ''fixed, fixed, fixed normalize3d(fixed x, fixed y, fixed z)''   * 3D: ''fixed, fixed, fixed normalize3d(fixed x, fixed y, fixed z)''
  
-These functions [[wp>Normalized vector|Normalize]] the input vector and return the result using [[multiple return values]].+These functions return the input vector scaled to have length ''1.0'', also known as [[wp>Normalized vector|normalizing]] the input vectorand return the result using [[multiple return values]].
  
-=== Example usage ===+=== Examples ===
 <code> <code>
 normalize3d(x, y, z); normalize3d(x, y, z);
math.txt · Last modified: 2019/08/26 21:26 by korshun