Both sides previous revisionPrevious revisionNext revision | Previous revision |
ru:math [2019/04/18 20:27] – [cmp] korshun | ru:math [2019/04/18 20:33] (current) – [RotateVectorCS] korshun |
---|
| |
Сравнивает два числа и возвращает результат: | Сравнивает два числа и возвращает результат: |
* Если A > B, возвращает''1''. | * Если A > B, возвращает ''1''. |
* Если A = B, возвращает ''0''. | * Если A = B, возвращает ''0''. |
* Если A < B, возвращает ''-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 ==== |
* 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) + ...''. | Возвращает [[wp>dot product|скалярное произведение]] двух векторов. Краткий способ записи ''FixedMul(x1, x2) + FixedMul(y1, y2) + ...''. |
| |
==== normalize ==== | ==== normalize ==== |
* 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]]. | [[wp>Normalized vector|Нормализует]] вектор и возвращает результат, используя [[multiple return values|несколько возвращаемых значений]]. |
| |
=== Example usage === | === Пример использования === |
<code> | <code> |
normalize3d(x, y, z); | normalize3d(x, y, z); |
''fixed, fixed RotateVector(fixed x, fixed y, fixed angle)'' | ''fixed, fixed RotateVector(fixed x, fixed y, fixed angle)'' |
| |
Rotates the vector by the angle and returns the result using [[multiple return values]]. | Поворачивает вектор на указанный угол и возвращает результат, используя [[multiple return values|несколько возвращаемых значений]]. |
| |
=== Example usage === | === Example usage === |
''fixed, fixed RotateVector(fixed x, fixed y, fixed cos, fixed sin)'' | ''fixed, fixed RotateVector(fixed x, fixed y, fixed cos, fixed sin)'' |
| |
A faster version of RotateVector that accepts cos(angle) and sin(angle) instead of computing them. | Более быстрая версия ''RotateVector'', которая принимает косинус и синус угла вращения, вместо того, чтобы вычислять их. |
| |
==== RotatePoint ==== | ==== RotatePoint ==== |