<commit_before>package org.team2471.frc.lib.motion_profiling;

import org.team2471.frc.lib.vector.Vector2;

import static org.team2471.frc.lib.motion_profiling.MotionKey.SlopeMethod.SLOPE_MANUAL;
import static org.team2471.frc.lib.motion_profiling.MotionKey.SlopeMethod.SLOPE_PLATEAU;

public class MotionKey {
    private transient final double CLAMPTOLERANCE = 0.005;
    private Vector2 m_timeAndValue;
    private Vector2 m_prevAngleAndMagnitude;
    private Vector2 m_nextAngleAndMagnitude;
    private Vector2 m_prevTangent;
    private Vector2 m_nextTangent;
    private SlopeMethod m_prevSlopeMethod;
    private SlopeMethod m_nextSlopeMethod;
    private boolean m_markBeginOrEndKeysToZeroSlope;
    private MotionKey m_nextKey;

    private transient MotionCurve m_motionCurve;
    private transient MotionKey m_prevKey;
    private transient boolean m_bTangentsDirty;
    private transient boolean m_bCoefficientsDirty;
    private transient CubicCoefficients1D m_xCoeff;
    private transient CubicCoefficients1D m_yCoeff;

    public MotionKey() {
        m_timeAndValue = new Vector2(0, 0);
        m_prevAngleAndMagnitude = new Vector2(0, 1);
        m_nextAngleAndMagnitude = new Vector2(0, 1);
        m_prevTangent = new Vector2(0, 0);
        m_nextTangent = new Vector2(0, 0);

        m_timeAndValue.set(0, 0);
        m_prevAngleAndMagnitude.set(0, 1);
        m_nextAngleAndMagnitude.set(0, 1);
        m_bTangentsDirty = true;
        m_bCoefficientsDirty = true;
        m_prevSlopeMethod = SlopeMethod.SLOPE_SMOOTH;
        m_nextSlopeMethod = SlopeMethod.SLOPE_SMOOTH;
        m_markBeginOrEndKeysToZeroSlope = true;
        m_motionCurve = null;
        m_nextKey = null;
        m_prevKey = null;
    }

    public void onPositionChanged() {
        getMotionCurve().onKeyPositionChanged(this);  // tell the curve too

        setTangentsDirty(true);
        setCoefficientsDirty(true);

        if (getPrevKey() != null) {
            getPrevKey().setTangentsDirty(true);
            getPrevKey().setCoefficientsDirty(true);
            if (getPrevKey().getPrevKey() != null && getPrevKey().getPrevKey().getNextSlopeMethod() == SLOPE_PLATEAU) {  // Need to go two away if it is Plateau because they use Prev and Next Tangents
                getPrevKey().getPrevKey().setTangentsDirty(true);
                getPrevKey().getPrevKey().setCoefficientsDirty(true);
            }
        }

        if (getNextKey() != null) {
            getNextKey().setTangentsDirty(true);
            if (getNextKey().getNextKey() != null && getNextKey().getNextKey().getPrevSlopeMethod() == SLOPE_PLATEAU) {  // Need to go two away if it is Plateau because they use Prev and Next Tangents
                getNextKey().getNextKey().setTangentsDirty(true);
                getNextKey().setCoefficientsDirty(true);
            }
        }
    }

    public double getTime() {
        return m_timeAndValue.getX();
    }

    public void setTime(double time) {
        m_timeAndValue.setX(time);
        onPositionChanged();
    }

    public double getValue() {
        return m_timeAndValue.getY();
    }

    public void setValue(double value) {
        m_timeAndValue.setY(value);
        onPositionChanged();
    }

    public boolean areTangentsDirty() {
        return m_bTangentsDirty;
    }

    public void setTangentsDirty(boolean bTangentsDirty) {
        m_bTangentsDirty = bTangentsDirty;
    }

    public boolean areCoefficientsDirty() {
        return m_bCoefficientsDirty;
    }

    public void setCoefficientsDirty(boolean bCoefficientsDirty) {
        m_bCoefficientsDirty = bCoefficientsDirty;
    }

    public Vector2 getTimeAndValue() {
        return m_timeAndValue;
    }

    public void setTimeAndValue(Vector2 m_timeAndValue) {
        this.m_timeAndValue = m_timeAndValue;
        onPositionChanged();
    }

    public Vector2 getPrevAngleAndMagnitude() {
        return m_prevAngleAndMagnitude;
    }

    public void setPrevAngleAndMagnitude(Vector2 m_prevAngleAndMagnitude) {
        m_markBeginOrEndKeysToZeroSlope = false;
        this.m_prevAngleAndMagnitude = m_prevAngleAndMagnitude;
        setTangentsDirty(true);
    }

    public Vector2 getNextAngleAndMagnitude() {
        return m_nextAngleAndMagnitude;
    }

    public void setNextAngleAndMagnitude(Vector2 m_nextAngleAndMagnitude) {
        m_markBeginOrEndKeysToZeroSlope = false;
        this.m_nextAngleAndMagnitude = m_nextAngleAndMagnitude;
        setTangentsDirty(true);
    }
<commit_msg>Allow tangent changes to work.<commit_after>package org.team2471.frc.lib.motion_profiling;

import org.team2471.frc.lib.vector.Vector2;

import static org.team2471.frc.lib.motion_profiling.MotionKey.SlopeMethod.SLOPE_MANUAL;
import static org.team2471.frc.lib.motion_profiling.MotionKey.SlopeMethod.SLOPE_PLATEAU;

public class MotionKey {
    private transient final double CLAMPTOLERANCE = 0.005;
    private Vector2 m_timeAndValue;
    private Vector2 m_prevAngleAndMagnitude;
    private Vector2 m_nextAngleAndMagnitude;
    private Vector2 m_prevTangent;
    private Vector2 m_nextTangent;
    private SlopeMethod m_prevSlopeMethod;
    private SlopeMethod m_nextSlopeMethod;
    private boolean m_markBeginOrEndKeysToZeroSlope;
    private MotionKey m_nextKey;

    private transient MotionCurve m_motionCurve;
    private transient MotionKey m_prevKey;
    private transient boolean m_bTangentsDirty;
    private transient boolean m_bCoefficientsDirty;
    private transient CubicCoefficients1D m_xCoeff;
    private transient CubicCoefficients1D m_yCoeff;

    public MotionKey() {
        m_timeAndValue = new Vector2(0, 0);
        m_prevAngleAndMagnitude = new Vector2(0, 1);
        m_nextAngleAndMagnitude = new Vector2(0, 1);
        m_prevTangent = new Vector2(0, 0);
        m_nextTangent = new Vector2(0, 0);

        m_timeAndValue.set(0, 0);
        m_prevAngleAndMagnitude.set(0, 1);
        m_nextAngleAndMagnitude.set(0, 1);
        m_bTangentsDirty = true;
        m_bCoefficientsDirty = true;
        m_prevSlopeMethod = SlopeMethod.SLOPE_SMOOTH;
        m_nextSlopeMethod = SlopeMethod.SLOPE_SMOOTH;
        m_markBeginOrEndKeysToZeroSlope = true;
        m_motionCurve = null;
        m_nextKey = null;
        m_prevKey = null;
    }

    public void onPositionChanged() {
        getMotionCurve().onKeyPositionChanged(this);  // tell the curve too

        setTangentsDirty(true);
        setCoefficientsDirty(true);

        if (getPrevKey() != null) {
            getPrevKey().setTangentsDirty(true);
            getPrevKey().setCoefficientsDirty(true);
            if (getPrevKey().getPrevKey() != null && getPrevKey().getPrevKey().getNextSlopeMethod() == SLOPE_PLATEAU) {  // Need to go two away if it is Plateau because they use Prev and Next Tangents
                getPrevKey().getPrevKey().setTangentsDirty(true);
                getPrevKey().getPrevKey().setCoefficientsDirty(true);
            }
        }

        if (getNextKey() != null) {
            getNextKey().setTangentsDirty(true);
            if (getNextKey().getNextKey() != null && getNextKey().getNextKey().getPrevSlopeMethod() == SLOPE_PLATEAU) {  // Need to go two away if it is Plateau because they use Prev and Next Tangents
                getNextKey().getNextKey().setTangentsDirty(true);
                getNextKey().setCoefficientsDirty(true);
            }
        }
    }

    public double getTime() {
        return m_timeAndValue.getX();
    }

    public void setTime(double time) {
        m_timeAndValue.setX(time);
        onPositionChanged();
    }

    public double getValue() {
        return m_timeAndValue.getY();
    }

    public void setValue(double value) {
        m_timeAndValue.setY(value);
        onPositionChanged();
    }

    public boolean areTangentsDirty() {
        return m_bTangentsDirty;
    }

    public void setTangentsDirty(boolean bTangentsDirty) {
        m_bTangentsDirty = bTangentsDirty;
    }

    public boolean areCoefficientsDirty() {
        return m_bCoefficientsDirty;
    }

    public void setCoefficientsDirty(boolean bCoefficientsDirty) {
        m_bCoefficientsDirty = bCoefficientsDirty;
    }

    public Vector2 getTimeAndValue() {
        return m_timeAndValue;
    }

    public void setTimeAndValue(Vector2 m_timeAndValue) {
        this.m_timeAndValue = m_timeAndValue;
        onPositionChanged();
    }

    public Vector2 getPrevAngleAndMagnitude() {
        return m_prevAngleAndMagnitude;
    }

    public void setPrevAngleAndMagnitude(Vector2 m_prevAngleAndMagnitude) {
        m_markBeginOrEndKeysToZeroSlope = false;
        this.m_prevAngleAndMagnitude = m_prevAngleAndMagnitude;
        m_prevSlopeMethod = SlopeMethod.SLOPE_MANUAL;
        setTangentsDirty(true);
        onPositionChanged();
    }

    public Vector2 getNextAngleAndMagnitude() {
        return m_nextAngleAndMagnitude;
    }

    public void setNextAngleAndMagnitude(Vector2 m_nextAngleAndMagnitude) {
        m_markBeginOrEndKeysToZeroSlope = false;
        this.m_nextAngleAndMagnitude = m_nextAngleAndMagnitude;
        m_nextSlopeMethod = SlopeMethod.SLOPE_MANUAL;
        setTangentsDirty(true);
        onPositionChanged();
    }

{'fraction_non_alphanumeric': 0.07861259106230292, 'fraction_numerical': 0.011960421876698924, 'mean_word_length': 3.0413005272407734, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '16228', 'n_tokens_mistral': 3122, 'n_tokens_neox': 2902, 'n_words': 536}