import { DangerZone } from "expo" ; const { Animated } = DangerZone ; const { Value , cond , eq , add , sqrt , or , neq , pow , sub , and , greaterThan , modulo , greaterOrEq , lessOrEq , multiply , lessThan , divide , abs , cos , sin , } = Animated ; type Value = typeof Value ; type MixedValue = Value | number ; export const toRad = ( deg ) : MixedValue => multiply ( deg , Math . PI / 180 ) ; export const toDeg = ( rad ) : MixedValue => multiply ( rad , 180 / Math . PI ) ; export const atan = ( x ) : Value => sub ( multiply ( Math . PI / 4 , x ) , multiply ( multiply ( x , sub ( abs ( x ) , 1 ) ) , add ( 0.2447 , multiply ( 0.0663 , abs ( x ) ) ) ) ) ; export const atan2 = ( y , x ) : Value => { const coeff1 = Math . PI / 4 ; const coeff2 = 3 * coeff1 ; const absY = abs ( y ) ; const angle = cond ( greaterOrEq ( x , 0 ) , [ sub ( coeff1 , multiply ( coeff1 , divide ( sub ( x , absY ) , add ( x , absY ) ) ) ) , ] , [ sub ( coeff2 , multiply ( coeff1 , divide ( add ( x , absY ) , sub ( absY , x ) ) ) ) , ] ) ; return cond ( lessThan ( y , 0 ) , multiply ( angle , - 1 ) , angle ) ; } ;