[ascoders] Re: 4 Punkte um Zentrum rotieren

äh?

jetzt solltest du nur noch den abstand (radius), deiner punkte zum zentrum kennen.

// as
Math.distanceTo = function(x0, y0, x1, y1)
{
        var distSq = Math.pow(x0 - x1, 2) + Math.pow(y0 - y1, 2);
        return Math.sqrt(distSq);
}
//

gruss,
micha

ps. ach ja,
hier is noch ein nettes tutorial, dass sogar ich fast begriffen hätte.
>> http://www.codylindley.com/Tutorials/trigonometry/index.htm

At 10:35 16.07.2003 +0200, you wrote:
hi kiko,

trigonometrie is zwar ne üble kiste, aber irgendwie so die richtung:

// as
rotate = function(xCenter, yCenter, radius)
{
        deg < 360 ? deg++ : deg = 0;
        var radians = deg * (Math.PI / 180);
        var x = radius * Math.cos(radians);
        var y = radius * Math.sin(radians);
        var pos_array = [x + xCenter, y + yCenter];
        return pos_array;
}

this.onEnterFrame = function()
{
        p1XY_array = rotate(100, 100, 50);
        p2XY_array = rotate(100, 50, 50);
        p3XY_array = rotate(50, 100, 100);
        p4XY_array = rotate(300, 200, 40);
}

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

Other related posts: