A Flash Developer Resource Site

# Thread: API lines to mouse position

1. ## API lines to mouse position

hey,
I'm trying to generate a sin wave line to the mouse position.

I can make a straight line to the mouse point and a sin wave along a set line. But I'm struggling in using the equation of the line to the mouse point so that I can make a sin wave on it.
thanks

2. why not USe your sine wav code and embed it in a movieClip that rotates towards the mouse?

3. this is a problem that haunted me for about a month before i gave up on it. i'd personally be very interested if anyone can answer the question, to something i have long sought:

is it possible to rotate a linear function?

not just for sine waves, but for parabolas, and anything else. i am pretty sure there is no algorithm to apply to anything, but perhaps many different ones depending on the type.

i asked my calculus teacher last year in class, after spending days without coming up with anything.

he said "yes", and then went on to give me an explanation that i did not understand at all (which i consequentially do not remember).

4. Yes, of course it's possible to rotate linear functions. In fact it's possible to rotate any type of function programatically. Rotating is used all the time in 3D and sometimes in 2D as well. The basic equations for rotating a point is
Code:
```Rotation Equations
x' = x * cos(theta) - y * sin(theta)
y' = y * cos(theta) + x * sin(theta)

Where x' and y' are the new points of the rotation.
And theta is the angle the point is to be rotated.```
You should do a search on "rotation" or something like that to see the derivation of the above equation. In fact, here's one link http://www.siggraph.org/education/ma...ran/2drota.htm.

To see this being applied. I made this:
You can examine the code too. Here:

5. i'll have to take some time to examine this!

#### Posting Permissions

• You may not post new threads
• You may not post replies
• You may not post attachments
• You may not edit your posts
•

 » Home » Movies » Tutorials » Submissions » Board » Links » Reviews » Feedback » Gallery » Fonts » The Lounge » Sound Loops » Sound FX » About FK » Sitemap