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 6969233
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T16:33:18+00:00 2026-05-27T16:33:18+00:00

I have a problem i can’t get my head around. I use a sphere,

  • 0

I have a problem i can’t get my head around.

I use a sphere, when the user touch anywhere on the sphere i get a point in form of a 3D vector(x, y, z) all in opengl coordinates.

I also have a defined point on the sphere to begin with, also a 3D vector.

For example:

real V x: -0.2881811, y: 0.25460157, z: 0.9231087

Where “real V” is the point defined to begin with. (Sphere has a readius of 1.0)

After i’ve rotated the sphere using gl.glRotatef i want to pin out the new point with OpenGL coordinates of “real V”.

By doing this i use something like this:

real.rotate(-model.getRotationX(), 1f, 0f, 0);
    real.rotate(-model.getRotationY(), 0f, 1f, 0);

Where “getRotationX and Y is the total rotation of the sphere (that i know is correct).

and real.rotate looks something like this:

    public Vector3 rotate(float angle, float axisX, float axisY, float axisZ)
{
    inVec[0] = x;
    inVec[1] = y;
    inVec[2] = z;
    inVec[3] = 1;

    Matrix.setIdentityM(matrix, 0);
    Matrix.rotateM(matrix, 0, angle, axisX, axisY, axisZ);
    Matrix.multiplyMV(outVec, 0, matrix, 0, inVec, 0);
    x = outVec[0];
    y = outVec[1];
    z = outVec[2];
    return this;
}

When doing this and also translating vector “real (V)” by adding origin-vector of spehere to “real (V)” vector i would believe i would get the correct new point on the spehere where i would be able to for example set a flag or similar at.

The problem is that something isn’t getting right after the vectors rotation.

If i don’t rotate the sphere and thereby not rotating the vector everything becomes the way i want it. But when i rotate it, the more the rotation the more of i come from the correct point.

Following is a outline from LogCat:

real V x: -0.2881811, y: 0.25460157, z: 0.9231087
rotated V x: 0.10823092, y: 0.79800075, z: 0.5928582
added V x: 0.10823092, y: 0.79800075, z: -3.4071417
subtracted V x: 0.10823092, y: 0.79800075, z: 0.5928583
backRotated V x: -0.5257477, y: 0.21287462, z: 0.8235738

As you can se, when backrotated it’s not the same as the original for some reason.

    Vector3 real = Result.getRealVector(location);

    Log.d(TAG, "real V "+ real.toString());
    real.rotate(-model.getRotationX(), 1f, 0f, 0);
    real.rotate(-model.getRotationY(), 0f, 1f, 0);
    Log.d(TAG, "rotated V " + real.toString());

    real.add(model);
    Log.d(TAG, "added V " + real.toString());

    real.sub(model);
    Log.d(TAG, "subtracted V " + real.toString());
    real.rotate(model.getRotationX(), 1f, 0f, 0f);
    real.rotate(model.getRotationY(), 0f, 1f, 0f);

    Log.d(TAG, "backRotated V " + real.toString());

It’s not that far of, the point is always somwhere near where it should be, but still…

I know it may be hard to understand my problem, somewhat difficult to explain.
What i am hoping for is someone seeing any obvious problem.

  • 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-27T16:33:19+00:00Added an answer on May 27, 2026 at 4:33 pm

    With matrix operations order is very important. If you rotate separately around each axis, in order to undo those operations you will need perform the inverse operations in the reverse order to get your original vector back.

    real.rotate(-model.getRotationX(), 1f, 0f, 0f);
    real.rotate(-model.getRotationY(), 0f, 1f, 0f);
    ...
    real.rotate(model.getRotationY(), 0f, 1f, 0f);
    real.rotate(model.getRotationX(), 1f, 0f, 0f);
    

    To put it mathematically:
    (where A and B are matrices, A-1 and B-1 are there respective inverse matrices, and I is the identity matrix)

    A * B * B-1 * A-1 == I

    however

    A * B * A-1 * B-1 != I

    I suggest studying a little bit if linear algebra if you have not already, as a good basic understanding is very helpful when doing graphics programming.

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

Sidebar

Related Questions

I have a problem I can not resolve on a form Here's my view:
I seem to have a problem and can't get it work. I'm working on
Can I use jsf component libraries(primefaces) with spring mvc .I have problem with client
i have this problem: user can add an HTML description and it will be
I have a problem and can't solve it alone. My teacher gives me one
I have a problem - i can't compile SqlCipher. I'm using this http://groups.google.com/group/sqlcipher/browse_thread/thread/55c6296b56bf4533/c792bbec6df7d4f4?tvc=2#c792bbec6df7d4f4 instructions
I have problem compilin this code..can anyone tell whats wrong with the syntax CREATE
i have a problem that i can't solve ! (sqlite3, but i think it
can anyone help, i have problem doing a sort, I thought i had it
I'm almost finished with my program, but I have one problem that I can't

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.