Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 4055700
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 20, 20262026-05-20T14:44:02+00:00 2026-05-20T14:44:02+00:00

On a different question , the user that answered (Ricky) me also said the

  • 0

On a different question, the user that answered (Ricky) me also said the following (which I still find a little confusing):

When I say they must remain
perpendicular, I only mean that if you
rotate vectors independently by the
same transformation over and over,
floating point errors may creep in and
they could diverge from being
perpendicular. Dot(x,y), dot(y,z) and
dot(x,z) should be very close to zero.
If not, you need to do some cross
products and re-perpendicularize them.
It’s as simple as overwriting
z=cross(x,y), then y=cross(z,x).

There are 3 relevant vectors on my camera system, these vectors are floating point numbers and always normalized. Reference vector points in the direction the camera is looking at, UpVector and RightVector are self-explanatory.

Anyone knowing how to answer, should answer of course, but Ricky, if you’re there, please help me out…

1) What exactly does it mean dot(x,y), dot(y,z) and dot(x,z)? Is this the dot product between these vectors? I suppose… But which ones (x, y, z) correspond to my Reference, UpVector and RightVector? I’m a little confused…

2) Then, these dot products should be very close to zero, how exactly should I check this? I’ve seen code like this to achieve the same thing in a similar context:

const float Math::EPSILON = 1e-6f;

Math::closeEnough(<floating_point_variable_to_check>, 0.0f);

static bool closeEnough(float f1, float f2) {
    // Determines whether the two floating-point values f1 and f2 are
    // close enough together that they can be considered equal.

    return fabsf((f1 - f2) / ((f2 == 0.0f) ? 1.0f : f2)) < EPSILON;
}

I suppose it’s good enough?

3) Where I exactly should I perform all these checks and re-perpendicularize the vectors? I have 3 functions that rotate the camera, Pitch, Yaw and Roll (the last one I don’t use it that much), only these functions change those unit vectors. Should I perform the checks and fixes every time I call one of these rotate functions or would that be too much? Where and when then?

4) Last but not least, to fix them I need to overwrite the vectors with the cross product, makes sense as I want them perpendicular to each other. But isn’t the quote above missing one cross product? And does the order i which I perform those fixes matter?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-20T14:44:03+00:00Added an answer on May 20, 2026 at 2:44 pm

    Hopefully the two current answers are adequate, so I’ll just add on a theoretical note that the reason this arises and the reason it’s not too important how you handle it is that the nine numbers that form a 3×3 rotation matrix and describe how your camera is oriented are more than necessary.

    A rotation matrix is just a matrix with the three vectors (e.g. up, right, forward) as the three columns. Consider a matrix with three vectors e1=right, e2=up, e3=backward. Then to transform a point into the same reference frame as the matrix, you premultiply the column vector by

    [ e1_x  e2_x  e3_x ]
    [ e1_y  e2_y  e3_y ]
    [ e1_z  e2_z  e3_z ]
    

    (Or the inverse… I always get the language confused depending on how you think about it. Also, OpenGL uses 4×4 matrices as a trick to apply translations or even perspective with just one matrix.) Anyway, you can get any of the three vectors by crossing two others. i.e. e1 = e2 x e3, e2 = e3 x e1, and e3 = e1 x e2 That means one vector is unnecessary. One less vector leaves six numbers. The length of the two remaining vectors is irrelevant —— only the direction is important — which leaves four numbers required to describe the transformation. Enter quaternions. They’re a mathematical tool that happen to deal with the remaining four numbers in a stable, robust way. If you use all nine numbers though, you just need to make sure that the vectors always have length 1 and that any one is perpendicular to the other two. Otherwise it’s not really a rotation matrix. Up might not be 90 degrees from right. That’s why I suggested:

    e1 = Normalize(e1);
    e3 = Normalize(Cross(e1,e2));  // e3 is now perpendicular to e1 and e2, and
                                   // probably hasn't changed much.  It will also 
                                   // have length 1.
    e2 = Normalize(Cross(e3,e1));  // e2 was perpendicular to e3 from the previous
                                   // step, but now it's also perpendicular to e1.
    

    You can do this in any order or combination as long as it accomplishes the same effect. Every iteration or every thousand. If you neglect it completely there’s a small chance that your camera will start to distort the image. After a few camera rotations, only the last couple digits will be modified, so think of it as a fudge factor to keep things from drifting over long periods of time.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

[Please note that this is a different question from the already answered How to
Following on from my last Question Buttons to be renamed by the user which
This is related to an earlier question by a different user, asking How to
I posted a related but still different question regarding Protobuf-Net before, so here goes:
I know that this question is perfectly answered in FOSUserBundle documentation, but yet I
Let's say that I have a site where once the user selects a few
Because nobody answered to my previous questions I need to find a different solution.
I have an odd question that im not sure has been asked/answered, and im
I'll rewrite a different question of mine, because the problem case somewhat changed: If
this is a different question concerning: add a connection to database not working, asp.net

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.