-
Notifications
You must be signed in to change notification settings - Fork 0
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Quaternions #27
Comments
I found this about quats |
It have also some interesting articles. It will be no difficult to implement |
Right when I get to Slerp ordinary Slerp works fine.
Again no one has used this in Scene, another for the bin? I will check in as is, so you can play with the behaviour to see if I am 'doing it wrong' |
Ok maybe you can scale with quat, something I had not seen before
|
Many things don't work here with Quaternion :
What the change you did exactly ? Normalize and mul worked before |
Are you normalising 3 element or 4 with Quats you have to normalise all four not just the inaginary vector
this result would point to that, Quats are 4 dimensional beasts so are normalised as such. It is not a vector + flag or Vector + length. So if you copied Vector normalise then this would be the cause. |
I' m doing nothing just ran the test |
I found article in french http://mecaspa.cannes-aero-patrimoine.net/SCAO/QUATERN/complements/som_quat.htm#note_calcul_perso but don't understand well all yet. I need little more time |
Ok I just looked at the win64 SSE and the above is exactly the reason for most of the errors. |
by comment |
Now onto the gimbal lock code in Euler Create. What I think has happened here is the original code in the sub function was the first written, someone read about gimbal lock and decided to 'protect' original code with some code found somewhere, not realising that the original code was gimbal lock safe as it creates 3 quats and returns the product of the three, This is inherently safe from gimbal lock as it is combining quats not euler angles. |
maybe this
This cured a lot of ills in the pascal. So tests reflect what it naturally broke. Try swapping A and B registers |
In which function ???? i'm lost, normailze ? or Mul |
I have checked in the fixes |
Normalize could do with reworking and simplifying but it does work |
Ok, i'll compare with old code, i don't see what you're doing. So now only 1 fail :
|
That one is to be expected that is the routine that makes no sense to me. |
Thinking ahead a bit while I finish Quat and Matrix what functionallity are we missing from fustrum. That I think, is the last piece of the jigsaw to a simple software world line render. We have plane and the ability to test for in plane. Do we need a create from Quat/EyeVector or similar. |
Yes, you're right missing some functions, but not many. For a 3D word render. After some learning somethings about quaternion. I'm thinking it will good if we'll add RotateWithQuaternion functions in TGLZVectorHelper. From what I read, we would have several advantages to using quaternions in rotations rather than matrices |
The one issue I had withquat was needing to scale. Without quats that is a lot of Mat manipulation for each item |
I found this for unity (it's in french) https://www.youtube.com/watch?v=EWQCsjp3NvY it describe very well how Unity work with quaternion and why. |
I'm trying to fix slerpSpin
Like we can see the result is in W |
Ok by accessing var in with aq4.Realpart instead aq4.Z get :
|
After some mino changes, now i've :
Have you swap components results in functionnal test ? or it is something wrong |
After some minors change, the problems come always from the Z
Now the result don't match. It's a pain |
if i normailze the result i get :
|
sorry just back from shopping, tests may may not be correct as I had no idea if spin was 180 or 360 thats what I was trying to determine when nothing worked in a sane manner |
now if i negate result.z : ( and i change slerpsingle to SlerpSpin, for not to be confused) -"SlerpSpin:Sub7 Z failed (ImagePart.X: 0,00000 ,ImagePart.Y: 0,00000 ,ImagePart.Z: -0,17365 , RealPart.W: -0,98481)" expected: <0,766> but was: <-0,1736> I don't understand why result is false at this stage this is the change i've made for testing :
|
No, problems Peter :) 👍 |
Ok changed
|
(720 - 90) / 2 = 315 so perhaps we are doubling the spin rotation and negating the initial rotation. this is still from the unchanged code you posted, will plug some more numbers in to test |
Ok that is it from changing 90 to 20 we get 720 - 20 = 700 : 700 / 2 = 350 and I get a euler answer of -10 |
so need to half spin value and negate initial somehow. |
Quat to Mat4 done and checked in. Now for Mat4 to Quat. |
Always don't understand SlerpSpin. I don't understand "(720 - 90) / 2 = 315" = ((360*2) - 90) / 2 Why 360 our destination is at 90° I don't understand slerpSpin in the same maner like you. why in
RadiansToDeg(Omega) = 45 and not 90 like the initial aqt2.Create(90,ZVector); at firts i'm understading SlerpSpin like this :
so normally we have made a rotation of 90° = (90° * 2) * 0.5 or something escape me And for Matrix test
|
if this is the case an Angular lerp is needed here |
Ok by making like i think SlerpSpin is ok First change :
after function TGLZQuaternion.Slerp(const QEnd: TGLZQuaternion; Spin: Integer; t: Single): TGLZQuaternion; and for finish :
This is the behaviour you want ? |
Ok I just did the last two parts and it works, you have changed the spin to mean rotation * spin which is fine by me. previous code looked like it was adding some multiple of pi.
This has no effect, with it or without it. Best not putting it in as it may make us add some asembler code where not required. |
Fixed |
thinking about it need to test for large number of 'spirals' and see what the limits are, if any. |
If it not working just go on Bin, not really necessary. If you see others functions like this don't hesitate to trash it |
I see the problem, but I do not understand what you want to talk about and about what. Can you be more precise |
None of the grids I have come across in GLScene has single tri strip for a rectangular mesh. And I was looking for such an algo myself but all I ever found before were algos that created degenerate tris at the end of rows. With those grid patterns I now see a way of creating a tri strip with no degenerate triangles in it. |
Ok i understand now it's not a problem like i've supposed. We can use this scheme for terrain rendering (not implemented for terrain, in glscene I believe) i'm already try this thrue an article long time ago. never finished. This scheme can also be using with tesselate geometry shader if i'm remember |
I presume you have seen this, this looks like the 'bible' on shuffles as it was written by Peter Cordes, a name that comes up a lot when looking at SSE et al. |
Ok I have just applied those to quat nornalise. It's not the only optimisation I'm afraid so no test on the code there yet. But I have taken Quat.Normalize from a SF of 1.9 to a SF of 2.88. |
best test for the article above will be Magnitude of Quat. |
Ok I have tested Magnitude. Here are the speed up results from that testing
This is for SSE 3 |
Yes but not same thread :) if you look in the win64 sse you can see some Horizontal Sum test surround by {$ifdef TEST}..{$endif} for me the most performant with hsum is (sse3)
|
the code i've wrote above is for Magnitude, strangely with normalize this :
is better |
I made some little test also with TGLZVector4f Length and normalize In Normalize
is better (around 4%) in length :
is better (around 2%) and with this :
is better around 1% |
lots of warnings about using pshufd when processing packed single, does not affect all processors but those it does it hurts.
|
One other item that came up in that was using ss where possible so it does not use the other gates. I suppose when you are multithreading and hammering all processors that the heat generated forces the CPU to throttle its clock speed to stay within its working thermal envelope. |
In Distance with :
better around 7,8% With :
this better around 9% and by replacing
is better around 13,5 % 👍 |
Yes, as I read it, many recommend using 'Shufps' instead |
In Normalize replacing |
In AngleCosine by replacing all |
Hi Peter, i hope your are fine. I haven't got many time since while days. I've some little problems, i need to solve. So i'm finding some little time to code and empty my head. In following this thread : See you soon |
What fun this has been so far.
Just to let you know the changes.
Made mul conform to first second as there is a MulFirst (not tested yet) which does non Math order.
Commented out large parts of CreateEuler, trying to hit the exceptions that they are guarding against, but not managed yet.
Rotations conform to existing rotations.
Euler create gives correct numbers.
Default create rpy not done as we will probably have to decide on world up for the system as this is meant to be the quick quat that defaults to world.
The text was updated successfully, but these errors were encountered: