How can I rotate an object around its local Y axis rather than the global Y axis using actionscript-3? - actionscript-3

I have a flat object, eventually it will be a circle, but for now I just have a 2d square on the stage. I tip it back 75 degrees, and then rotate it around the y axis.
I have this code which has the object rotating, but it rotates around the global Y axis. But I want it to rotate around it's own Y axis which is tipped 15 degrees from vertical.
box_mc.rotationY=0;
box_mc.rotationX=-75;
addEventListener(Event.ENTER_FRAME, onYRotate);
function onYRotate(e:Event):void{
box_mc.rotationY+=2;
}
Can someone help me change my code so it rotates on its own Y axis?

Related

Why is the y axis inverted in the HTML DOM and in SVG?

The y axis instead of going upwards, goes downwards, whilst the x axis has the normal sense from left to right. Why?
It is one of the most annoying obstacles when doing the graphic part of a website because the geometry has to be recalculated, as the usual calculation as in the cartesian plane will be wrong. So, why does this happen? Is there a specific reason? Did they not notice that they were betraying traditional mathematics?

libgdx - moving a KinematicBody in a circular path

I'm trying to achieve a circular movement of KinematicBody around another body. I tryied this function:
public void updateCircular(float speed, Vector2 center){
Vector2 radius = center.cpy().sub(this.body.getPosition());
Vector2 force = radius.rotate90(1).nor().scl(speed);
this.body.setLinearVelocity(force.x, force.y);
}
But it's work fine only for DynamicBody connected with DistanceJoint. Changing body type to KinematicBody changes the behavior of the body. The body ceases to move in a circular orbit and passes to a spiral motion (Constantly increases the radius as if the centrifugal force is consumed by it). I need as much as possible a perfect circular motion. How can I achieve this?
Sorry for bad English.
The easiest way, in my opinion, is to just create a distance joint between some static body and your kinematics body. This way the body stays a certain radius from the other(creates a circle) and then you could just use set velocity to change its speed.
If the rotating body has to be a kinematic body, then to get uniform circular motion with fixed radius, we can add an extra velocity component perpendicular to the velocity vector. We can calculate the difference in distance of rotating body with the center. The velocity can be calculated by dividing this distance by time step per frame. This will move the body towards or outwards from center whenever rotating body is going outwards or coming inwards to the center. Add the below velocity to your calculation.
float dst=rotatingBody.getPosition().dst(pivotBody.getPosition());
//radius is the distance of center to the rotating body
float delta=dst-radius ;
//dt is time step per frame
float c2=delta/(dt);
Vector2 centripetalVector=new Vector2(pivotBody.getPosition()).sub(rotatingBody.getPosition()).nor().scl(c2);
I have written a tutorial on how to achieve a rotating shield around a moving dynamic body as center in libgdx. It can be found here along with the full code.

Rotating a cube about its x axis

I am done designing a 3-D cube in pure html.
The cube is rotating fine about its y and z axis, but when I try to rotate it about its axis it behaves a little strange.
Instead of rotating about its new rotated x axis it just rotates about the original X axis.
You can see the code I've provided and suggest necessary amends.
Here is the CODE PEN link for you to tinker:
<a href="http://codepen.io/deviljinkazama/pen/KzoxEL">Link</a>

How to draw colored circle with stroke in libgdx?

I found that I can do it using Pixmap:
void drawCircle(int x, int y, int radius)
Draws a circle outline with the center at x,y and a radius using the current color and stroke width.
The problem that their isn't a function that can set stroke width.
Is their any other way to do it?
The easiest way would be to draw one before, with a bigger radius.
The stroke width would be the difference between radius2 and radius1.

Invert Y axis on coordinate plane?

On a coordinate plane, what is the equation to flip the image upside down?
Could it be as simple as y = -y?