# Getting object positions relative to another object's local space?

UPDATE =================================

Thanks to Insanto and Anubis I have found two ways to do what I needed below!

1. theCoords = (\$Box01.transform * (inverse \$Plane01.transform)).pos
2. theCoords = in coordsys \$Plane01 \$Box01.pos

========================================

Hello, I'm having trouble getting object's positions relative to another object's rotation & position (transform). See example below:

I'm trying to get the coordinates of this box relative to this plane's local coordinates. The XYZ coords it should return in this case would be (0,-20,-25).

I have tried
in coordsys \$Plane01 \$Box01

but it returns the value of the Box's coordinates in world space.. something like (0, 3.536, 46.481)

I've managed to move the box in Plane01's world space using in coordsys \$Plane01 move \$Box01 [0,0,1] which is a tease but this is not what I need. Did I miss something here? I've looked all over in the documentation. I've included the example scene. Thanks for any help!

## Comment viewing options

### (b.transform * (inverse

(b.transform * (inverse p.transform)).pos

Raphael 'Insanto' Steves
http://Graph.Net84.Net

### Brilliant!! I think this

Brilliant!! I think this method provides great insight as to how the position is calculated. Thank you so much!

- Dru

### I dont see scene attached but

I dont see scene attached but with the next code I hope you will see what you miss ;)

```--// scene setup...
p = plane width:60 length:60
b = box width:10 height:10 length:10
b.pos = [10,20,0]
b.parent = p
p.rotation.x_rotation += 22

--// test #1
b.pos -->> [10,18.5437,7.49213]
in coordsys p b.pos -->> [10,20,0]
--// Works OK

--// test #2
b.parent = undefined
b.pos -->> [10,18.5437,7.49213]
in coordsys p b.pos -->> [10,20,0]
--// Works OK```

my recent MAXScripts RSS (archive here)

### Awesome, Thank YOU!!! Looks

Awesome, Thank YOU!!! Looks like I missed ".pos" when doing my tests(doh!). I knew this forum and members like you would help me see the light!. Thank you!

- Dru

### I've created this hack, but I

I've created this hack, but I think it's a bit sloppy. There has to be a better way..

fn translatePosition theObject theTargetObject =
(
local helperDummy = dummy()
helperDummy.transform = theObject.transform
helperDummy.controller = lc