# X axis rotation

**URL:** <https://forum.kirupa.com/t/x-axis-rotation/179178>\
**Category:** Uncategorized\
**Created:** [February 17, 2006, 9:56am UTC](https://forum.kirupa.com/t/x-axis-rotation/179178 "2006-02-17T09:56:09Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![Sinus1](https://avatars.discourse-cdn.com/v4/letter/s/f14d63/32.png) [@Sinus1](https://forum.kirupa.com/u/Sinus1)\
**Post date:** [February 17, 2006, 9:56am UTC](https://forum.kirupa.com/t/x-axis-rotation/179178/1 "2006-02-17T09:56:09Z")

</div>

i want to rotate square around x axis. this is the code for rotating 1 point(draw a circle or something like that and copy code):

```auto

var centar:Object = new Object();
centar.x = 250;
centar.y = 250;
var angle:Number = 0;
var radius:Number = 50;
var speed:Number = 4;
var size:Number = 100;
function rotationX() {
    this._y = Math.sin(angle*Math.PI/180)*radius+centar.y;
    //if size equals radius then sizes are the same
    z = Math.cos(angle*Math.PI/180)*radius+size;
    this._xscale = this._yscale=z;
    angle += speed;
}
_root.MC.onEnterFrame = rotationX;

```

but i want to rotate square.for that i need 4 points(actually angles because i`m using sin and cos), and then i need to rotate each point individualy and connect the points. but i doesn`t work. if anybody knows the solution please tell. any other ways of rotating a square(around x axis of course)are also welcome  
here is the code i wrote:

```auto

//vars
var point:Array = new Array();
var speed:Number = 4;
var radius:Number = 100;
var centar:Object = new Object();
centar.x = 250;
centar.y = 250;
_root.createEmptyMovieClip("square", 1);
_root.square.lineStyle(2, 0xff0000, 100);
//square points, they are actually angels
point = [135, 45, 315, 215];
function rotation() {
    for (n=0; n<=point.length; n++) {
        y = Math.sin(point[n]*Math.PI/180)*radius+centar.y;
        z = Math.cos(point[n]*Math.PI/180)*radius+size;
        this._xscale = this._yscale=z;
        point[n] += speed;
        if (n == 0) {
            this.moveTo(z, y);
        } else {
            this.lineTo(z, y);
        }
        point[n] += speed;
    }
}
_root.square.onEnterFrame = rotation;

```
