Next revision | Previous revisionNext revisionBoth sides next revision |
ru:math [2019/04/18 23:21] – created korshun | ru:math [2019/04/18 23:29] – [VectorLength3D] korshun |
---|
''int sgn(int x)'' | ''int sgn(int x)'' |
| |
Returns the sign of X: | Возвращает знак X: |
* If X is positive, returns ''1''. | * Если X положителен, возвращает ''1''. |
* If X is negative, returns ''-1''. | * Если X отрицателен, возвращает ''-1''. |
* If X is zero, returns ''0''. | * Если X -- ноль, возвращает ''0''. |
| |
=== Example usage === | === Пример использования === |
<code> | <code> |
// Make X velocity 15.0, but with the same sign as foo | // Задаём скорость по X равную 15.0 |
| // но с таким же знаком, что и у foo |
int xvel = sgn(foo) * 15.0; | int xvel = sgn(foo) * 15.0; |
</code> | </code> |
''num min(num a, num b)'' | ''num min(num a, num b)'' |
| |
Returns the lesser of two numbers. | Возвращает меньшее из двух чисел. |
| |
==== max ==== | ==== max ==== |
''num max(num a, num b)'' | ''num max(num a, num b)'' |
| |
Returns the greater of two numbers. | Возвращает большее из двух чисел. |
| |
==== clamp ==== | ==== clamp ==== |
''num clamp(num x, num mininum, num maximum)'' | ''num clamp(num x, num минимум, num максимум)'' |
| |
Limits X to the specified range: | Ограничивает X в указанном диапазоне: |
* If X < mininum, returns the minumum. | * Если X меньше минимума, возвращает минимум. |
* If X is between mininum and maximum, returns X. | * Если X между минимумом и максимумом, возвращает X. |
* If X > maximum, returns the maximum. | * Если X больше максимума, возвращает максимум. |
| |
==== cmp ==== | ==== cmp ==== |
''int cmp(num a, num b)'' | ''int cmp(num a, num b)'' |
| |
Compares two numbers and returns the result: | Сравнивает два числа и возвращает результат: |
* If A > B, returns ''1''. | * Если A > B, возвращает ''1''. |
* If A = B, returns ''0''. | * Если A = B, возвращает ''0''. |
* If A < B, returns ''-1''. | * Если A < B, возвращает ''-1''. |
| |
| |
===== Trigonometry ===== | ===== Тригонометрия ===== |
| |
ACSUtils provides a full set of trigonometric functions: | ACSUtils предоставляет полный набор тригонометрических функций: |
| |
* [[zdoom>sin]] is already built into ZDoom. | * [[zdoom>sin]] уже встроен в ZDoom. |
* [[zdoom>cos]] is already built into ZDoom. | * [[zdoom>cos]] уже встроен в ZDoom. |
* ''fixed tan(fixed angle)'' -- implemented as ''FixedDiv(sin(x), cos(x))''. | * ''fixed tan(fixed angle)'' -- реализован как ''FixedDiv(sin(x), cos(x))''. |
* ''fixed cot(fixed angle)'' -- implemented as ''FixedDiv(cos(x), sin(x))''. | * ''fixed cot(fixed angle)'' -- реализован как ''FixedDiv(cos(x), sin(x))''. |
* ''fixed sec(fixed angle)'' -- implemented as ''FixedDiv(1.0, sin(x))''. | * ''fixed sec(fixed angle)'' -- реализован как ''FixedDiv(1.0, sin(x))''. |
* ''fixed cosec(fixed angle)'' -- implemented as ''FixedDiv(1.0, cos(x))''. | * ''fixed cosec(fixed angle)'' -- реализован как ''FixedDiv(1.0, cos(x))''. |
| |
Inverse trigonometric functions: | Inverse trigonometric functions: |
* ''fixed atan(fixed x)'' -- implemented as ''[[zdoom>VectorAngle]](1.0, x)''. | * ''fixed atan(fixed x)'' -- реализован как ''[[zdoom>VectorAngle]](1.0, x)''. |
* ''fixed acot(fixed x)'' -- implemented as ''0.25 - atan(x)''. | * ''fixed acot(fixed x)'' -- реализован как ''0.25 - atan(x)''. |
* ''fixed asin(fixed x)'' -- implemented as ''atan(FixedDiv(x, FixedSqrt(1.0 - FixedMul(x, x))))''. | * ''fixed asin(fixed x)'' -- реализован как ''atan(FixedDiv(x, FixedSqrt(1.0 - FixedMul(x, x))))''. |
* ''fixed acos(fixed x)'' -- implemented as ''ang(2 * atan(FixedSqrt(FixedDiv(1.0 - x, 1.0 + x))))''. | * ''fixed acos(fixed x)'' -- реализован как ''ang(2 * atan(FixedSqrt(FixedDiv(1.0 - x, 1.0 + x))))''. |
* ''fixed asec(fixed x)'' -- implemented as ''acos(FixedDiv(1.0, x))''. | * ''fixed asec(fixed x)'' -- реализован как ''acos(FixedDiv(1.0, x))''. |
* ''fixed acosec(fixed x)'' -- implemented as ''asin(FixedDiv(1.0, x))''. | * ''fixed acosec(fixed x)'' -- реализован как ''asin(FixedDiv(1.0, x))''. |
| |
| |
''fixed VectorLength3D(fixed x, fixed y, fixed z)'' | ''fixed VectorLength3D(fixed x, fixed y, fixed z)'' |
| |
A 3D version of [[zdoom>VectorLength]]. Returns the length of the 3D vector. | Трёхмерная версия [[zdoom>VectorLength]]. Возвращает длину трёхмерного вектора. |
| |
==== dot ==== | ==== dot ==== |