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

  • Home
  • SEARCH
  • 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 7738151
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 1, 20262026-06-01T08:11:26+00:00 2026-06-01T08:11:26+00:00

The problem is when I face my camera down the z axis for example

  • 0

The problem is when I face my camera down the z axis for example and pitch this works fine however, after I have finished the pitch and would like to yaw on this new axis it begins to roll for some unknown reason =s.

    void FrustumCamera::xAxisRotation(float angle)
{
//  angle = angle * (double)degToRad;
    Vector3<float> x = m_orientation.getXAxis();
    Vector3<float> y = m_orientation.getYAxis();
    Vector3<float> z = m_orientation.getZAxis();

    y.rotateAroundAxis(x,angle);
    x = m_orientation.getXAxis();
    z.rotateAroundAxis(x,angle);

    m_orientation.setYAxis(y);
    m_orientation.setZAxis(z);

}
void FrustumCamera::yAxisRotation(float angle)
{
//  angle = angle * (double)degToRad;

    Vector3<float> x = m_orientation.getXAxis();
    Vector3<float> y = m_orientation.getYAxis();
    Vector3<float> z = m_orientation.getZAxis();

    x.rotateAroundAxis(y,angle);
    y = m_orientation.getYAxis();
    z.rotateAroundAxis(y,angle);

    m_orientation.setXAxis(x);
    m_orientation.setZAxis(z);
}
void FrustumCamera::zAxisRotation(float angle)
{
    Vector3<float> x = m_orientation.getXAxis();
    Vector3<float> y = m_orientation.getYAxis();
    Vector3<float> z = m_orientation.getZAxis();

    x.rotateAroundAxis(z,angle);
    z = m_orientation.getYAxis();
    y.rotateAroundAxis(z,angle);

    m_orientation.setXAxis(x);
    m_orientation.setYAxis(y);
}

template <class Type>
void Vector3<Type>::rotateAroundAxis(Vector3<Type> axis, const float angle)
{
    float radians = static_cast<Type>(angle * degToRad);
    Type sinAngle = static_cast<Type>(sin(radians));
    Type cosAngle = 0.0;

    if (angle == 90 || angle == -90)
        cosAngle = 0.0;
    else
        cosAngle = cos(radians); 

    normalise(axis);    // normalise the axis

    Type oneMinusCos = 1 - cosAngle;        // (1 - cos(theta))

    // construct the rotation matrix
    Type tempMatrix[3][3];
    tempMatrix[0][0] = (axis.x * axis.x) * oneMinusCos + cosAngle;
    tempMatrix[0][1] = (axis.x * axis.y) * oneMinusCos + axis.z * sinAngle;
    tempMatrix[0][2] = (axis.x * axis.z) * oneMinusCos - axis.y * sinAngle;
    tempMatrix[1][0] = (axis.x * axis.y) * oneMinusCos - axis.z * sinAngle;
    tempMatrix[1][1] = (axis.y * axis.y) * oneMinusCos + cosAngle;
    tempMatrix[1][2] = (axis.y * axis.z) * oneMinusCos + axis.x * sinAngle;
    tempMatrix[2][0] = (axis.x * axis.z) * oneMinusCos + axis.y * sinAngle;
    tempMatrix[2][1] = (axis.y * axis.z) * oneMinusCos - axis.x * sinAngle;
    tempMatrix[2][2] = (axis.z * axis.z) * oneMinusCos + cosAngle;

    Vector3<Type> temp(*this);
    Vector3<Type> result;

    result.x = (temp.x * tempMatrix[0][0]) + (temp.y * tempMatrix[1][0]) + (temp.z * tempMatrix[2][0]);
    result.y = (temp.x * tempMatrix[0][1]) + (temp.y * tempMatrix[1][1]) + (temp.z * tempMatrix[2][1]);
    result.z = (temp.x * tempMatrix[0][2]) + (temp.y * tempMatrix[1][2]) + (temp.z * tempMatrix[2][2]); 

    *this = result;
}

void OpenGLRenderer::startDraw(unsigned long mask)
{
    //sortBuffer();                                     // sort draw queue
    clearBuffers(mask);                                 // clear buffers
    loadIdentity();
    glTranslatef(-1*m_frustumCamera->getViewMatrix().getTranslationAxis().x,-1*m_frustumCamera->getViewMatrix().getTranslationAxis().y,-1*m_frustumCamera->getViewMatrix().getTranslationAxis().z);
    glMultMatrixf(m_frustumCamera->getViewMatrix().getMatrix());
    glTranslatef(m_frustumCamera->getViewMatrix().getTranslationAxis().x,m_frustumCamera->getViewMatrix().getTranslationAxis().y,m_frustumCamera->getViewMatrix().getTranslationAxis().z);// load identity

    //

    // push matrix stack
    matrixStackPush();                                          
}
  • 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-06-01T08:11:27+00:00Added an answer on June 1, 2026 at 8:11 am

    You might be experiencing Gimbal Lock; this can happen if you pitch all the way up or down so your look vector becomes parallel with your up vector, In which case a yaw will be the same as a roll.

    This can be a downside of constructing rotations piecemeal via Euler angles. You may want to look into quaternions. (Note that you cant rotate with Euler angles; they are just a representation for rotation (you need to convert it to matrix or quats), but the way you are tackling it is very much an ‘Euler angle’ way of thinking about it)

    The strength of matrix multiplication is that any sequence of multiple rotations can be represented (and concatenated) as a single rotation matrix. What you need to be doing is something like this:

    void Transformable::yaw(float angle)
    {
        float4x4 rot; // temp rotation matrix
        float3 translate(&_transform._41); // save our translation
        float3 up(&_transform._21); // y axis
    
        // build the rotation matrix for rotation around y
        MatrixRotationAxis(&rot, &up, angle);
    
        // multiply our transform by the rotation matrix
        // note that order of multiplication matters and depends on
        // if your matrices are column-major or row-major
        MatrixMultiply(&_transform, &_transform, &rot);
    
        // write back our original translation
        memcpy(&_transform._41, &translate, sizeof(float3));
    
        // might want to reorthogonalise every now and then
        // to make sure basis vectors are orthonormal
        // or you will probably get matrix creep after a few operations
    }
    

    instead of trying to rotate one basis vector at a time. In this case _transform would be a 4×4 homogenous matrix representing the transformation matrix. (rotation and translation). The topleft 3×3 submatrix is simply the basis vectors of the orientation space.

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

Sidebar

Related Questions

can some one explain why I face problem with backgroundworker backgroundWorker1_RunWorkerCompleted works just fine
I have a problem with CSS3 property for using my own fonts @font-face. In
I have three row in jasper sub report , I face problem when I
I have a TableLayout within ScrollView with a background image. The problem I face
This is a design problem I face regularly and I'd like to find some
I must be the first to face this problem because I can't find even
Note that this isn't a problem I face, I'm more interested in what is
I am new to iphone developement, during development I face problem due to this
I am annoyed with a problem I have repeater control in updatepanel like this.
I face a problem when I try to get value from primary table in

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.