# How to remove the matrix effect

**URL:** <https://discourse.threejs.org/t/how-to-remove-the-matrix-effect/21376>\
**Category:** Questions\
**Tags:** math\
**Created:** [December 9, 2020, 4:48am UTC](https://discourse.threejs.org/t/how-to-remove-the-matrix-effect/21376 "2020-12-09T04:48:38Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![Alex](https://yyz1.discourse-cdn.com/flex035/user_avatar/discourse.threejs.org/alex/32/9027_2.png) [@Alex](https://discourse.threejs.org/u/Alex)\
**Post date:** [December 9, 2020, 4:48am UTC](https://discourse.threejs.org/t/how-to-remove-the-matrix-effect/21376/1 "2020-12-09T04:48:38Z")

</div>

Hello Three js team,

A quick help please. I want to know how we can remove the applied matrix from an vector.

Like

vector3 = vector3.applyMatrix4(matrix)

now vector3 have some matrix4 effect and i noticed my x,y,z also updated i want to redo this effect means

something like vector3.redo…

so i get back my original vector3

Thanks

---

<div class="post-metadata">

**Author:** ![mjurczyk](https://yyz1.discourse-cdn.com/flex035/user_avatar/discourse.threejs.org/mjurczyk/32/10995_2.png) [@mjurczyk](https://discourse.threejs.org/u/mjurczyk)\
**Post date:** [December 9, 2020, 4:55am UTC](https://discourse.threejs.org/t/how-to-remove-the-matrix-effect/21376/2 "2020-12-09T04:55:09Z")

</div>

Vector methods mutate the source vector (ex. `vector.add(vector2)` will change the original vector.)  
You can use `clone()` to preserve the original vector.

```javascript
const vectorA = new THREE.Vector3(1.0, 2.0, 3.0);
const vectorB = vectorA.clone().applyMatrix4(matrix); // vectorA will remain untouched

```

---

<div class="post-metadata">

**Author:** ![Alex](https://yyz1.discourse-cdn.com/flex035/user_avatar/discourse.threejs.org/alex/32/9027_2.png) [@Alex](https://discourse.threejs.org/u/Alex)\
**Post date:** [December 9, 2020, 4:58am UTC](https://discourse.threejs.org/t/how-to-remove-the-matrix-effect/21376/3 "2020-12-09T04:58:24Z")

</div>

No this is not i am looking for. Actually i am taking some points and applying the matrix4 to place them properly in the model. Now my task is to again save them back to the db but for this i have to remove the applied matrix effects.

Is there any way to redo the matrix effect ?

An example

This is my vector point  
{x: -1973.239999999998, y: 1731.13836, z: 15}

This is my matrix

{  
“elements”: [  
0.8660254037844387,  
0.49999999999999994,  
0,  
0,  
-0.49999999999999994,  
0.8660254037844387,  
0,  
0,  
0,  
0,  
1,  
0,  
-348.7943970038309,  
-5653.1347137137145,  
0,  
1  
]  
}

This is my transformed point

{  
“x”: -2923.239544767435,  
“y”: -5140.544916487983,  
“z”: 15  
}

I want to transform this transformed point back to the vector point

---

<div class="post-metadata">

**Author:** ![mjurczyk](https://yyz1.discourse-cdn.com/flex035/user_avatar/discourse.threejs.org/mjurczyk/32/10995_2.png) [@mjurczyk](https://discourse.threejs.org/u/mjurczyk)\
**Post date:** [December 9, 2020, 5:25am UTC](https://discourse.threejs.org/t/how-to-remove-the-matrix-effect/21376/4 "2020-12-09T05:25:31Z")

</div>

See [this thread](https://math.stackexchange.com/questions/876685/how-to-reverse-matrix-vector-multiplication) as to whether it is something you should be aiming for performance-wise (instead of just saving the original coordinates to `point.userData`.)

Three does have a [Matrix4.invert()](https://github.com/mrdoob/three.js/blob/9694de0fb9d9e45f36b2943642d534365e6d5965/src/math/Matrix4.js#L486%5D) method (in earlier builds it’s `Matrix4.toInverse`.)

---

<div class="post-metadata">

**Author:** ![Alex](https://yyz1.discourse-cdn.com/flex035/user_avatar/discourse.threejs.org/alex/32/9027_2.png) [@Alex](https://discourse.threejs.org/u/Alex)\
**Post date:** [December 9, 2020, 6:19am UTC](https://discourse.threejs.org/t/how-to-remove-the-matrix-effect/21376/5 "2020-12-09T06:19:30Z")

</div>

@mjurczyk thanks, i thought this was a solution but you gave me confidence and i put in my code it works.

Thanks a lot
