website

source code for the ttmaths.uk website
Log | Files | Refs | README

RotationTextElement.jsx (515B)


      1 import { trueMod } from "../scripts/mathsUtils"
      2 import Equation from "./Equation"
      3 
      4 export default function RotationTextElement({ angle }) {
      5 
      6   angle = trueMod(angle, 2*Math.PI)
      7   angle = Math.round(angle * 180 / Math.PI) // range 0 to 360
      8   let directionText = ""
      9   if (Math.abs(angle) == 180) { directionText = "" }
     10   else { directionText = angle < 180 ? 'clockwise' : 'anticlockwise' }
     11   angle = angle > 180 ? 360 - angle : angle
     12   return <span><Equation equation={angle + '\\degree'} /> {directionText}</span>
     13 }