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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 29, 20262026-05-29T10:22:06+00:00 2026-05-29T10:22:06+00:00

I am using quaternions in my game to calculate some basic angles. Now I

  • 0

I am using quaternions in my game to calculate some basic angles.

Now I am trying to get the angle of a quaternion, given a certain axis. So, given a quaternion and a new axis. Can I get the projected angle back?

To me, it seems like a solid way to calculate the signed angle between two vectors. The code is written in Unity3D C#, but this does not necessarily has to be the case. It’s more of a general method.

public static float DirectionalAngle(Vector3 from, Vector3 to, Vector3 up)
{
    // project the vectors on the plane with up as a normal
    Vector3 f = Vector3.Exclude(up, from);
    Vector3 t = Vector3.Exclude(up, to);

    // creates an angle-axis rotation
    Quaternion q = Quaternion.FromToRotation(f, t);

    // do something to get the angle out of the quaternion,
    // given the new axis.
    // TODO: Make this method. Doesn't exist.
    Quaternion q2 = Quaternion.GetAngleFromAxis(q, Vector3.right);

    return q2.Angle(q2);
}

I can always get the angle and axis from the quaternion, as well as x,y,z,w and the euler angles. But I don’t see a way to get the projected angle from the quaternion on the axis.

  • 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-29T10:22:08+00:00Added an answer on May 29, 2026 at 10:22 am

    I found it! The only thing I had to do was rotate the quaternion in such a way that it is oriented in the local space. The method seems to be sound for all planes I’ve tested it on.

    public static float DirectionalAngle(Vector3 from, Vector3 to, Vector3 up)
    {
        // project the vectors on the plane with up as a normal
        Vector3 f = Vector3.Exclude(up, from);
        Vector3 t = Vector3.Exclude(up, to);
    
        // rotate the vectors into y-up coordinates
        Quaternion toZ = Quaternion.FromToRotation(up, Vector3.up);
        f = toZ * f;
        t = toZ * t;
    
        // calculate the quaternion in between f and t.
        Quaternion fromTo = Quaternion.FromToRotation(f,t);
    
        // return the eulers.
        return fromTo.eulerAngles.y;
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am writing a camera class for OpenGL that is using quaternions and Angle-Axis.
Using C# .NET 3.5 and WCF, I'm trying to write out some of the
I am trying to extract the axis of rotation and the angle of rotation
I am trying to develop a game in Unity where you jump from 2D
Using linq2sql I'm trying to take the string in txtOilChange and update the oilChange
Using the navigator.geolocation object in JavaScript. Trying to establish accurate ranges, but wondering exactly
Using Rails 3.2.0 with haml, sass and coffeescript: Basically I am trying to disable
Tell me if I am wrong. I'm starting using quaternions. Using a rotation matrix
I'm learning some OpenGL game programing, and I'm stuck in how to implement so
I am using C++ to code some complicated FFT algorithm, so I need to

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.