A Flash Developer Resource Site

Results 1 to 5 of 5

Thread: API lines to mouse position

  1. #1
    Member
    Join Date
    Feb 2002
    Posts
    64

    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.
    please can you help me
    thanks

  2. #2
    Senior Member
    Join Date
    Apr 2001
    Location
    UK
    Posts
    493
    why not USe your sine wav code and embed it in a movieClip that rotates towards the mouse?

  3. #3
    desert nomad
    Join Date
    Aug 2001
    Posts
    63
    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).
    -nomadx-

  4. #4
    Junior Member
    Join Date
    Jul 2002
    Posts
    25
    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:
    http://home.earthlink.net/~funbox/ma...gFunctions.swf
    You can examine the code too. Here:
    http://home.earthlink.net/~funbox/ma...gFunctions.fla

  5. #5
    desert nomad
    Join Date
    Aug 2001
    Posts
    63
    i'll have to take some time to examine this!
    -nomadx-

Posting Permissions

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




Click Here to Expand Forum to Full Width

HTML5 Development Center