1

I have a QEF implementation like this

float atA[3][3] = { 0 };
FVector atb = FVector::ZeroVector;
for (const FEdgeIntersection& e : IntersectionList)
{
 const FVector& n = e.Normal;
 float b_i = FVector::DotProduct(n, e.Position);
 atA[0][0] += n.X * n.X;
 atA[0][1] += n.X * n.Y;
 atA[0][2] += n.X * n.Z;
 atA[1][0] += n.Y * n.X;
 atA[1][1] += n.Y * n.Y;
 atA[1][2] += n.Y * n.Z;
 atA[2][0] += n.Z * n.X;
 atA[2][1] += n.Z * n.Y;
 atA[2][2] += n.Z * n.Z;
 atb.X += n.X * b_i;
 atb.Y += n.Y * b_i;
 atb.Z += n.Z * b_i;
}
FMatrix M(
 FPlane(atA[0][0], atA[0][1], atA[0][2], 0),
 FPlane(atA[1][0], atA[1][1], atA[1][2], 0),
 FPlane(atA[2][0], atA[2][1], atA[2][2], 0),
 FPlane(0, 0, 0, 1)
);
FVector Result = M.InverseFast().TransformVector(atb);

When I have IntersectionList with these values

{Position={X=-960.00006103515625 Y=766.10652868112652 Z=-24.615383148193359} Normal={X=0.97101487888310145 Y=0.0000000000000000 Z=0.23901904733229035} }
{Position={X=-1006.2012716118422 Y=812.30773925781250 Z=-24.615383148193359} Normal={X=0.69663297076236907 Y=0.69663297076236907 Z=0.17147888527043917} }
{Position={X=-960.00006103515625 Y=812.30773925781250 Z=-65.753435217289166} Normal={X=0.0000000000000000 Y=0.97101488224128463 Z=0.23901903368967076} }

I get the following Result: {X=-996.07524496255644 Y=766.10633524904335 Z=121.94025333520403}

Now looking at it the Z is too far from where it should be from -24/-65 to a 121!!!

I expect it to be within close range of the value I inputted

Any idea What is wrong with my calculation!!

Thanks in advance

asked Oct 30 at 11:17
2
  • I think the main issue is you're using unstable math. InverseFast makes some assumptions on input, so can you try Inverse? Then are your normals actually normalized (to length 1.0)? Or maybe this. Commented Oct 30 at 12:39
  • First, Thanks for responding. 1 - Using Inverse() doesnt change the result {X=-996.07524496255644 Y=766.10633524904335 Z=121.94025333520403} 2- Normals are normalized of course and I already posted the normals right next to the position, if you scroll the position, you will see the normal corresponding to the position Commented Oct 30 at 12:57

0

Know someone who can answer? Share a link to this question via email, Twitter, or Facebook.

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

By clicking "Post Your Answer", you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.