import math


def straightness_imperfection(z, length, delta_global, oos_axis, **kwargs):
    """ Returns the out-of-straightness imperfection of the node.

    :param float z: z coordinate of node
    :param float length: total length of the component
    :param float delta_global: maximum amplitude of the out-of-straightness global imperfection
    :param np.ndarray oos_axis: direction of out-of-straightness wrt to the global coordinates
    :return list: [float] nodal imperfection [x, y, z] in the global coordinates

    Notes:
        - Assumes that the z-direction is along the length of the member
    """
    w = -1.0 * (math.cos(2.0 * math.pi * z / length) - 1.0) * delta_global / 2.
    return list(w * oos_axis)