Vector.fromString constructor

Vector.fromString(
  1. String s
)

Implementation

Vector.fromString(String s) {
  final regex = RegExp(r'<(?<x>[^,]*),(?<y>[^,]*),(?<z>[^,]*)>');
  final match = regex.firstMatch(s);
  if (match != null) {
    _vector = Vector3d(
      X: double.parse(match.namedGroup('x') ?? '0'),
      Y: double.parse(match.namedGroup('y') ?? '0'),
      Z: double.parse(match.namedGroup('z') ?? '0'),
    );
  } else {
    _vector = Vector3d(X: 0, Y: 0, Z: 0);
  }
}