def wing_get_normal(wing, time):
    phi = wing.rolling(time)
    theta = wing.pitching(time)
    points = numpy.array([[0.0, 0.0, 0.0],
                          [0.5, 0.0, 0.5],
                          [-0.5, 0.0, 0.5]]).T
    x, y, z = rodney.vrotation(*points,
                               roll=phi, pitch=theta,
                               center=wing.hook)
    p1, p2, p3 = numpy.array([x, y, z]).T

    v1 = (p1 - p2) / numpy.linalg.norm(p1 - p2)
    v2 = (p3 - p1) / numpy.linalg.norm(p3 - p1)
    v3 = numpy.cross(v1, v2)
    return v3 / numpy.linalg.norm(v3)
    times = [float(t_str) for t_str in list(infile['p'].keys())]

# Initialize array to contain hydrodynamic power for each time recording.
P_hydro = numpy.empty_like(times)

# Compute the hydrodynamic power over the time records.
for i, time in enumerate(times):
    print(f'[t/T = {time / T:.6f}] Computing hydrodynamic power ...')

    # Get the rolling and pitching angles.
    phi = wing.rolling(time)
    theta = wing.pitching(time)
    # Rotate the reference points (to next compute the unit normal).
    points = Point(*rodney.vrotation(points0.x,
                                     points0.y,
                                     points0.z,
                                     roll=phi,
                                     pitch=theta,
                                     center=wing.hook))
    # Compute the unit normal vector.
    n = get_normal(*points.asarray())

    # Update the position and velocity of the body.
    wing.update_position(time)

    # Interpolate the pressure on the virtual boundary.
    p = interpolate_pressure(*wing.get_coordinates(), time, datadir)

    # Get the normal for each marker on the virtual boundary.
    n = numpy.concatenate(
        (numpy.tile(-n,
                    (wing.size // 2, 1)), numpy.tile(+n, (wing.size // 2, 1))))