How to find pos/rot values based on extended parents objects space

Become a member of the CGSociety

Connect, Share, and Learn with our Large Growing CG Art Community. It's Free!

Thread Tools Display Modes
  03 March 2004
How to find pos/rot values based on extended parents objects space

Iím trying to determine how to find the local position and rotation values of an object based on an extended parentís object space. Here is an example situation:

GroundPlane (mesh)
------groupRoot (null, possibly animate, child of GroundPlane)
------CTRL (null, animated, child of groupRoot)
------ Ball (mesh, may or may not be animated, child of control)

So for example the position values are:
GoundPlane [World 0,0,0 || Local 0,0,0]
groupRoot [W 1,0,0 || L 1,0,0]
CTRL [W 2,0,1 || L 1,0,1]
Ball [W 2,0,1 || L 0,0,0]

For now assume all rotation values are 0.

What I want to find is what the local value for Ball would be based on the object space of groupRoot. The problem right now is if I use world position and then rotate GroundPlane or groupRoot all the calculations get thrown off, so I need to account for the affected position of groupRoot and any additional changes made by GroundPlane. I canít use local values for Ball because most if not all animation is done to CRTL so Ballís local values do not change.

My thought is I need to get the world values for groupRoot and Ball then modify Ballís values to reflect itís local position in groupRootís object space. So far Iíve yet to figure out an approach to achieve this. In the end I the x,y,z,h,p,b values for Ball in relation to groupRoot.

Iím working in C using the messiah API, which provides me access to channel values and matrix values for objects, along with the standard C math libraryís.

(My Plugins)
  03 March 2004
Your description leaves me feeling a little confused.

I think what you're after is Ball's position/rotation(/scale), relative to groupRoot, right?

I can get into a more dtailed explanation about coordinate systems and transforms if you want, but the short answer is:

o Each of your objects has its own transform. This tells you where it is relative to its parent

o As you step up the heirachy, you concatenate each object's transformation matrix

So for groupRoot, CTRL and Ball we have transfomation matrices Tgr, Tc and Tb, respectively.

To find the relative transformation of Ball from groupRoot, Tbgr, we must first find the relative transform of Ball from its parent, then of its parent from groupRoot:

Tbgr = Tb X Tc

If we are assuming all rotation values are 0, that means that Ball is translated [ 2 0 1 ] from groupRoot, as when we multiply the transformation matrices, the translation values are added together, as you would expect.

You can have your characters photoreal, fast or cheap. Pick two.
  03 March 2004
playmesumch00ns, your correct on what I'm trying to do. Thanks for the explanation, I'll start trying it out.

I have 3 options for reading an objects matrix, local, world and rotate only. From your discription I should concatenate the local matrix's for the items up the hiearchy by multipling the matrixes together, correct? And this will take rotation of the parents into account when I get my final position for Ball?

Thanks again.
(My Plugins)
  03 March 2004
The transformation matrix encodes rotation, position, scale, skew, and whatever else you could want to do all in one.

Yep, grab the local transformation matrices and multiply up the heirachy. Depending on the matrix notation convention used by your API, you'll want to do the multiplication in a particular order. If it doesn't work one way, try it the other

You can have your characters photoreal, fast or cheap. Pick two.
  03 March 2004
I'm trying to not get to complicated yet, but here I go anyway. If groupRoot is a child of another item can I just get the world matrix for groupRoot and stop going up the hierarchy?

[-edit spelling]

(My Plugins)
  03 March 2004
Yep. try it out and see if it works

You can have your characters photoreal, fast or cheap. Pick two.
  03 March 2004
if i understood correctly, you want to be able to get an objects position local to an arbitrary object in your scene?

most apps already have local/worldspace matrices/transforms/kinematics, so this shouldn't be any trouble, just get the global position & matrix, then follow the basic rules:

going between local and global space using matrices:

local to global:


multiply the position by the global matrix (world matrix) to shift from local space of the object you got your global matrix from into world space.

global to local:


multiply by the inverted global matrix of any object in order to find your position relative to that object in it's local space.

so all you need are the global matrices (including global position) for all your objects. which should be directly accesible in whatever app you use.
The Third Party | Homepage | My Reel
"You need to know what you're doing before you start, and to start because you need what you're doing."
  03 March 2004
I'm doing something wrong, I keep getting the world position back from the resulting matrix.

I want to find the local position and rotation for an object in relation to an arbitrary object. So to simplify based on you explanation:

target object = T
arbitrary object = A

I can get:
Target position local vector = TpVEC
Target position world vector = TpwVEC
Target rotation local vector = TrVEC
Target rotation world vector = TrwVEC
Target local matrix = Tm
Target world matrix = Twm


Arbitrary position local vector = ApVEC
Arbitrary position world vector = ApwVEC
Arbitrary rotation local vector = ArVEC
Arbitrary rotation world vector = ArwVEC
Arbitrary local matrix = Am
Arbitrary world matrix = Awm

so based on on these I want the local pos/rot for Target in relation to Arbitrary.

does that mean the I need to:
TpwVec*Inverse(Awm) = result matrix?

or is it
(TpVec*Twm)*Inverse(ApVec*Awm)= result matrix

or am I completely off in what I need to do?

(My Plugins)
  04 April 2004
I got it working, the problem was I did not realize the invertmatrix function I was using was 3x3 only. I added a 4x4 invert function of my own and it worked.

Thanks for the help playmesumch00ns and mdme_sadie.
(My Plugins)
  01 January 2006
Thread automatically closed

This thread has been automatically closed as it remained inactive for 12 months. If you wish to continue the discussion, please create a new thread in the appropriate forum.
CGTalk Policy/Legalities
Note that as CGTalk Members, you agree to the terms and conditions of using this website.
Thread Closed share thread

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Society of Digital Artists

Powered by vBulletin
Copyright ©2000 - 2006,
Jelsoft Enterprises Ltd.
Minimize Ads
Forum Jump

All times are GMT. The time now is 03:21 AM.

Powered by vBulletin
Copyright ©2000 - 2018, Jelsoft Enterprises Ltd.