Let $A$ and $A' $ be fixed points on two equal circles in the plane and let $AB$ and $A' B'$  be arcs of these circles of the same length $x$. Find the locus of the midpoint of segment $BB'$ when $x$ varies:
(a) if the arcs have the same direction,
(b) if the arcs have opposite directions.
Let's break down the problem and solution step by step.

### Part (a): Arcs have the same direction

1. **Define the circles and points:**
   - Circle \( C_1 \) with equation \( x^2 + y^2 = r^2 \) centered at \( O(0,0) \).
   - Circle \( C_2 \) with equation \( (x-t)^2 + y^2 = r^2 \) centered at \( M(t,0) \).
   - Point \( A \) on \( C_1 \) such that \( \angle (OA, \text{x-axis}) = \alpha \).
   - Point \( A' \) on \( C_2 \) such that \( \angle (MA', \text{x-axis}) = \beta \).

2. **Parameterize the points \( A \) and \( A' \):**
   - \( A = (r \cos \alpha, r \sin \alpha) \)
   - \( A' = (t + r \cos \beta, r \sin \beta) \)

3. **Relate the angles \( \alpha \) and \( \beta \):**
   - Since the arcs have the same direction and the circles are equal, the angle \( \beta \) can be expressed as \( \beta = \alpha - \gamma \), where \( \gamma \) is a fixed angle.

4. **Parameterize the points \( B \) and \( B' \):**
   - \( B \) is a point on \( C_1 \) such that the arc \( AB \) has length \( x \). Thus, \( B = (r \cos (\alpha + \theta), r \sin (\alpha + \theta)) \), where \( \theta = \frac{x}{r} \).
   - \( B' \) is a point on \( C_2 \) such that the arc \( A'B' \) has length \( x \). Thus, \( B' = (t + r \cos (\beta + \theta), r \sin (\beta + \theta)) \).

5. **Find the midpoint of segment \( BB' \):**
   - The coordinates of the midpoint \( P \) of \( BB' \) are:
     \[
     P = \left( \frac{r \cos (\alpha + \theta) + t + r \cos (\beta + \theta)}{2}, \frac{r \sin (\alpha + \theta) + r \sin (\beta + \theta)}{2} \right)
     \]

6. **Simplify the expression for \( P \):**
   - Using \( \beta = \alpha - \gamma \), we get:
     \[
     P = \left( \frac{r \cos (\alpha + \theta) + t + r \cos (\alpha - \gamma + \theta)}{2}, \frac{r \sin (\alpha + \theta) + r \sin (\alpha - \gamma + \theta)}{2} \right)
     \]

7. **Use trigonometric identities to simplify further:**
   - The x-coordinate of \( P \):
     \[
     x_P = \frac{r (\cos (\alpha + \theta) + \cos (\alpha - \gamma + \theta)) + t}{2}
     \]
     Using the sum-to-product identities:
     \[
     \cos (\alpha + \theta) + \cos (\alpha - \gamma + \theta) = 2 \cos \left( \frac{2\alpha - \gamma + 2\theta}{2} \right) \cos \left( \frac{\gamma}{2} \right)
     \]
     Thus,
     \[
     x_P = \frac{2r \cos \left( \alpha + \theta - \frac{\gamma}{2} \right) \cos \left( \frac{\gamma}{2} \right) + t}{2}
     \]

   - The y-coordinate of \( P \):
     \[
     y_P = \frac{r (\sin (\alpha + \theta) + \sin (\alpha - \gamma + \theta))}{2}
     \]
     Using the sum-to-product identities:
     \[
     \sin (\alpha + \theta) + \sin (\alpha - \gamma + \theta) = 2 \sin \left( \alpha + \theta - \frac{\gamma}{2} \right) \cos \left( \frac{\gamma}{2} \right)
     \]
     Thus,
     \[
     y_P = r \sin \left( \alpha + \theta - \frac{\gamma}{2} \right) \cos \left( \frac{\gamma}{2} \right)
     \]

8. **Form the locus equation:**
   - The locus of the midpoint \( P \) is given by:
     \[
     \left( x - \frac{t}{2} \right)^2 + y^2 = r^2 \cos^2 \left( \frac{\gamma}{2} \right)
     \]

### Part (b): Arcs have opposite directions

1. **Relate the angles \( \alpha \) and \( \beta \):**
   - Since the arcs have opposite directions, the angle \( \beta \) can be expressed as \( \beta = \alpha + \gamma \), where \( \gamma \) is a fixed angle.

2. **Parameterize the points \( B \) and \( B' \):**
   - \( B = (r \cos (\alpha + \theta), r \sin (\alpha + \theta)) \)
   - \( B' = (t + r \cos (\beta - \theta), r \sin (\beta - \theta)) \)

3. **Find the midpoint of segment \( BB' \):**
   - The coordinates of the midpoint \( P \) of \( BB' \) are:
     \[
     P = \left( \frac{r \cos (\alpha + \theta) + t + r \cos (\beta - \theta)}{2}, \frac{r \sin (\alpha + \theta) + r \sin (\beta - \theta)}{2} \right)
     \]

4. **Simplify the expression for \( P \):**
   - Using \( \beta = \alpha + \gamma \), we get:
     \[
     P = \left( \frac{r \cos (\alpha + \theta) + t + r \cos (\alpha + \gamma - \theta)}{2}, \frac{r \sin (\alpha + \theta) + r \sin (\alpha + \gamma - \theta)}{2} \right)
     \]

5. **Use trigonometric identities to simplify further:**
   - The x-coordinate of \( P \):
     \[
     x_P = \frac{r (\cos (\alpha + \theta) + \cos (\alpha + \gamma - \theta)) + t}{2}
     \]
     Using the sum-to-product identities:
     \[
     \cos (\alpha + \theta) + \cos (\alpha + \gamma - \theta) = 2 \cos \left( \alpha + \frac{\gamma}{2} \right) \cos \left( \theta - \frac{\gamma}{2} \right)
     \]
     Thus,
     \[
     x_P = \frac{2r \cos \left( \alpha + \frac{\gamma}{2} \right) \cos \left( \theta - \frac{\gamma}{2} \right) + t}{2}
     \]

   - The y-coordinate of \( P \):
     \[
     y_P = \frac{r (\sin (\alpha + \theta) + \sin (\alpha + \gamma - \theta))}{2}
     \]
     Using the sum-to-product identities:
     \[
     \sin (\alpha + \theta) + \sin (\alpha + \gamma - \theta) = 2 \sin \left( \alpha + \frac{\gamma}{2} \right) \cos \left( \theta - \frac{\gamma}{2} \right)
     \]
     Thus,
     \[
     y_P = r \sin \left( \alpha + \frac{\gamma}{2} \right) \cos \left( \theta - \frac{\gamma}{2} \right)
     \]

6. **Form the locus equation:**
   - The locus of the midpoint \( P \) is given by:
     \[
     \left( x - \frac{t}{2} \right)^2 + y^2 = r^2 \cos^2 \left( \frac{\gamma}{2} \right)
     \]

The final answer is \( \boxed{ \left( x - \frac{t}{2} \right)^2 + y^2 = r^2 \cos^2 \left( \frac{\gamma}{2} \right) } \)