not implemented guQuat funcs and others.
not implemented guQuat funcs and others.
i've noticed that :
MTXQuat (not implemented, even N's one is buggy)
QUATSlerp (not implemented)
QUATMtx (not implemented)
QUATMultiply (buggy C version and ps not implemented)
MTXInvXpose (not implemented)
now i'm a happy devkitpro user and i have ported my stuff
would you be interested by the C versions that works?
i guess you would prefer the assembly optimised but i can't help for that sorry..
MTXQuat (not implemented, even N's one is buggy)
QUATSlerp (not implemented)
QUATMtx (not implemented)
QUATMultiply (buggy C version and ps not implemented)
MTXInvXpose (not implemented)
now i'm a happy devkitpro user and i have ported my stuff
would you be interested by the C versions that works?
i guess you would prefer the assembly optimised but i can't help for that sorry..
-
- Site Admin
- Posts: 1989
- Joined: Tue Aug 09, 2005 3:21 am
- Location: UK
- Contact:
Re: not implemented guQuat funcs and others.
We're more than happy to consider patches to libogc, ideally these should be supplied as a diff against latest svn.
https://sourceforge.net/tracker/?group_ ... tid=668553
https://sourceforge.net/tracker/?group_ ... tid=668553
Re: not implemented guQuat funcs and others.
Hi,
first of all: Thanks for the patch. I've taken a look thru and there're a few questions i've.
What's the desired result for Normalize? I see you calculate the dot-product/scale from the source quaternion but then just multiply the "unit" quaternion with the scale value. Isn't the "unit" quaternion meant to be the destination quaternion? Or does it already contain meaningful values? For my understanding of normalization of vectors/quaternions you calculate the dot-product/scale from the vector/quaternion and multiply this vector/quaternion with the scaler and hence get the normalized variant of it.
For the QuatMtx & MtxQuat i'd like to ask you if the variants below would do the trick too (i've to admit that i'm not very well at quaternion calculations, but those would make my life easier to build the PS assembly versions of it).
QuatMtx:
MtxQuat:
Code is taken from IrrLichts implementation. Probably needs to be right ordered for the access of the matrix elements.
regards
shagkur
PS: when this all is done in C i'll write down the assembly versions of it.
first of all: Thanks for the patch. I've taken a look thru and there're a few questions i've.
What's the desired result for Normalize? I see you calculate the dot-product/scale from the source quaternion but then just multiply the "unit" quaternion with the scale value. Isn't the "unit" quaternion meant to be the destination quaternion? Or does it already contain meaningful values? For my understanding of normalization of vectors/quaternions you calculate the dot-product/scale from the vector/quaternion and multiply this vector/quaternion with the scaler and hence get the normalized variant of it.
For the QuatMtx & MtxQuat i'd like to ask you if the variants below would do the trick too (i've to admit that i'm not very well at quaternion calculations, but those would make my life easier to build the PS assembly versions of it).
QuatMtx:
Code: Select all
m(0,0) = 1.0f - 2.0f*Y*Y - 2.0f*Z*Z;
m(0,1) = 2.0f*X*Y - 2.0f*Z*W;
m(0,2) = 2.0f*X*Z + 2.0f*Y*W;
m(0,3) = 0.0f;
m(1,0) = 2.0f*X*Y + 2.0f*Z*W;
m(1,1) = 1.0f - 2.0f*X*X - 2.0f*Z*Z;
m(1,2) = 2.0f*Z*Y - 2.0f*X*W;
m(1,3) = 0.0f;
m(2,0) = 2.0f*X*Z - 2.0f*Y*W;
m(2,1) = 2.0f*Z*Y + 2.0f*X*W;
m(2,2) = 1.0f - 2.0f*X*X - 2.0f*Y*Y;
m(2,3) = 0.0f;
m(3,0) = 0.0f;
m(3,1) = 0.0f;
m(3,2) = 0.0f;
m(3,3) = 1.0f;
Code: Select all
const f32 diag = mat(0,0) + mat(1,1) + mat(2,2) + 1;
if(diag>0.0f) {
const f32 scale = sqrtf32(diag)*2.0f;
X = (mat(1,2) - mat(2,1))/scale;
Y = (mat(2,0) - mat(0,2))/scale;
Z = (mat(0,1) - mat(1,0))/scale;
W = 0.25f*scale;
} else {
if(mat(0,0)>mat(1,1) && mat(0,0)>mat(2,2)) {
const f32 scale = sqrtf32(1.0f + mat(0,0) + mat(1,1) + mat(2,2))*2.0f;
X = 0.25f*scale;
Y = (mat(1,0) + mat(0,1))/scale;
Z = (mat(0,2) + mat(2,0))/scale;
W = (mat(1,2) - mat(2,1))/scale;
} else if(mat(1,1)>mat(2,2)) {
const f32 scale = sqrtf32(1.0f + mat(0,0) + mat(1,1) + mat(2,2))*2.0f;
X = (mat(1,0) + mat(0,1))/scale;
Y = 0.25f*scale;
Z = (mat(2,1) + mat(1,2))/scale;
W = (mat(2,0) - mat(0,2))/scale;
} else {
const f32 scale = sqrtf32(1.0f + mat(0,0) + mat(1,1) + mat(2,2))*2.0f;
X = (mat(2,0) + mat(0,2))/scale;
Y = (mat(2,1) + mat(1,2))/scale;
Z = 0.25f*scale;
W = (mat(0,1) - mat(1,0))/scale;
}
}
return normalize();
regards
shagkur
PS: when this all is done in C i'll write down the assembly versions of it.
Re: not implemented guQuat funcs and others.
Hello,
//Damn me here is the correction
void c_guQuatNormalize ( Quaternion* src, Quaternion* unit )
{
f32 dot,scale;
dot = (src->x * src->x) + (src->y * src->y) + (src->z * src->z) + (src->w * src->w);
if (dot == 0.f)
return;
scale = 1.f / sqrtf(dot);
//Of course there was a very bad affectation here ^^
unit->x = src->x * scale;
unit->y = src->y * scale;
unit->z = src->z * scale;
unit->w = src->w * scale;
}
I'll test your Quat->Mtx->Quat asap
//Damn me here is the correction
void c_guQuatNormalize ( Quaternion* src, Quaternion* unit )
{
f32 dot,scale;
dot = (src->x * src->x) + (src->y * src->y) + (src->z * src->z) + (src->w * src->w);
if (dot == 0.f)
return;
scale = 1.f / sqrtf(dot);
//Of course there was a very bad affectation here ^^
unit->x = src->x * scale;
unit->y = src->y * scale;
unit->z = src->z * scale;
unit->w = src->w * scale;
}
I'll test your Quat->Mtx->Quat asap
Re: not implemented guQuat funcs and others.
Hello,
Ok both versions are giving similar results.
here are right ordered Mtx versions:
for quatMtx:
const f32 diag = guMtxRowCol(m,0,0) + guMtxRowCol(m,1,1) + guMtxRowCol(m,2,2) + 1;
if(diag>0.0f) {
const f32 scale = sqrtf(diag)*2.0f;
quat->x = (guMtxRowCol(m,2,1) - guMtxRowCol(m,1,2))/scale;
quat->y = (guMtxRowCol(m,0,2) - guMtxRowCol(m,2,0))/scale;
quat->z = (guMtxRowCol(m,1,0) - guMtxRowCol(m,0,1))/scale;
quat->w = 0.25f*scale;
} else {
if(guMtxRowCol(m,0,0)>guMtxRowCol(m,1,1) && guMtxRowCol(m,0,0)>guMtxRowCol(m,2,2)) {
const f32 scale = sqrtf(1.0f + guMtxRowCol(m,0,0) + guMtxRowCol(m,1,1) + guMtxRowCol(m,2,2))*2.0f;
quat->x = 0.25f*scale;
quat->y = (guMtxRowCol(m,0,1) + guMtxRowCol(m,1,0))/scale;
quat->z = (guMtxRowCol(m,2,0) + guMtxRowCol(m,0,2))/scale;
quat->w = (guMtxRowCol(m,2,1) - guMtxRowCol(m,1,2))/scale;
} else if(guMtxRowCol(m,1,1)>guMtxRowCol(m,2,2)) {
const f32 scale = sqrtf(1.0f + guMtxRowCol(m,0,0) + guMtxRowCol(m,1,1) + guMtxRowCol(m,2,2))*2.0f;
quat->x = (guMtxRowCol(m,0,1) + guMtxRowCol(m,1,0))/scale;
quat->y = 0.25f*scale;
quat->z = (guMtxRowCol(m,1,2) + guMtxRowCol(m,2,1))/scale;
quat->w = (guMtxRowCol(m,0,2) - guMtxRowCol(m,2,0))/scale;
} else {
const f32 scale = sqrtf(1.0f + guMtxRowCol(m,0,0) + guMtxRowCol(m,1,1) + guMtxRowCol(m,2,2))*2.0f;
quat->x = (guMtxRowCol(m,0,2) + guMtxRowCol(m,2,0))/scale;
quat->y = (guMtxRowCol(m,1,2) + guMtxRowCol(m,2,1))/scale;
quat->z = 0.25f*scale;
quat->w = (guMtxRowCol(m,1,0) - guMtxRowCol(m,0,1))/scale;
}
}
guQuatNormalize ( (Quaternion*) quat, (Quaternion*) quat);
for guMtxQuat: (warning undefined translation part here)
guMtxRowCol(m0,0,0) = 1.0f - 2.0f*q0->y*q0->y - 2.0f*q0->z*q0->z;
guMtxRowCol(m0,1,0) = 2.0f*q0->x*q0->y - 2.0f*q0->z*q0->w;
guMtxRowCol(m0,2,0) = 2.0f*q0->x*q0->z + 2.0f*q0->y*q0->w;
guMtxRowCol(m0,0,1) = 2.0f*q0->x*q0->y + 2.0f*q0->z*q0->w;
guMtxRowCol(m0,1,1) = 1.0f - 2.0f*q0->x*q0->x - 2.0f*q0->z*q0->z;
guMtxRowCol(m0,2,1) = 2.0f*q0->z*q0->y - 2.0f*q0->x*q0->w;
guMtxRowCol(m0,0,2) = 2.0f*q0->x*q0->z - 2.0f*q0->y*q0->w;
guMtxRowCol(m0,1,2) = 2.0f*q0->z*q0->y + 2.0f*q0->x*q0->w;
guMtxRowCol(m0,2,2) = 1.0f - 2.0f*q0->x*q0->x - 2.0f*q0->y*q0->y;
now good luck with the assembly version! ^^
Ok both versions are giving similar results.
here are right ordered Mtx versions:
for quatMtx:
const f32 diag = guMtxRowCol(m,0,0) + guMtxRowCol(m,1,1) + guMtxRowCol(m,2,2) + 1;
if(diag>0.0f) {
const f32 scale = sqrtf(diag)*2.0f;
quat->x = (guMtxRowCol(m,2,1) - guMtxRowCol(m,1,2))/scale;
quat->y = (guMtxRowCol(m,0,2) - guMtxRowCol(m,2,0))/scale;
quat->z = (guMtxRowCol(m,1,0) - guMtxRowCol(m,0,1))/scale;
quat->w = 0.25f*scale;
} else {
if(guMtxRowCol(m,0,0)>guMtxRowCol(m,1,1) && guMtxRowCol(m,0,0)>guMtxRowCol(m,2,2)) {
const f32 scale = sqrtf(1.0f + guMtxRowCol(m,0,0) + guMtxRowCol(m,1,1) + guMtxRowCol(m,2,2))*2.0f;
quat->x = 0.25f*scale;
quat->y = (guMtxRowCol(m,0,1) + guMtxRowCol(m,1,0))/scale;
quat->z = (guMtxRowCol(m,2,0) + guMtxRowCol(m,0,2))/scale;
quat->w = (guMtxRowCol(m,2,1) - guMtxRowCol(m,1,2))/scale;
} else if(guMtxRowCol(m,1,1)>guMtxRowCol(m,2,2)) {
const f32 scale = sqrtf(1.0f + guMtxRowCol(m,0,0) + guMtxRowCol(m,1,1) + guMtxRowCol(m,2,2))*2.0f;
quat->x = (guMtxRowCol(m,0,1) + guMtxRowCol(m,1,0))/scale;
quat->y = 0.25f*scale;
quat->z = (guMtxRowCol(m,1,2) + guMtxRowCol(m,2,1))/scale;
quat->w = (guMtxRowCol(m,0,2) - guMtxRowCol(m,2,0))/scale;
} else {
const f32 scale = sqrtf(1.0f + guMtxRowCol(m,0,0) + guMtxRowCol(m,1,1) + guMtxRowCol(m,2,2))*2.0f;
quat->x = (guMtxRowCol(m,0,2) + guMtxRowCol(m,2,0))/scale;
quat->y = (guMtxRowCol(m,1,2) + guMtxRowCol(m,2,1))/scale;
quat->z = 0.25f*scale;
quat->w = (guMtxRowCol(m,1,0) - guMtxRowCol(m,0,1))/scale;
}
}
guQuatNormalize ( (Quaternion*) quat, (Quaternion*) quat);
for guMtxQuat: (warning undefined translation part here)
guMtxRowCol(m0,0,0) = 1.0f - 2.0f*q0->y*q0->y - 2.0f*q0->z*q0->z;
guMtxRowCol(m0,1,0) = 2.0f*q0->x*q0->y - 2.0f*q0->z*q0->w;
guMtxRowCol(m0,2,0) = 2.0f*q0->x*q0->z + 2.0f*q0->y*q0->w;
guMtxRowCol(m0,0,1) = 2.0f*q0->x*q0->y + 2.0f*q0->z*q0->w;
guMtxRowCol(m0,1,1) = 1.0f - 2.0f*q0->x*q0->x - 2.0f*q0->z*q0->z;
guMtxRowCol(m0,2,1) = 2.0f*q0->z*q0->y - 2.0f*q0->x*q0->w;
guMtxRowCol(m0,0,2) = 2.0f*q0->x*q0->z - 2.0f*q0->y*q0->w;
guMtxRowCol(m0,1,2) = 2.0f*q0->z*q0->y + 2.0f*q0->x*q0->w;
guMtxRowCol(m0,2,2) = 1.0f - 2.0f*q0->x*q0->x - 2.0f*q0->y*q0->y;
now good luck with the assembly version! ^^
Re: not implemented guQuat funcs and others.
Hi,
thanks alot for having a look at it.
I've added so far all the C version of those quaternion functions.
Additionally i also added PS version for QuatMultiply,QuatNormalize & QuatInverse.
So still missing is QuatMtx & MtxQuat as this will take a bit of time to do so.
I'd be glad if you could test the PS version i just added. Just call the like them now without any prefix, i.e. guQuatNormalize.
regards
shagkur
thanks alot for having a look at it.
I've added so far all the C version of those quaternion functions.
Additionally i also added PS version for QuatMultiply,QuatNormalize & QuatInverse.
So still missing is QuatMtx & MtxQuat as this will take a bit of time to do so.
I'd be glad if you could test the PS version i just added. Just call the like them now without any prefix, i.e. guQuatNormalize.
regards
shagkur
Re: not implemented guQuat funcs and others.
Hello,
Tested guxxx implementations using 23/06/09 SVN version.
It seems all fine from my side ^^
Would be nice to get guQuatSlerp implemented aswell.
The MtxInvXPose optimised assembly version would also be neat for lighting (normals, envmap and so on)
Let us know when full optimised versions will be available eh?
cheers!
Tested guxxx implementations using 23/06/09 SVN version.
It seems all fine from my side ^^
Would be nice to get guQuatSlerp implemented aswell.
The MtxInvXPose optimised assembly version would also be neat for lighting (normals, envmap and so on)
Let us know when full optimised versions will be available eh?
cheers!
Re: not implemented guQuat funcs and others.
Hi,
i'm working on them...
Will come back as soon as i got them.
regards
shagkur
i'm working on them...
Will come back as soon as i got them.
regards
shagkur
Who is online
Users browsing this forum: Bing [Bot] and 1 guest