# Bring 3 Vector 3s together

I'm dealing with a scenario where I have 3 Vector3 stored in variables. I need to be able to "contract" those 3 points together, as well as expand them.

Please see example image below. This is happening in a 3D space and the 3 points can be at any position and the whole triangle might be rotated too (although all 3 points would have the same rotation).

I am able to get the scale to shrink by multiplying the points by a decimal. However this has the negative effect of leaving the triangle completely.

Any help is appreciated!

**Answer** by Hellium
·
Jul 03, 2018 at 02:28 PM

Compute the point to use so as to shrink the triangle (can be the centroid or any other point)

Example here : https://stackoverflow.com/questions/9815699/how-to-calculate-centroidanswer-19750258 (need to be adapted to take `Vector2`

instead of `PointF`

)

Then, compute the new position from the centroid:

```
Vector2 centroid = GetCentroid( new List<Vector2>() { pointA, pointB, pointC } ) ;
Vector2 centroidToA = pointA - centroid ;
Vector2 centroidToB = pointB - centroid ;
Vector2 centroidToC = pointC - centroid;
pointA = centroid + centroidToA.normalized * centroidToA.magnitude * percentage;
pointB = centroid + centroidToB.normalized * centroidToB.magnitude * percentage;
pointC = centroid + centroidToC.normalized * centroidToC.magnitude * percentage;
```

### Your answer

### Welcome to Unity Answers

The best place to ask and answer questions about development with Unity.

To help users navigate the site we have posted a site navigation guide.

If you are a new user to Unity Answers, check out our FAQ for more information.

Make sure to check out our Knowledge Base for commonly asked Unity questions.

If you are a moderator, see our Moderator Guidelines page.

We are making improvements to UA, see the list of changes.

### Follow this Question

### Related Questions

how to calculate the angle between two vectors? 6 Answers

Applying direction into transform position 0 Answers

Non physics determinism of floating point math across platforms 1 Answer

Unity plane constructor bug? 1 Answer

How to calculate next camera position to look at the object that changed rotation 1 Answer