about the st_distance function in Postgis

the dependencies as I understand them in the file measures.c:

to get the points out of the function from where the distance is measured between I think two things have to be done.

1) find a way to "transport" the point-values back from distance2d_pt_pt to lwgeom_mindistance2d_recursive
and back to some new function wich will come with the request.
I don't know C but I guess it would be possible to add the distance and the two points in an array something like
array[3] = ("min_distance","point1","point2") and then access array[0] instead of the today variable dist or min_dist or whatever.

2) If one of the points is not a vertice but somewhere inbetween that point will not be identified in the function distance2d_pt_seg.
Instead the distance will be calculated liek this: s = ( (A->y-p->y)*(B->x-A->x)- (A->x-p->x)*(B->y-A->y) ) /
( (B->x-A->x)*(B->x-A->x) +(B->y-A->y)*(B->y-A->y) );

return LW_ABS(s) * sqrt(
(B->x-A->x)*(B->x-A->x) + (B->y-A->y)*(B->y-A->y)
);

But to check if a vertice or a point between two vertices is closest to the other geometry the r-value is already calculated.
The r-value tells us how var from vertice A this closest opint is. Therefor it should be possible to get that "new" point C like this instead:
C->x=A->x + r(B->x-A->x)
C->y=A->y + r(B->y-A->y)
then I guess there is som point-constructor
After that we can send the points to distance2d_pt_pt.


a few questions:
1) will this handling of the points affect the performance.
If thats the case I guess the functions need to be duplicated so the ordinary st_distance function won't be affected. 2) is it opssible to put different datatypes like double precision and poonts in the sama array? 3) How to make a point out o C->x and C->y 4)