# Issue with flycam rotation to -1.0

hello all,

[java]protected void rotateCamera2(float value, Vector3f axis){
if (dragToRotate){
if (canRotate){
// value = -value;
}else{
return;
}
}

``````    Matrix3f mat = new Matrix3f();
mat.fromAngleNormalAxis(rotationSpeed * value, axis);

Vector3f up = cam.getUp();
Vector3f left = cam.getLeft();
Vector3f dir = cam.getDirection();

mat.mult(up, up);
mat.mult(left, left);
mat.mult(dir, dir);

Quaternion q = new Quaternion();
q.fromAxes(left, up, dir);
q.normalizeLocal();

high = dir.y;
if(high &lt; 0.4 &amp;&amp; high &gt; -0.9)
cam.setAxes(q);
}
``````

[/java]

This is my code with restraints at the bottom to not rotate higher than 0.4 or lower(currently) than -0.9.

Now I essentially wanted it to max out at looking straight down, but -0.9 works.

when I do -1.0 there are no restraints, it can rotate around all the way around, which shouldn’t be?

I’m curious why this is,

Thanks,

~KZ

Because this is constraining the vector essentially. Looking straight down is (0, -1.0, 0)… all direction vectors are always less than 1.0.

Put another way, your value of “high” is actually the sine of the pitch.

Just an aside, this code goes through a LOT of trouble just to rotate the camera. Did you see some example that does this? Or did you figure it out on your own? I’m curious if there is some wrong example somewhere.

Oh, hahah… FlyByCamera does it. This is one crazy class.

@pspeed said: Because this is constraining the vector essentially. Looking straight down is (0, -1.0, 0)... all direction vectors are always less than 1.0.

Put another way, your value of “high” is actually the sine of the pitch.

Just an aside, this code goes through a LOT of trouble just to rotate the camera. Did you see some example that does this? Or did you figure it out on your own? I’m curious if there is some wrong example somewhere.

Oh, hahah… FlyByCamera does it. This is one crazy class.

so it being 0 does something,but +/-1 wont do anything essentially?

and yes this is FlyByCam’s code :D, lots craziness in it indeed:p. I wonder about half of the stuff it’s doing definitely not my code :p.

You make me laugh when you say “is this your code, or is there a wrong example somewhere…” then “Oh FlyByCamera…” no big deal :P.

@KonradZuse said: so it being 0 does something,but +/-1 wont do anything essentially?

and yes this is FlyByCam’s code :D, lots craziness in it indeed:p. I wonder about half of the stuff it’s doing definitely not my code :p.

You make me laugh when you say “is this your code, or is there a wrong example somewhere…” then “Oh FlyByCamera…” no big deal :P.

Yeah, FlyByCam does things the hard way for some reason… it’s also the more expensive way. I have trouble fixing a demo camera, though. Nearly 100% of games will have to implement their own camera so fixing this one doesn’t help much.

Regarding the question, maybe a picture helps: