DragModel constructor

DragModel({
  1. required double bc,
  2. required List dragTable,
  3. Weight? weight,
  4. Distance? diameter,
  5. Distance? length,
})

Implementation

DragModel({
  required this.bc,
  required List<dynamic> dragTable,
  Weight? weight,
  Distance? diameter,
  Distance? length,
}) : dragTable = makeDataPoints(dragTable),
     weight = weight ?? Weight.grain(0),
     diameter = diameter ?? Distance.inch(0),
     length = length ?? Distance.inch(0) {
  if (this.dragTable.isEmpty) {
    throw ArgumentError('Received empty drag table');
  }
  if (bc <= 0) throw ArgumentError('Ballistic coefficient must be positive');

  if (this.weight.raw > 0 && this.diameter.raw > 0) {
    sectionalDensity = _getSectionalDensity();
    formFactor = _getFormFactor(bc);
  } else {
    sectionalDensity = 0.0;
    formFactor = 0.0;
  }
}