;+
; NAME:
;	V4METRIC
; PURPOSE:
;	Return the distance between two arbitrary four-vectors, in either
;	3-space or 4-space.
; CALLING SEQUENCE:
;	dist = V4METRIC(in1,in2,/verbose,units=units,dim=dim)
; INPUTS:
;	in1, in2 - V4 structures containing the co-ordinates to measure
; RETURNS:
;	The 3-distance or the 4-distance between the two points.
; KEYWORDS:
;	VERBOSE - Be chatty
;	UNITS - If present, V4MCART attempts to return a value in the units given.
;	 	If not defined, V4MCART sets this to the name of the units in which the
;		value is returned.
; 	DIM - Number specifying how many dimensions to use (2,3,4)
; METHOD:
;	We clean up the input vectors by translating them into the same coordinate
;	system and canonicalizing them, then call the appropriate metric functions
;	defined in their V4TYPE structures.
;
; CAVEATS:
;	Because some coordinate systems move with respect to others, the 3-space 
;	metric between points at different (Galilean) times is not well defined.
;	We measure the distance within the coordinate system of the first point.
;	For example, if in1 and in2 start out in Carrington spherical coordinates
;	and are at the same place but different times, then
;		vmcart(in1,in2)
;	will be zero.  But 
;		vmcart(v4xform(in1,'heliographic'),in2)
;	will be nonzero, because the spatial location of in1 is now assumed to be
;	stationary in heliographic coordinates, which are moving with respect to the 
;	carrington system in which in2 is specified.
;
;	(Of course, the foregoing doesn't apply to 4-metrics, which are invariant.)
;-
function v4metric,in1,in2,verbose=verbose,units=units,dim=dim

i1 = v4canon(in1)
i2 = v4canon(v4xform(in2,in1.(4)))

if(keyword_set(verbose) and (in1.(4) ne in2.(4))) then $
	print,"V4METRIC: WARNING- coordinates started out in different systems ('",$
		in1.(4),"' vs '",in2.(4),"'.)"

g = getv4type(in1.(4))
return,call_function(g.metric,in1,in2,verbose=verbose,units=units,dim=dim)
end




