Skip to content

Commit

Permalink
fix: added log for matching sine curves
Browse files Browse the repository at this point in the history
  • Loading branch information
FeroxFoxxo committed Aug 5, 2024
1 parent da96b61 commit 86b515d
Showing 1 changed file with 9 additions and 7 deletions.
16 changes: 9 additions & 7 deletions app/ui/engineer/SineGraph.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,12 +20,13 @@ export default function SineGraph(sineMatch) {
const increment = 0.2;

const delay = 10;
const amount = 5;

const [magnitude, setMagnitude] = useState(magChange);
const [phase, setPhase] = useState(phaseChange);
const [frequency, setFrequency] = useState(freqChange);
const [magnitude, setMagnitude] = useState(magChange * amount);
const [phase, setPhase] = useState(phaseChange * amount);
const [frequency, setFrequency] = useState(freqChange * amount);

const length = Math.floor((end - start) / increment);
const length = Math.floor((end - start) / increment) + 1;

const debouncedSetMagnitude = useCallback(debounce((value) => {
setMagnitude(value);
Expand All @@ -42,9 +43,9 @@ export default function SineGraph(sineMatch) {
}

const staticData = useMemo(() => {
const staticMagnitude = magChange * getRandomInt(start + 1, end)
const staticPhase = phaseChange * getRandomInt(start + 1, end)
const staticFrequency = freqChange * getRandomInt(start + 1, end)
const staticMagnitude = magChange * getRandomInt(start + 1, end - 1)
const staticPhase = phaseChange * getRandomInt(start + 1, end - 1)
const staticFrequency = freqChange * getRandomInt(start + 1, end - 1)

const labels = Array.from({ length }, (_, i) => start + i * increment);
const values = labels.map(x => staticMagnitude * Math.sin(staticFrequency * (x + staticPhase)));
Expand Down Expand Up @@ -148,6 +149,7 @@ export default function SineGraph(sineMatch) {
const frequencyMatch = frequencyDiff <= frequencyTolerance;

if (magnitudeMatch && phaseMatch && frequencyMatch) {
console.log("Matched sine curves!");
sineMatch();
}
},[magnitude, phase, frequency])
Expand Down

0 comments on commit 86b515d

Please sign in to comment.