Storing values vs recalculating them.

Hello everyone,
Im working on some code and ive been wondering if it`s better to store as much values as i can in a class, to do less math later on, or to just store as few as possible, and do a lot of math later on?

So here is an example of what i mean :
I have Triangles. Should i store only their center positions, and then calculate their distance to their neighbors everytime i need, or should i store their distance and never have to recalculate that again?
The positions do not ever change.

using UnityEngine;

public class StuffMaker : MonoBehaviour
{
        private Triangle[] myArray;

        void Start ()
        {
                Triangle = new Triangle[1000];
        }

        void DoStuff (int i, int j)
        {
                float distance = Vector2.Distance(myArray[i].centerPosition, myArray[j].centerPosition);
                // Do some stuff with that distance value.
        }
}

public class Triangle
{
        public Vector2 centerPosition;
}

Or should this be done instead?

using UnityEngine;

public class StuffMaker : MonoBehaviour
{
        private Triangle[] myArray;

        void Start ()
        {
                Triangle = new Triangle[1000];
                for (int i = 0; i < 1000; i++) {
                        for (int j = 0; j < 3; j++) {
                                myArray[i].distance[j] = Vector2.Distance(myArray[i].centerPosition, myArray[j].centerPosition);
                        }
                }
        }

        void DoStuff (int i, int j)
        {
                float distance = myArray[i].distance[j];
                // Do some stuff with that distance value.
        }
}

public class Triangle
{
        public Vector2 centerPosition;
        public float[] distance;
}

In other words, is it better to store some value, or to recalculate it every time i need it?
The DoStuff () function is called quite a lot but there are also a lot of triangles.

Thank you very much!

This seems somewhat like ‘premature optimization’, worrying yourself over some ‘non-critical’ part of your program. You spend a long time on this, and make no real progress.
The typical advice is to just do what works, then use the profiler later to see where you can save cycles.

There’s no doubt that pre-computing large data sets is beneficial, but is your situation big enough to make a difference? You can only know once the rest of your program is up and running