# Rotate a sine wave to an arbitrary angle?

**URL:** <https://forum.kirupa.com/t/rotate-a-sine-wave-to-an-arbitrary-angle/324161>\
**Category:** flash\
**Created:** [August 5, 2011, 2:41pm UTC](https://forum.kirupa.com/t/rotate-a-sine-wave-to-an-arbitrary-angle/324161 "2011-08-05T14:41:43Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![Stickeroo](https://avatars.discourse-cdn.com/v4/letter/s/e19adc/32.png) [@Stickeroo](https://forum.kirupa.com/u/Stickeroo)\
**Post date:** [August 5, 2011, 2:41pm UTC](https://forum.kirupa.com/t/rotate-a-sine-wave-to-an-arbitrary-angle/324161/1 "2011-08-05T14:41:43Z")

</div>

That might not be what I really mean, but I’m not sure how else to describe it!

I want to be able to take a general sine wave y=Math.sin(x) and rotate it around some other angle, so instead of going strictly left-to-right, I’d like to go from, say, the top left corner toward the “center,” or from the bottom right to the center, or any other arbitrary angle. Like this:

I want to be able to use that wave as a “path” for enemies in a game, but I cannot seem to wrap my head around it. I’ve tried matrix transformations, but I was missing something there, too, because the origin was wrong…

I’d appreciate any help! Thanks!
