cos
Gives the cosine of an angle in .aim units, multiplied by 32000: 0 cos gives 32000.
Facts
- Word
cos- Family
- Advanced
- Integer stack
- pops 1, pushes 1
- What it does
- Replaces an angle in
.aimunits with its cosine multiplied by 32000 and rounded: from −32000 to 32000. - Cost
- Advanced command; debugint and debugbool are free
- Runs
- inside a gene: in the condition (cond) and in the body (start or else)
angle cos leaves the cosine of the angle multiplied by 32000 and rounded. It works just like sin: the angle in .aim units (about 1256 per turn) and the result between −32000 and 32000.
| Angle | cos |
|---|---|
| 0 (to the right) | 32000 |
| 314 (up) | 25 (almost 0: 314 is not exactly a quarter turn) |
| 628 (to the left) | −32000 |
The cosine gives the horizontal part of a movement. This bot computes how far it advances to the right for every 100 it moves toward where it is aiming, and stores it in cell 50 (negative if it aims left):
cond
start
*.aim cos 100 mult 32000 div 50 store
stopMultiply before dividing: *.aim cos 32000 div 100 mult can only give 0, −100 or 100, because the division rounds to an integer before scaling.