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
Next revisionBoth sides next revision
math [2019/07/05 22:38] – [VectorToAngles] korshunmath [2019/08/26 21:16] korshun
Line 162: Line 162:
 ''int ipow(int x, int y)'' ''int ipow(int x, int y)''
  
-Returns x^y. Uses a simple multiplication loop.+Returns x<sup>y</sup>. Uses a simple multiplication loop.
  
 ==== fpow ==== ==== fpow ====
 ''fixed fpow(fixed x, fixed y)'' ''fixed fpow(fixed x, fixed y)''
  
-returns x^y. Supports powers below ''1.0''. Uses a simple loop with ''FixedMul'' or ''FixedDiv'', depending on whether the power is below ''1.0''.+returns x<sup>y</sup>. Supports powers below ''1.0''. Uses a simple loop with ''FixedMul'' or ''FixedDiv'', depending on whether the power is below ''1.0''.
  
  
Line 192: Line 192:
 ===== Vector math ===== ===== Vector math =====
  
-==== VectorLength3D ==== +==== Length ====
-''fixed VectorLength3D(fixed x, fixed y, fixed z)''+
  
-A 3D version of [[zdoom>VectorLength]]. Returns the length of the 3D vector.+  * 2D: [[zdoom>VectorLength]] 
 +  * 3D: ''fixed VectorLength3D(fixed x, fixed y, fixed Z)'' 
 + 
 +''VectorLength3D'' is implemented efficiently as ''VectorLength(VectorLength(x, y), z)''. 
 + 
 +==== Dot product ====
  
-==== dot ==== 
   * 2D: ''fixed dot2(fixed x1, fixed y1, fixed x2, fixed y2)''   * 2D: ''fixed dot2(fixed x1, fixed y1, fixed x2, fixed y2)''
   * 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)''
  
-Returns the [[wp>dot product]] of two vectors. Shorthand for writing out ''FixedMul(x1, x2) + FixedMul(y1, y2) + ...''.+These functions return the [[wp>dot product]] of two vectors. They are shorthands for writing out ''FixedMul(x1, x2) + FixedMul(y1, y2) + ...''. 
 + 
 +==== Normalization ====
  
-==== normalize ==== 
   * 2D: ''fixed, fixed normalize2d(fixed x, fixed y)''   * 2D: ''fixed, fixed normalize2d(fixed x, fixed y)''
   * 3D: ''fixed, fixed, fixed normalize3d(fixed x, fixed y, fixed z)''   * 3D: ''fixed, fixed, fixed normalize3d(fixed x, fixed y, fixed z)''
  
-[[wp>Normalized vector|Normalizes]] the vector and returns the result using [[multiple return values]].+These functions [[wp>Normalized vector|Normalize]] the input vector and return the result using [[multiple return values]].
  
 === Example usage === === Example usage ===
math.txt · Last modified: 2019/08/26 21:26 by korshun