PDA

View Full Version : Convert coordinates from world space to local/parent space


MrSparkle
02-07-2006, 09:09 PM
Hi!
I'm new to MaxScript and I'm looking for a way to convert coordinates from world space into an object's local coordinate system. For example, selecting a point by p1 = pickPoint() always returns the coordinates of p1 in world space coordinates. How can I convert p1 that it's coordinates refer to the currently selected object?
Thank you!
Chris

Bobo
02-07-2006, 09:40 PM
Hi!
I'm new to MaxScript and I'm looking for a way to convert coordinates from world space into an object's local coordinate system. For example, selecting a point by p1 = pickPoint() always returns the coordinates of p1 in world space coordinates. How can I convert p1 that it's coordinates refer to the currently selected object?
Thank you!
Chris

Multiply the point with the inverse of the object's transformation matrix.

p1 = pickPoint()
p1 *= inverse yourObject.transform

Rule of thumb:

Local Point * yourObject.transform -> world coordinates
World Point * inverse yourObject.transform -> back to local

MrSparkle
02-08-2006, 04:51 AM
Thank you! You helped me very much! :)

CGTalk Moderation
02-08-2006, 04:51 AM
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.