1 Reply Latest reply on May 18, 2006 5:57 PM by Newsgroup_User

    Getting x and y from angle and radius

    sunlis
      Does anybody know how I could get the x and y coordinates and a dot, controllable by the mouse. The dot rotates around the center of the stage.
      I have been working on it, but I can't find out a way to it.
      After days, I'm finally breaking down and asking around.
      So, if anyone knows how I would go about doing this, or has any links, let me know.
      By the way, it's not the rotation or radius I'm asking how to do. I can do that.

      Sean
        • 1. Re: Getting x and y from angle and radius
          Level 7
          sunlis,

          > Does anybody know how I could get the x and y
          > coordinates and a dot, controllable by the mouse.

          Sure. You'll want the sine and cosine trig functions of the Math class.

          > By the way, it's not the rotation or radius I'm
          > asking how to do. I can do that.

          Okay, if you have rotation (your angle), make sure to translate that
          into radians. If you have your radius, then you have both key parameters.

          dot._x = xcenter + Math.cos(angle) * radius;
          dot._y = ycenter - Math.sin(angle) * radius;

          xcenter is the horizontal component of an arbitrary point, such as
          Stage.width / 2. ycenter is the other component, such as Stage.height / 2.


          David
          stiller (at) quip (dot) net
          Dev essays: http://www.quip.net/blog/
          "Luck is the residue of good design."