# [SOLVED] Not again... can't rotate Vector

Ahem… I have a textured quad shown below as A. I want to rotate it so that it looks like B or C. So I have this:

``````Vector3f dir = new Vector3f((float) Math.cos(angle), (float) Math.sin(angle), 0);
``````

and then:

``````float rot=dir.x;
node.setLocalRotation(new Quaternion().fromAngles(0, 0, (float)Math.acos(rot)));
``````

This works for getting B, but since C is negative I don’t get the desired result… I’ve tried with Quatertion.lookAt, but still wasn’t able to make sense of what I got…
Thanks for you patience Why turn an angle into a vector just to turn it back into an angle?

node.setLocalRotation(new Quaternion().fromAngles(0, 0, angle));

Else you will have to use atan2() but it’s really strange to find yourself using any of the atan() type methods.

1 Like

Because entity system Now I have this:

``````public class Direction implements EntityComponent {
private final Vector3f direction;
private final float angle;
private Quaternion facing;

public Direction( float angle ) {
this.direction = new Vector3f((float) Math.cos(angle), (float) Math.sin(angle), 0);
this.angle=angle;
}

public Vector3f getDirection() {
return direction;
}

public float getAngle() {
return angle;
}

@Override
public String toString() {
return "Direction[" + direction + "]";
}
}
``````

Sort of redundant, but at least I have the information on both forms when I need them.

Yeah, well… Vector3f direction seems completely unnecessary.

Well why not using this (I don’t know which ones right )

``````Quaternion q;
Vector3f v = q.mult(Vector3f.UNIT_Z);
``````

Or was it

``````Vector3f v = new Vector3f();
v = Vector3f.UNIT_Z.mult(q);
``````

Note that it does make a difference, I only can’t remember Also note that you need to transform jme’s 3d coords to 2d, ie:

``````float x = v.x;
float y = v.z;
``````