ACSUtils Wiki

An ACS library for ZDoom-based ports

User Tools

Site Tools


new: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
new:math [2018/02/20 18:43] korshunnew:math [2018/02/21 13:11] korshun
Line 26: Line 26:
  
   * ''fixed IntDiv(int x, int y)'' -- divides two integers and returns fixed-point result. Supports any pair of integers whose ratio is less than 32767.   * ''fixed IntDiv(int x, int y)'' -- divides two integers and returns fixed-point result. Supports any pair of integers whose ratio is less than 32767.
-  * ''fixed AngleDiff(fixed a, fixed b)'' -- returns the shortest rotation angle needed to go from A to B. Result is always in [-0.5, 0.5]. Both A and B may be outside [0.0, 1.0].+  * ''fixed AngleDiff(fixed a, fixed b)'' -- returns the shortest signed rotation angle needed to go from angle A to angle B. Result is always in [-0.5, 0.5]. Both A and B may be outside [0.0, 1.0].
   * ''num gcf(num a, num b)'' -- returns the greatest common factor of two numbers.   * ''num gcf(num a, num b)'' -- returns the greatest common factor of two numbers.
 +  * ''fixed fract(fixed x)'' -- returns the fractional part of X. For example, ''fract(12.345)'' returns ''0.345''. ''fract(-1234.56789) == 0.56789''.
 +
  
 ==== Powers ==== ==== Powers ====
Line 69: Line 71:
   * ''fixed, fixed VectorToAngles(fixed x, fixed y, fixed z)'' -- converts vector to a pair of angles (angle and pitch)   * ''fixed, fixed VectorToAngles(fixed x, fixed y, fixed z)'' -- converts vector to a pair of angles (angle and pitch)
   * ''fixed, fixed RotateVector(fixed x, fixed y, fixed angle)'' -- returns vector rotated by angle   * ''fixed, fixed RotateVector(fixed x, fixed y, fixed angle)'' -- returns vector rotated by angle
-  * ''fixed, fixed RotateVectorSC(fixed x, fixed y, fixed sin, fixed cos)'' -- returns vector rotated by sin and cos of some angle (aka rotation vector)This is useful if you already have the sine and cosine of the rotation angle.+  * ''fixed, fixed RotateVectorCS(fixed x, fixed y, fixed rx, fixed ry)'' -- returns vector rotated by another vector's angleResult is multipled by the second vector's length. If the second vector is normalized, it's a (cos(angle), sin(angle)) vector of rotation angle.
   * ''fixed, fixed RotatePoint(fixed x, fixed y, fixed originX, fixed originY, fixed angle)'' -- returns 2D point rotated by angle around the origin.   * ''fixed, fixed RotatePoint(fixed x, fixed y, fixed originX, fixed originY, fixed angle)'' -- returns 2D point rotated by angle around the origin.
  
Line 78: Line 80:
  
 ==== Other useful functions ==== ==== Other useful functions ====
- 
-=== fract === 
- 
-''fixed fract(fixed x)'' -- returns the fractional part of X. For example, ''fract(12.345)'' returns ''0.345''. 
  
 === mod === === mod ===
new/math.txt · Last modified: 2019/04/21 01:25 by korshun