You can you use vector math for this problem.
You have the position of the bucket b and you have the position and direction of the hose h
h
.
. .
v3 . .
. . v2
. . .
. phi . .
b .........x......
v1
The vector v3 = v1 + v2 (vector addition). It's a directional vector.
_____
v1 = x - b
_____
v2 = h - x
The angle phi you can determine by using the dot product within the following equation:
__ __
(v1 dot v3) where v3 is the inverse of v3
cos(phi) = -----------
__
|v1| * |v3| where |v1|, |v3| are the magnitudes of v1 and v3
This angle you can use to rotate your sprite in the appropriate way.
If you are in 3D space the operations are equivalent. You just have to introduce a third element to the vectors.