[ascoders] Re: 4 Punkte um Zentrum rotieren

  • From: Michael Nisi <_@xxxxxxxxxxxxxxx>
  • To: ascoders@xxxxxxxxxxxxx
  • Date: Wed, 16 Jul 2003 15:09:59 +0200

hallo nochmal,

hatte gerade noch einen moment zeit und habe mit einer Rotationsklasse begonnen.
könnte man ausbauen. ellipsen, etc.


vielleicht hat ja jemand bedarf -- oder vorschläge?

// as
#include "ASL/Math/distance.as"
#include "ASL/Math/toRadians.as"

Rotation = function(x, y, centerX, centerY)
{
this.x = x;
this.y = y;
this.centerX = centerX;
this.centerY = centerY;
this.radius = Math.distance(this.x, this.y, this.centerX, this.centerY);
}


Rotation.prototype.rotate = function()
{
        deg < 360 ? deg++ : deg = 0;
        var radians = Math.toRadians(deg);
        var x = this.radius * Math.cos(radians);
        var y = this.radius * Math.sin(radians);
        var pos_array = [x + this.centerX, y + this.centerY];
        return pos_array;
}

/* Usage

// mc1 + mc2 are on stage

foo = new Rotation(mc1._x, mc1._y, 300, 300);
doe = new Rotation(mc2._x, mc2._y, 300, 100);

this.onEnterFrame = function()
{
        var p1 = foo.rotate();
        mc1._x = p1[0];
        mc1._y = p1[1];

        var p2 = doe.rotate();
        mc2._x = p2[0];
        mc2._y = p2[1];
}
*/

gruss,
micha


MN www.michaelnisi.com
_@xxxxxxxxxxxxxxx


------------------------------------------------------
Archiv   : //www.freelists.org/archives/ascoders/
Optionen : //www.freelists.org/list/ascoders
------------------------------------------------------

Other related posts: