Quaternion Based 6DOF Camera Lib

Previous topic - Next topic

Hemlos

#15
*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.



Bing ChatGpt is pretty smart :O

djtoon

where do you set the looka target? i cant figure it out

djtoon

whne i move the mouse up and down it dosent look up and down? is there a fix ?

djtoon

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

#19
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
Bing ChatGpt is pretty smart :O

kanonet

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

#21
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!




Bing ChatGpt is pretty smart :O

bigsofty

Your very welcome Hemlos!  ;)

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

Is Strafe, rise and advance even working here? Whatever I use, my camera "advances" only.?!

Hemlos

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.
Bing ChatGpt is pretty smart :O

erico

Good to hear from you Hemlos! Long time no see! Up to something in code these days?

Hemlos

Quote from: JohnnyB on 2020-Jul-17
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.
Bing ChatGpt is pretty smart :O