"""
Implementation of an OmniGraph node that deforms a surface using a sine wave
"""
import numpy as np


class OgnDeformerYAxis:
    @staticmethod
    def compute(db):
        """Deform the input points by a multiple of the sine wave"""
        points = db.inputs.points
        multiplier = db.inputs.multiplier
        wavelength = db.inputs.wavelength
        offset = db.inputs.offset

        db.outputs.points_size = points.shape[0]
        # Nothing to evaluate if there are no input points
        if db.outputs.points_size == 0:
            return True
        output_points = db.outputs.points

        if wavelength <= 0:
            wavelength = 1.0

        pt = points.copy()  # we still need to do a copy here because we do not want to modify points
        tx = pt[:, 0]
        offset_tx = tx + offset

        disp = np.sin(offset_tx / wavelength)
        pt[:, 1] += disp * multiplier

        output_points[:] = pt[:]  # we modify output_points in memory so we do not need to set the value again
        return True
