ACSUtils Wiki

An ACS library for ZDoom-based ports

User Tools

Site Tools


ru:functions: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
ru:functions:math [2016/04/26 21:21] djskaarjru:functions:math [2016/05/02 00:37] korshun
Line 55: Line 55:
 dist(3.0, -2.0) == 5.0; dist(3.0, -2.0) == 5.0;
 </code> </code>
 +
 +==== gcf ====
 +''num gcf(num a, num b)''
 +
 +Возвращает наибольший общий делитель двух чисел. Возвращённый делитель будет отрицательным, если одно или оба данных числа отрицательны.
 +
 +**Example**
 +
 +<code>
 +gcf(18,   24)   == 6;
 +gcf(18.0, 24.0) == 6.0;
 +gcf(-18,  -24)  == -6;
 +</code>
 +
  
 ==== max ==== ==== max ====
Line 105: Line 119:
   * round -- округляет до ближайшего целого числа   * round -- округляет до ближайшего целого числа
  
-Для каждого вида округления существует две функции. Те, что начинаются с "i" возвращают целое число. Другие, без "i" возвращают значение с типом данных fixed.+Таблица округления:
  
 +<code>
 +    round(x) floor(x)  ceil(x) trunc(x)
 +----- -------- -------- -------- --------
 + 2.3                2        3        2
 + 3.8                3        4        3
 + 5.5                5        6        5
 +-2.3        -2       -3       -2       -2
 +-3.8        -4       -4       -3       -3
 +-5.5        -5       -6       -5       -5
 +</code>
 +
 +Для каждого вида округления существует две функции. Те, что начинаются с "i" возвращают целое число. Другие, без "i" возвращают значение с типом данных fixed.
 ==== ceil ==== ==== ceil ====
 ''fixed ceil(fixed x)'' ''fixed ceil(fixed x)''
Line 222: Line 248:
 Возвращает arccosec x (арккосеканс). Возвращает arccosec x (арккосеканс).
  
-===== Vectors =====+===== Векторы =====
  
 ==== dot2 ==== ==== dot2 ====
 ''fixed dot2(fixed x1, fixed y1, fixed x2, fixed y2)'' ''fixed dot2(fixed x1, fixed y1, fixed x2, fixed y2)''
  
-Returns the dot product of two 2D vectors.+Возвращает скалярное произведение двух векторов.
  
 ==== dot3 ==== ==== dot3 ====
 ''fixed dot3(fixed x1, fixed y1, fixed z1, fixed x2, fixed y2, fixed z2)'' ''fixed dot3(fixed x1, fixed y1, fixed z1, fixed x2, fixed y2, fixed z2)''
  
-Returns the dot product of two 3D vectors.+Возвращает скалярное произведение двух трехмерных векторов.
  
 ==== length2d ==== ==== length2d ====
 ''fixed length2d(fixed x, fixed y)'' ''fixed length2d(fixed x, fixed y)''
  
-Returns the length of the given 2D vectorThis is a Zandronum replacement for +Возвращает длину заданного двухмерного вектораЯвляется Zandronum-реализацией функции 
 [[zdoom>VectorLength]]. [[zdoom>VectorLength]].
 ==== length2d2 ==== ==== length2d2 ====
 ''fixed length2d2(int x, int y)'' ''fixed length2d2(int x, int y)''
  
-Returns the **squared** length of the given 2D vector.+Возвращает **квадрат** длины данного двухмерного вектора.
  
 ==== length3d ==== ==== length3d ====
 ''fixed length3d(fixed x, fixed y, fixed z)'' ''fixed length3d(fixed x, fixed y, fixed z)''
  
-Returns the length of the given 3D vector.+Возвращает длину заданного трехмерного вектора.
  
 ==== length3d2 ==== ==== length3d2 ====
 ''fixed length3d2(int x, int y, int z)'' ''fixed length3d2(int x, int y, int z)''
  
-Returns the **squared** length of the given 3D vector.+Возвращает **квадрат** длинны заданного трехмерного вектора.
  
 ==== normalize2d ==== ==== normalize2d ====
 ''fixed, fixed normalize2d(fixed x, fixed y)'' ''fixed, fixed normalize2d(fixed x, fixed y)''
  
-Normalizes the given 2D vector and returns the result.+Нормализует заданный двухмерный вектор.
  
-[[:mulretval|This function returns multiple values.]]+[[..mulretval|Эта функция возвращает несколько значений.]]
  
 ==== normalize3d ==== ==== normalize3d ====
 ''fixed, fixed, fixed normalize3d(fixed x, fixed y, fixed z)'' ''fixed, fixed, fixed normalize3d(fixed x, fixed y, fixed z)''
  
-Normalizes the given 3D vector and returns the result.+Нормализует заданный трехмерный вектор.
  
-[[:mulretval|This function returns multiple values.]]+[[..mulretval|Эта функция возвращает несколько значений.]]
  
 ==== RotatePoint ==== ==== RotatePoint ====
 ''fixed, fixed RotatePoint(fixed x, fixed y, fixed originX, fixed originY, angle angle)'' ''fixed, fixed RotatePoint(fixed x, fixed y, fixed originX, fixed originY, angle angle)''
  
-Rotates the given point (x; y) around the given origin by the given angle and returns the resulting coordinates of the point.+Вращает заданную точку (x; y) вокруг заданной точки вращения на указанный угол и возвращает результирующие координаты точки.
  
-[[:mulretval|This function returns multiple values.]]+[[..mulretval|Эта функция возвращает несколько значений.]]
  
 ==== RotateVector ==== ==== RotateVector ====
 ''fixed, fixed RotateVector(fixed x, fixed y, angle angle)'' ''fixed, fixed RotateVector(fixed x, fixed y, angle angle)''
  
-Rotates the vector by the given angle and returns its new coordinates.+Поворачивает вектор на указанный угол и возвращает его новые координаты.
  
-[[:mulretval|This function returns multiple values.]]+[[..mulretval|Эта функция возвращает несколько значений.]]
  
-**Example**+**Пример**
  
 <code> <code>
Line 293: Line 319:
 ''angle, angle VectorToAngles(fixed x, fixed y, fixed z)'' ''angle, angle VectorToAngles(fixed x, fixed y, fixed z)''
  
-Converts a vector to a pair of angles (yaw and pitchthat point to the same direction.+Конвертирует вектор в пару углов (рысканье и тангаж (поворот и наклон)), которые направлены туда же.
  
-[[:mulretval|This function returns multiple values.]]+[[..mulretval|Эта функция возвращает несколько значений.]]
  
-**Example**+**Пример**
  
 <code> <code>
-// Make the player look along the vector+// Заставляет игрока смотреть по вектору
 VectorToAngles(1.0, 2.0, 3.0); VectorToAngles(1.0, 2.0, 3.0);
 int angle = r1; int angle = r1;
ru/functions/math.txt · Last modified: 2016/05/05 00:53 by djskaarj