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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 30, 20262026-05-30T03:31:42+00:00 2026-05-30T03:31:42+00:00

Say a object’s orientation is represented by a quaternion. If I want to rotate

  • 0

Say a object’s orientation is represented by a quaternion.
If I want to rotate that object, I simply multiply the quaternion with the rotational quaternion.

object.q = q_rotation*(object.q)

Then for an object that is composed of made up of a set of smaller objects. How do I rotate it?

class Object
{
 public:
    std::vector<Object> part;
    Point centre; //Point is basically double x, y, z
    Quaternion q;

    void RotateBy(Quaternion q_rotation);

};

Just say this object has two part’s. And each part could have its own centre and q, and they relative to the entire space (not relative to the centre of the main object).

Then now I want to rotate the object, and all its parts should rotate as well and get updated to their new centres and q’s. The parts will be rotated relative to the main object’s centre.

How should I do that??? I have found many some link that show how to do this with transformational matrice. But is there a way to do it directly with the quaternion?

Perhaps, in other word, how to rotate a quaternion with the origin shifted?

Thank you for your help!

  • 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-30T03:31:44+00:00Added an answer on May 30, 2026 at 3:31 am

    It is actually easier than I thought. I guess those linear algebra classes was actually useful.

    In this case, I assume you have some 3D geometry defined as a class named ‘GeomType’. An ‘Object’ is made up of many ‘GeomType’. Here an ‘Object’ is simple a vector of ‘GeomType’.
    Each ‘GeomType’ in an ‘Object’ is defined by it centre point location relative to the centre point of the ‘Object’ and an quaternion which represent the rotation from a default neutral position. Here is some sample code.

    There are also PointType which is basically (x, y, z) in double, and QuaternionType which is (w,x,y,z) in double as well.

    //suppose you have this Object
    std::vector <GeomType> Object; //and it is already initialized
    //you were given the rotation quaternion and the point to rotate about.
    PointType origin;
    QuaternionType Q2;
    
    //rotate the GeomTypes
    unsigned int numGeom = Object.size();
    for (unsigned int i = 0; i <numGeom; i++)
    {
        //1. translate the individual GeomType
        const PointType geomCentre= Object[i].GetCentrePosition();
    
        //Rotate vector representing the direction and distance from origin to geom
        //note that the origin of rotation does not need to be the centre
        const PointType newPos = 
              RotateAbout(PointType(geomCentre[0], geomCentre[1], dGeomPos[2]),
                                                             Q2, origin);
        //move the GeomType to the new position
        Object[i].SetCentrePosition(newPos.GetX(), newPos.GetY(), newPos.GetZ());
    
        //2. Rotate the GeomType
        QuaternionType Qo = Object[i].GetQuaternion(); //current quaternion of the geom
        QuaternionType Qr; //resultant quaternion of the geom
    
        Qr = Q2*Qo; //rotating by multiplication 
        //(please check other sites on how to multiply quaternions)
    
        Object[i].SetQuaternion(Qr); //set the new quaternion
    }
    

    This is the RotateAbout function which was used to rotate a vector about a point

    PointType RotateAbout(const PointType &InitPos, const QuaternionType &Qr, const PointType& Origin)
    {
         //the vector from the origin
         PointType newVec = InitPos-Origin;
         //extract the magnitude
         const double vecLength = newVec.Length();
    
         //normalize the vector and rotate that vector
         //then translate the geom to the new position
         newVec = Origin + Qr*(newVec.GetUnitVector())*vecLength;
    
         return newVec;
    }
    

    Here is the general program to rotate a set of 3D objects relative to a point. It should be applicable to any programming language though it is written based on C++.

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

Sidebar

Related Questions

I'm drawing an object (say, a cube) in OpenGL that a user can rotate
If I have an object say @user and I want to render only certain
I want to create an ouputStreamWriter object say out, for a file named say
Suppose I have a method that must return an object (say from a database
In C#, suppose you have an object (say, myObject ) that is an instance
I know that most everything is an object in JavaScript. When people say object
(When I say object address, I mean the string that you type in Python
When you have couple of synchronized blocks on an object (say) obj then how
Let's say my object has a CGRect property named rect . I want to
I want to take an object, let's say this object: public class BenchmarkList {

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.