# Change center point and size with the help of the Matrix in Unity

Let us suppose I have an array of Vector3, it contains vertices. Now I want to scale the vertices and/or change the center point of the texture (move texture relatively).

I have a Vector3 which is a new center point and I have a Vector3 which is vector for scaling along x, y and z.

How can I construct a needed matrix in Unity?

I am very new to all this, so, please, in case of any misunderstanding ask me about it.

Here is what I was able to find on my own. The problem with it, though, is that I can not infer what I need from it. I need a little bit more peculiar thing.

Why use a matrix for this at all?

Vector3 ScaleAndShiftVector(Vector3 v, Vector3 shift, Vector3 scale) {
return Vector3.Scale(v, scale) + shift;
}


You could do this with a matrix,

var matrix = Matrix4x4.TRS(shift, Quaternion.identity, scale);
var transformed = matrix.MultiplyPoint3x4(v);


but that does more calculations than you need, since it's accounting for rotation too which you're not using.

• It does not work somehow. I after modifying the vertex of the texture in this way the image does not change its size. – cutMeDown Jan 20 '18 at 11:08
• Textures don't have vertices. Meshes do. Are you manipulating the positions of a mesh's vertices, or its texture coordinates, or something else? Show your code in your question and we can help you find the error. – DMGregory Jan 20 '18 at 12:37