Skip to content

Commit

Permalink
add unit circle exercises (#94)
Browse files Browse the repository at this point in the history
  • Loading branch information
rakilkim committed May 26, 2024
1 parent dbf9763 commit 129ecf3
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 33 deletions.
13 changes: 8 additions & 5 deletions src/components/shared/ExerciseSide.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -220,17 +220,20 @@ ExerciseSideProps): JSX.Element {
unitCircleMarkers={[
['-90\xB0', '-45\xB0', '0\xB0', '45\xB0', '90\xB0'],
['-90\xB0', '-45\xB0', '0\xB0', '45\xB0', '90\xB0'],
['-90\xB0', '-45\xB0', '0\xB0', '45\xB0', '90\xB0'],
['-90\xB0', '-60\xB0', '-30\xB0', '0\xB0', '30\xB0', '60\xB0', '90\xB0'],
['-90\xB0', '-60\xB0', '-30\xB0', '0\xB0', '30\xB0', '60\xB0', '90\xB0'],
]}
unitCircleLabels={[
['A', 'C', '', 'B', ''],
['B', 'A', '', 'C', ''],
['', '', 'C', 'A', 'B'],
['', 'A', 'B', '', 'C'],
['', '', 'A', 'B', '', 'C', ''],
['', 'A', '', '', 'B', '', 'C'],
]}
directions={[
['left', 'right', '', 'right', ''],
['left', 'left', '', 'left', ''],
['', '', 'right', 'right', 'left'],
['', 'left', 'left', '', 'left'],
['', '', 'right', 'left', '', 'right', ''],
['', 'right', '', '', 'right', '', 'left'],
]}
toNextExercise={() => {
setDisplayExercise(displayExercise + 1);
Expand Down
49 changes: 21 additions & 28 deletions src/components/shared/Exercises/UnitCircleExercise.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -37,22 +37,20 @@ function UnitCircleExercise({
<div
className="circle-exercise"
style={{
left: `${
(1 - Math.cos(curAngle)) * 31 + //middle right and left
left: `${(1 - Math.cos(curAngle)) * 31 + //middle right and left
(curAngle <= Math.PI / 2
? curAngle == Math.PI / 2
? 17 //middle
: 19 //left
: 14) //right
}%`,
bottom: `${
Math.sin(curAngle) * 53 + //middle right and left
}%`,
bottom: `${Math.sin(curAngle) * 53 + //middle right and left
(curAngle <= Math.PI / 2
? curAngle == Math.PI / 2
? 28 //middle
: 25 //left
: 25) //right
}%`,
}%`,
}}
>
{element}
Expand All @@ -61,56 +59,51 @@ function UnitCircleExercise({
<div
className="circle-label"
style={{
left: `${
(1 - Math.cos(curAngle)) * 30 + //middle left and right
left: `${(1 - Math.cos(curAngle)) * 30 + //middle left and right
(curAngle <= Math.PI / 2
? curAngle == Math.PI / 2
? 19 //middle
: 20 //left
: 17 //left
: 15) //right
}%`,
bottom: `${
Math.sin(curAngle) * 55 + //middle left and right
}%`,
bottom: `${Math.sin(curAngle) * 55 + //middle left and right
(curAngle <= Math.PI / 2
? curAngle == Math.PI / 2
? 30 //middle
: 25 //left
: 25) //right
}%`,
}%`,
}}
>
{markers[idx]}
</div>
) : null}

<img
src={Cursor}
className="circle-cursor"
style={{
left: `${
(1 - Math.cos(cursorAngle)) * 43 +
left: `${(1 - Math.cos(cursorAngle)) * 43 +
(cursorAngle <= Math.PI / 2
? cursorAngle == Math.PI / 2
? 5
: 7
: 2)
}%`,
bottom: `${
Math.sin(cursorAngle) * 80 +
: 6
: 6)
}%`,
bottom: `${Math.sin(cursorAngle) * 80 +
(cursorAngle <= Math.PI / 2
? cursorAngle == Math.PI / 2
? 25
: 28
: 28)
}%`,
transform: `rotate(${cursorAngle}rad) ${
labels.length % 2 === 1 &&
: 27)
}%`,
transform: `rotate(${cursorAngle}rad) ${labels.length % 2 === 1 &&
idx === Math.floor(labels.length / 2)
? scaleCursor
: ''
}`,
? scaleCursor
: ''
}`,
}}
></img>

</div>
);
})}
Expand Down

0 comments on commit 129ecf3

Please sign in to comment.