private int vectorToPoint (LuaCallFrame callFrame, int nArguments) {
        BaseLib.luaAssert(nArguments >= 2, "insufficient arguments for VectorToPoint");
        ZonePoint a = (ZonePoint)callFrame.get(0);
        ZonePoint b = (ZonePoint)callFrame.get(1);
        double bearing = ZonePoint.angle2azimuth(b.bearing(a));
        double distance = b.distance(a);
        callFrame.push(LuaState.toDouble(distance));
        callFrame.push(LuaState.toDouble(bearing));
        return 2;
    }
Distance object's fake GetValue or __call method

Called from Lua code: dist:GetValue("metres") or dist("ft"),
where 'dist' is double, converts the number to specified units
and returns as double.
main/src/main/java/cgeo/geocaching/wherigo/openwig/WherigoLib.java