convertToRadians static method

double convertToRadians(
  1. VoltronMap transformMap,
  2. String key
)

Implementation

static double convertToRadians(VoltronMap transformMap, String key) {
  var value = 0.0;
  var inRadians = true;
  final valueTmp = transformMap.get(key);
  if (valueTmp is String) {
    var stringValue = valueTmp;
    if (stringValue.endsWith("rad")) {
      stringValue = stringValue.substring(0, stringValue.length - 3);
    } else if (stringValue.endsWith("deg")) {
      inRadians = false;
      stringValue = stringValue.substring(0, stringValue.length - 3);
    }
    value = double.parse(stringValue);
  } else if (valueTmp is num) {
    value = valueTmp.toDouble();
  }
  return inRadians ? value : MatrixUtil.degreesToRadians(value);
}