### Author Topic: Quaternion Based 6DOF Camera Lib  (Read 17845 times)

#### Hemlos

• To boldy go where no pixel has gone before!
• Global Moderator
• Prof. Inline
• Posts: 1645
• Particle Hawk
##### Re: Quaternion Based 6DOF Camera Lib
« Reply #15 on: 2009-Nov-25 »
*drum roll*

rotation = 57.2957 * Angle // which is:  1* radian * Angle..doesnt make sense, but neither do quats

Seems to work, tested it for a few minutes.

« Last Edit: 2009-Nov-30 by Hemlos »
Volume_of_Earth(km^3) = 4/3*3.14*POW(6371.392896,3)

#### djtoon

• Dr. Type
• Posts: 290
##### Re: Quaternion Based 6DOF Camera Lib
« Reply #16 on: 2011-Feb-14 »
where do you set the looka target? i cant figure it out

#### djtoon

• Dr. Type
• Posts: 290
##### Re: Quaternion Based 6DOF Camera Lib
« Reply #17 on: 2011-Feb-14 »
whne i move the mouse up and down it dosent look up and down? is there a fix ?

#### djtoon

• Dr. Type
• Posts: 290
##### Re: Quaternion Based 6DOF Camera Lib
« Reply #18 on: 2011-Feb-15 »
An error plz help !

im useing this lib and when i fly far enofe and rotate the mouse the camera seems to start to shake

any solve for this? kinda dont understand vectors

#### Hemlos

• To boldy go where no pixel has gone before!
• Global Moderator
• Prof. Inline
• Posts: 1645
• Particle Hawk
##### Re: Quaternion Based 6DOF Camera Lib
« Reply #19 on: 2011-Feb-16 »
You almost certainly must have a solid understanding of vectors before attempting this type of math.

1. the lookat target is the forward coordinate.
2. why it wont look up and down, is likely a code error on your part, show a sample here if you still have trouble.
3. The camera is shaking because you moved way too far from 0,0,0. You will need to limit the size of your world....scale the world and the speed down...alot.
Edit: world size is -32000.0 to 32000.0
« Last Edit: 2011-Feb-16 by Hemlos »
Volume_of_Earth(km^3) = 4/3*3.14*POW(6371.392896,3)

#### kanonet

• Prof. Inline
• Posts: 1142
##### Re: Quaternion Based 6DOF Camera Lib
« Reply #20 on: 2012-Jun-18 »
Camera shake happens because of the way how floats are represented in binary, check Wikipedia. To avoid this, you need to keep your camera at (0,0,0) and move the rest you your scene, just like Hemlos said. But keep in mind, that this only works, if you really do not move the camera, but the world. If you just try to fake it, by drawing you object wit objectpos-camerapos, than you will still have shakes!
The 3D ES do not do this, so it shakes too. To get rid of the shakes it would need a complete rewrite of some parts. Im thinking about implementing this in my smaller libESL, but this would be a bit work and have some side effects, so i have not done it yet.
Lenovo Thinkpad T430u: Intel i5-3317U, 8GB DDR3, NVidia GeForce 620M, Micron RealSSD C400 @Win7 x64

#### Hemlos

• To boldy go where no pixel has gone before!
• Global Moderator
• Prof. Inline
• Posts: 1645
• Particle Hawk
##### Re: Quaternion Based 6DOF Camera Lib
« Reply #21 on: 2015-Aug-30 »
Quaternions are obsolete math, due to modernized vector math.
Not trying to flame, but ive been learning a bit of math lately and have been checking on a few things around the forums too.
This reply might solve more than one issue on multiple threads...so ill just say it here in the sticky one...

I think i found a slight issue in the math and might know how to fix some issues.
Make it known that this same problem is on multiple threads in multiple libraries.
Sidenote: OTHER libs, Magnitude is not correct, this  quat lib one is fine.

Here, In the normalize function....the output is always less than one...almost half even. eg ||V|| = <1
Normalizing, mathematically speaking(for everything else to function properly), the math requires a normalized vector to have the magnitude of 1. eg. ||V|| = 1

unit vector = vector * ( 1 / mag )

as opposed to

unit vector = vector * mag

as it were.

That said, you can make a scalar function too....instead of 1 / mag make it Value# / mag, after you normalize ||V|| = 1
This will set the absolute size of the vector, no need to scale it up of divide it down.
However, those 2 scaling functions(scalar divide and multiply) are also possible, as well.....though this math is obsolete.
At least update the normalize function, so we got it right.
Love ya Ian, and thanks for such an awesome lib!

PS. if anyone has vector math libs( a couple of you), check your magnitudes, and normalizing again...itll fix crashes, divisions of zero, collapsing numbers, the need for a "solution", and no need for tolerances of numbers, nor rounding the precision,  etc etc etc!

« Last Edit: 2015-Aug-30 by Hemlos »
Volume_of_Earth(km^3) = 4/3*3.14*POW(6371.392896,3)

#### bigsofty

• Community Developer
• Prof. Inline
• Posts: 2697
##### Re: Quaternion Based 6DOF Camera Lib
« Reply #22 on: 2015-Aug-30 »

TBH I totally forgot about this. Quaternions are still relevant, esp. for interpolation of spherical angles but yes most people just use them just for that and do the rest of the stuff in vectors or matrices and only converting from and to a quat as needed.

Cheers,

Ian.

“It is practically impossible to teach good programming style to students that have had prior exposure to BASIC.  As potential programmers, they are mentally mutilated beyond hope of regeneration.”
(E. W. Dijkstra)

#### JohnnyB

• Mc. Print
• Posts: 37
##### Re: Quaternion Based 6DOF Camera Lib
« Reply #23 on: 2020-Jul-17 »
Is Strafe, rise and advance even working here? Whatever I use, my camera "advances" only.?!

#### Hemlos

• To boldy go where no pixel has gone before!
• Global Moderator
• Prof. Inline
• Posts: 1645
• Particle Hawk
##### Re: Quaternion Based 6DOF Camera Lib
« Reply #24 on: 2020-Jul-29 »
It is 6 degrees of freedom.
Pretty sure to add those ideas, should be easy to make small functions.
Im at work rn, i will look into this later.
Volume_of_Earth(km^3) = 4/3*3.14*POW(6371.392896,3)

#### erico

• Community Developer
• Prof. Inline
• Posts: 4347
##### Re: Quaternion Based 6DOF Camera Lib
« Reply #25 on: 2020-Jul-30 »
Good to hear from you Hemlos! Long time no see! Up to something in code these days?

#### Hemlos

• To boldy go where no pixel has gone before!
• Global Moderator
• Prof. Inline
• Posts: 1645
• Particle Hawk
##### Re: Quaternion Based 6DOF Camera Lib
« Reply #26 on: 2020-Jul-30 »
Is Strafe, rise and advance even working here? Whatever I use, my camera "advances" only.?!

@JohnnyB
Pretty certain all the math is working.
Perhaps i can help you to get this function operating as expected?
Will you create an example to show how it isn't working?

@Erico
Hi Erico, glad to hear from you too!
Nothing in specific for coding, just poking around once in a while, i still enjoy helping people with their codes, and math.
Volume_of_Earth(km^3) = 4/3*3.14*POW(6371.392896,3)