cosine
Details
Kode wheel segment | Math/Trigonometry |
Style | Math |
Modifiers | None |
Primarily WHEN/DO | DO |
Pre-made brains that use it | Unknown |
Math > Trigonometry> cosine
Description
This tile is a Math tile. It returns the cosine of an angle as a number in degrees. Can be used to create moving objects based on trigonometry.
Please view Trigonimos by KILLERBEENL83 (Project Spark World) for working examples of how to use trigonometry to create moving props.
Example Code
WHEN [once] DO [vectorvar:target][=][position]
…WHEN DO [vectorvar:position][=][position]
WHEN DO [numvar:per frame increment][increment by][3]
WHEN DO [vectorvar:target][y][=][vectorvar:position][y][+][sine][numvar:per frame increment]
WHEN DO [move][toward][vectorvar:target][with strafing][with flying][min distance][0]
This will move an object up and down. (Replace the sine with cosine or tangent for different up and down effects).
Change from y to x and the object moves from side to side (left to right)
Change to z and the object moves from side to side (forward to back)
Show movement on 2 axes and you get a circular orbiting motion
WHEN DO [vectorvar:target][x][=][vectorvar:position][x[+][sine][numvar:per frame increment]
WHEN DO [vectorvar:target][y][=][vectorvar:position][y][+][cosine][numvar:per frame increment]
Modifiers
None
Other Uses
You may need a basic understanding of trigonometry to get the most out of this tile. Try this website for an explanation of the math behind these tiles.