Jump to content

Change coordinate system


Macha

Recommended Posts

I have a geometry sitting nicely in the default world coordinate system.

I have another 3 vectors defining another coordinate system.

How would I transform the geometry from one coordinate system to the other, so that it transforms and aligns appropriately?

I know I can do something with transformPrims() and hou.hmath.buildRotateAboutAxis or getTransformFromPointToPoint() but I'm not sure what, I get all confused.

Does anyone know how to do it, or where I can find good info about it?

If it helps. These are my new coordinate vectors:

v0 = [-0.508 -0.496 -0.703]

v1 = [-0.797 -0.036  0.602]

v2 = [ 0.324 -0.867  0.376]

post-4013-126879574767_thumb.jpg

Edited by Macha
Link to comment
Share on other sites

I have a geometry sitting nicely in the default world coordinate system.

I have another 3 vectors defining another coordinate system.

How would I transform the geometry from one coordinate system to the other, so that it transforms and aligns appropriately?

If the vectors vn are unit length and independent (like the orthogonal sets in your image), then I think the only missing ingredient would be the translation vector -- the position at the origin of the system you're transforming to (say, o1) relative to the origin of the system you're transforming from; say o, both expressed in the same space of course). Then I believe the transform matrix (in a Houdini-friendly order), would be:

// translation vector
vector v3 = o1-o0;

// xfrom for points
matrix Mp = set( v0.x, v0.y, v0.z, 0,
                 v1.x, v1.y, v1.z, 0,
                 v2.x, v2.y, v2.z, 0,
                 v3.x, v3.y, v3.z, 1 );

// xfrom for vectors (strip translation)
matrix3 Mv = Mp;

// and for normals (strip translation and scaling)
matrix3 Mn = invert(Mv); 
transpose(Mn);

Then, to each element (point, vector, normal) that you want to transform, right-multiply it by the appropriate matrix -- eg p' = p*Mp, or v' = v*Mv, or n' = n*Mn

(untested)

HTH,

Cheers.

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...