Click to See Complete Forum and Search --> : API lines to mouse position

Radlington

11-15-2002, 09:39 AM

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.

please can you help me

thanks

Jayhoo

11-21-2002, 11:36 AM

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

nomadx

11-28-2002, 01:58 PM

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).

muckyMuckMan

11-29-2002, 12:51 AM

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

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/materials/HyperGraph/modeling/mod_tran/2drota.htm.

To see this being applied. I made this:

http://home.earthlink.net/~funbox/math/rotatingFunctions.swf

You can examine the code too. Here:

http://home.earthlink.net/~funbox/math/rotatingFunctions.fla

nomadx

11-30-2002, 03:16 AM

:eek: i'll have to take some time to examine this!