# Move to origin and restore original position

## Recommended Posts

I know how to move an object to origin with transform node (with CEX CEY CEZ) but can't get how to restore original position after...

moveToOrigin_001.hipnc

##### Share on other sites
Posted (edited)

I think its better to use centroid rather than CEX. If you use centroid you will actually see values and not just "0".

centroid(0,D_X)

then you can duplicate the transform node and use the invert transformation button.

Edited by ejr32123
• 1

##### Share on other sites

Thanks! Working with a reference copy of the first transform.

moveToOrigin_002.hipnc

##### Share on other sites

just wright position to attribute and after moving to origin apply stored position attribute to @P;

• 1

##### Share on other sites
```// Get center of the oject bounding box (centroid)
vector min = {0, 0, 0};
vector max = {0, 0, 0};
getpointbbox(0, min, max);
vector centroid = (max + min)/2.0;

// Build and apply transformation matrix
vector translate = centroid;
vector rotate = {0,0,0};
vector scale = {1,1,1};
matrix xform = invert(maketransform(0, 0, translate, rotate, scale));
@P *= xform;

// Store transformation matrix in attribute
4@xform_matrix = xform;```

`@P *= invert(4@xform_matrix);`

move_to_origin_001.hipnc

• 1

##### Share on other sites
On 1/16/2019 at 9:38 PM, kiryha said:
```
// Get center of the oject bounding box (centroid)
vector min = {0, 0, 0};
vector max = {0, 0, 0};
getpointbbox(0, min, max);
vector centroid = (max + min)/2.0;

// Build and apply transformation matrix
vector translate = centroid;
vector rotate = {0,0,0};
vector scale = {1,1,1};
matrix xform = invert(maketransform(0, 0, translate, rotate, scale));
@P *= xform;

// Store transformation matrix in attribute
4@xform_matrix = xform;```

```
@P *= invert(4@xform_matrix);```

Hi, thanks for this and it's wonderful and works for particles.

However, it doesn't seem to centroid the rotation as well?

## Create an account

Register a new account