PI :: 3.1415926; TAU :: 6.2831853; #if UNITS == .turns { to_rad :: turn_to_rad; from_rad :: rad_to_turn; } else #if UNITS == .radians { to_rad :: rad_to_rad; from_rad :: rad_to_rad; } else #if UNITS == .degrees { to_rad :: deg_to_rad; from_rad :: rad_to_deg; } turn_to_rad :: (turns: float64) -> float #expand #no_debug { CONSTANT :float64: PI*2.0; return cast(float)(CONSTANT*turns); } turn_to_rad :: (turns: float) -> float #expand #no_debug { CONSTANT :float: xx PI*2.0; return CONSTANT*turns; } deg_to_rad :: (deg: float64) -> float #expand #no_debug { CONSTANT :float64: PI/180.0; return cast(float)(CONSTANT*deg); } deg_to_rad :: (deg: float) -> float #expand #no_debug { CONSTANT :float: xx (PI/180.0); return CONSTANT*deg; } rad_to_rad :: (rad: float64) -> float #expand #no_debug { return cast(float)rad; } rad_to_rad :: (rad: float) -> float #expand #no_debug { return rad; } rad_to_turn :: (rad: float64) -> float #expand { CONSTANT :float64: (1.0/(PI*2.0)); return cast(float)(CONSTANT*rad); } rad_to_turn :: (rad: float) -> float #expand { CONSTANT :float: xx (1.0/(PI*2.0)); return CONSTANT*rad; } rad_to_deg :: (rad: float64) -> float #expand { CONSTANT :float64: (180.0/PI); return cast(float)(CONSTANT*rad); } rad_to_deg :: (rad: float) -> float #expand { CONSTANT :float: xx (180.0/PI); return CONSTANT*rad; } sin :: (ang: float) -> float #expand { return math.sin(to_rad(ang)); } cos :: (ang: float) -> float #expand { return math.cos(to_rad(ang)); } atan2 :: (y: float, x: float) -> float #expand { return from_rad(math.atan2(y, x)); } asin :: (ang: float) -> float #expand { return from_rad(math.asin(ang)); } abs :: (v: $T) -> T #modify { return meta.type_is_scalar(T), "Only accepting scalar types, integer and float"; } { return ifx v < 0 then -v else v; } #scope_file // sin, cos meta :: #import "jc/meta"; math :: #import "Math";