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!

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

Example here : c# - How to Calculate Centroid - Stack Overflow (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;
```