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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T22:20:21+00:00 2026-05-25T22:20:21+00:00

I’m working on a program with IK and have run into what I had

  • 0

I’m working on a program with IK and have run into what I had at first thought was a trivial problem but have since had trouble solving it.

Background:

Everything is in 3d space.
I’m using 3d Vectors and Quaternions to represent transforms.

I have a limb which we will call V1.
I want to rotate it onto V2.

I was getting the angle between V1 and V2.
Then the axis for rotation by V1 cross V2.

Then making a Quaternion from the axis and angle.

I then take the limbs current Orientation and multiply it by the axis angle quaternion.

This I believe is my desired local space for the limb.

This limb is attached to a series of other links. To get the world space I traverse up to the root combining the parents local space with the child’s local space until I reach the root.

This seems to work grand if the vector that I am rotating to is contained within the X and Y plane or if the body which the limb is attached to hasn’t been modified. If anything has been modified, for example rotating the root node, then on the first iteration the vector will rotate very close to the desired vector. After that point though it will begin to spin all over the place and never reach the goal.

I’ve gone through all the math line by line and it appears to all be correct. I’m not sure if there is something that I do not know about or am simply over looking. Is my logical sound? Or am I unaware of something? Any help is greatly appreciated!

Quaternion::Quaternion(const Vector& axis, const float angle)
{
float sin_half_angle = sinf( angle / 2 );

v.set_x( axis.get_x() * sin_half_angle );
v.set_y( axis.get_y() * sin_half_angle );
v.set_z( axis.get_z() * sin_half_angle );

w = cosf( angle / 2 );
}

Quaternion Quaternion::operator* (const Quaternion& quat) const
{

Quaternion result;

Vector v1( this->v );
Vector v2( quat.v  );

float s1 = this->w;
float s2 = quat.w;

result.w  = s1 * s2 - v1.Dot(v2);
result.v  = v2 * s1 + v1 * s2 + v1.Cross(v2); 

result.Normalize();

return result;
}

Vector Quaternion::operator* (const Vector& vec) const
{

Quaternion quat_vec(vec.get_x(), vec.get_y(), vec.get_z(), 0.0f);
Quaternion rotation( *this );

Quaternion rotated_vec = rotation * ( quat_vec * rotation.Conjugate() ); 

return rotated_vec.v;
}

Quaternion Quaternion::Conjugate()
{
    Quaternion result( *this );
    result.v = result.v * -1.0f;
    return result; 
}

Transform Transform::operator*(const Transform tran)
{
return Transform( mOrient * transform.getOrient(), mTrans + ( mOrient *   tran.getTrans());
}

Transform Joint::GetWorldSpace()
{       
Transform world = local_space;

Joint* par = GetParent();

while ( par ) 
{
    world = par->GetLocalSpace() * world;
    par = par->GetParent();
}

return world;
}

void RotLimb()
{
Vector end_effector_worldspace_pos = end_effector->GetWorldSpace().get_Translation();
Vector parent_worldspace_pos       = parent->GetWorldSpace().get_Translation();

Vector parent_To_end_effector      = ( end_effector_worldspace_pos - parent_worldspace_pos ).Normalize(); 
Vector parent_To_goal              = ( goal_pos                    - parent_worldspace_pos ).Normalize(); 

float dot = parent_To_end_effector.Dot( parent_To_goal );

Vector rot_axis(0.0f,0.0f,1.0f);
float  angle = 0.0f;

if (1.0f - fabs(dot) > EPSILON) 
{
    //angle    = parent_To_end_effector.Angle( parent_To_goal );            
    rot_axis = parent_To_end_effector.Cross( parent_To_goal ).Normalize();

    parent->RotateJoint( rot_axis, acos(dot) );
}
}

void Joint::Rotate( const Vector& axis, const float rotation )
{
    mLocalSpace = mlocalSpace * Quaternion( axis, rotation );
}
  • 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-25T22:20:22+00:00Added an answer on May 25, 2026 at 10:20 pm

    You are correct when you write in a comment that the axis should be computed in the local coordinate frame of the joint:

    I’m wondering if this issue is occuring because I’m doing the calculations to get the axis and angle in the world space for the joint, but then applying it to the local space.

    The rotation of the axis from the world frame to the joint frame will look something like this:

    rot_axis = parent->GetWorldSpace().Inverse().get_Rotation() * rot_axis
    

    There can be other issues to debug, but it’s the only logical error I can see in the code that you have posted.

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

Sidebar

Related Questions

link Im having trouble converting the html entites into html characters, (&# 8217;) i
I have a French site that I want to parse, but am running into
this is what i have right now Drawing an RSS feed into the php,
I am currently running into a problem where an element is coming back from
I have a string like this: La Torre Eiffel paragonata all’Everest What PHP function
I ran into a problem. Wrote the following code snippet: teksti = teksti.Trim() teksti
I have just tried to save a simple *.rtf file with some websites and
I want to count how many characters a certain string has in PHP, but
I have a jquery bug and I've been looking for hours now, I can't
Seemingly simple, but I cannot find anything relevant on the web. What is the

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.