You will also need to determine if the dimension is Horizontal or Vertical or Aligned and the line location ..
... this can't be done simply from a predetermined set of points.
Dimensioning is simple once these parameters are determined
unfortunately for programming, they are usually best determined by a rational mind.
HOWEVER ;
If you're dimensioning parametric shapes where the configuration can be predetermined you may be joyfull.