import { useState, useEffect, useCallback } from "react"; import "./PhysicsSimulationBox.scss"; export interface IWedgeProps { startHeight: number; startWidth: number; startLeft: number; } export const Wedge = (props: IWedgeProps) => { const { startHeight, startWidth, startLeft } = props; const [angleInRadians, setAngleInRadians] = useState( Math.atan(startHeight / startWidth) ); const [left, setLeft] = useState(startLeft); const [coordinates, setCoordinates] = useState(""); const color = "#deb887"; useEffect(() => { const coordinatePair1 = Math.round(left) + "," + Math.round(window.innerHeight * 0.8) + " "; const coordinatePair2 = Math.round(left + startWidth) + "," + Math.round(window.innerHeight * 0.8) + " "; const coordinatePair3 = Math.round(left) + "," + Math.round(window.innerHeight * 0.8 - startHeight); const coord = coordinatePair1 + coordinatePair2 + coordinatePair3; setCoordinates(coord); }, [left, startWidth, startHeight]); useEffect(() => { setAngleInRadians(Math.atan(startHeight / startWidth)); }, [startWidth, startHeight]); return (
{Math.round(((angleInRadians * 180) / Math.PI) * 100) / 100}°