diff --git a/packages/vector_math/lib/src/vector_math/aabb2.dart b/packages/vector_math/lib/src/vector_math/aabb2.dart index bef9e02..9d29f2f 100644 --- a/packages/vector_math/lib/src/vector_math/aabb2.dart +++ b/packages/vector_math/lib/src/vector_math/aabb2.dart @@ -43,10 +43,9 @@ class Aabb2 { Vector2 get max => _max; /// The center of the AABB. - Vector2 get center => - _min.clone() - ..add(_max) - ..scale(0.5); + Vector2 get center => _min.clone() + ..add(_max) + ..scale(0.5); /// Set the AABB by a [center] and [halfExtents]. void setCenterAndHalfExtents(Vector2 center, Vector2 halfExtents) { @@ -109,17 +108,15 @@ class Aabb2 { /// Create a copy of this that is transformed by the transform [t] and store /// it in [out]. - Aabb2 transformed(Matrix3 t, Aabb2 out) => - out - ..copyFrom(this) - ..transform(t); + Aabb2 transformed(Matrix3 t, Aabb2 out) => out + ..copyFrom(this) + ..transform(t); /// Create a copy of this that is rotated by the rotation matrix [t] and /// store it in [out]. - Aabb2 rotated(Matrix3 t, Aabb2 out) => - out - ..copyFrom(this) - ..rotate(t); + Aabb2 rotated(Matrix3 t, Aabb2 out) => out + ..copyFrom(this) + ..rotate(t); /// Set the min and max of this so that this is a hull of this and /// [other]. diff --git a/packages/vector_math/lib/src/vector_math/aabb3.dart b/packages/vector_math/lib/src/vector_math/aabb3.dart index 12176d1..473fd58 100644 --- a/packages/vector_math/lib/src/vector_math/aabb3.dart +++ b/packages/vector_math/lib/src/vector_math/aabb3.dart @@ -62,10 +62,9 @@ class Aabb3 { Vector3 get max => _max; /// The center of the AABB. - Vector3 get center => - _min.clone() - ..add(_max) - ..scale(0.5); + Vector3 get center => _min.clone() + ..add(_max) + ..scale(0.5); /// Set the AABB by a [center] and [halfExtents]. void setCenterAndHalfExtents(Vector3 center, Vector3 halfExtents) { @@ -266,17 +265,15 @@ class Aabb3 { /// Create a copy of this that is transformed by the transform [t] and store /// it in [out]. - Aabb3 transformed(Matrix4 t, Aabb3 out) => - out - ..copyFrom(this) - ..transform(t); + Aabb3 transformed(Matrix4 t, Aabb3 out) => out + ..copyFrom(this) + ..transform(t); /// Create a copy of this that is rotated by the rotation matrix [t] and /// store it in [out]. - Aabb3 rotated(Matrix4 t, Aabb3 out) => - out - ..copyFrom(this) - ..rotate(t); + Aabb3 rotated(Matrix4 t, Aabb3 out) => out + ..copyFrom(this) + ..rotate(t); void getPN(Vector3 planeNormal, Vector3 outP, Vector3 outN) { if (planeNormal.x < 0.0) { diff --git a/packages/vector_math/lib/src/vector_math/colors.dart b/packages/vector_math/lib/src/vector_math/colors.dart index 90a3d06..575b4e5 100644 --- a/packages/vector_math/lib/src/vector_math/colors.dart +++ b/packages/vector_math/lib/src/vector_math/colors.dart @@ -269,10 +269,9 @@ class Colors { if (hslColor.y == 0.0) { rgbColor.setValues(hslColor.z, hslColor.z, hslColor.z, hslColor.a); } else { - final double q = - hslColor.z < 0.5 - ? hslColor.z * (1.0 + hslColor.y) - : hslColor.z + hslColor.y - hslColor.z * hslColor.y; + final double q = hslColor.z < 0.5 + ? hslColor.z * (1.0 + hslColor.y) + : hslColor.z + hslColor.y - hslColor.z * hslColor.y; final double p = 2.0 * hslColor.z - q; final double r = _hueToRgb(p, q, hslColor.x + 1.0 / 3.0); diff --git a/packages/vector_math/lib/src/vector_math/matrix2.dart b/packages/vector_math/lib/src/vector_math/matrix2.dart index 143e1d7..5be5803 100644 --- a/packages/vector_math/lib/src/vector_math/matrix2.dart +++ b/packages/vector_math/lib/src/vector_math/matrix2.dart @@ -19,10 +19,9 @@ class Matrix2 { Matrix2.zero() : _m2storage = Float32List(4); /// Identity matrix. - factory Matrix2.identity() => - Matrix2.zero() - .._m2storage[0] = 1.0 - .._m2storage[3] = 1.0; + factory Matrix2.identity() => Matrix2.zero() + .._m2storage[0] = 1.0 + .._m2storage[3] = 1.0; /// Copies values from [other]. factory Matrix2.copy(Matrix2 other) => Matrix2.zero()..setFrom(other); diff --git a/packages/vector_math/lib/src/vector_math/matrix3.dart b/packages/vector_math/lib/src/vector_math/matrix3.dart index cef0dc3..a008e35 100644 --- a/packages/vector_math/lib/src/vector_math/matrix3.dart +++ b/packages/vector_math/lib/src/vector_math/matrix3.dart @@ -27,28 +27,27 @@ class Matrix3 { ..setValues(arg0, arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8); /// New matrix from [values]. - factory Matrix3.fromList(List values) => - Matrix3.zero()..setValues( - values[0], - values[1], - values[2], - values[3], - values[4], - values[5], - values[6], - values[7], - values[8], - ); + factory Matrix3.fromList(List values) => Matrix3.zero() + ..setValues( + values[0], + values[1], + values[2], + values[3], + values[4], + values[5], + values[6], + values[7], + values[8], + ); /// Constructs a new [Matrix3] filled with zeros. Matrix3.zero() : _m3storage = Float32List(9); /// Identity matrix. - factory Matrix3.identity() => - Matrix3.zero() - .._m3storage[0] = 1.0 - .._m3storage[4] = 1.0 - .._m3storage[8] = 1.0; + factory Matrix3.identity() => Matrix3.zero() + .._m3storage[0] = 1.0 + .._m3storage[4] = 1.0 + .._m3storage[8] = 1.0; /// Copes values from [other]. factory Matrix3.copy(Matrix3 other) => Matrix3.zero()..setFrom(other); diff --git a/packages/vector_math/lib/src/vector_math/matrix4.dart b/packages/vector_math/lib/src/vector_math/matrix4.dart index b29b760..0132293 100644 --- a/packages/vector_math/lib/src/vector_math/matrix4.dart +++ b/packages/vector_math/lib/src/vector_math/matrix4.dart @@ -29,57 +29,56 @@ class Matrix4 { double arg13, double arg14, double arg15, - ) => - Matrix4.zero()..setValues( - arg0, - arg1, - arg2, - arg3, - arg4, - arg5, - arg6, - arg7, - arg8, - arg9, - arg10, - arg11, - arg12, - arg13, - arg14, - arg15, - ); + ) => Matrix4.zero() + ..setValues( + arg0, + arg1, + arg2, + arg3, + arg4, + arg5, + arg6, + arg7, + arg8, + arg9, + arg10, + arg11, + arg12, + arg13, + arg14, + arg15, + ); /// New matrix from [values]. - factory Matrix4.fromList(List values) => - Matrix4.zero()..setValues( - values[0], - values[1], - values[2], - values[3], - values[4], - values[5], - values[6], - values[7], - values[8], - values[9], - values[10], - values[11], - values[12], - values[13], - values[14], - values[15], - ); + factory Matrix4.fromList(List values) => Matrix4.zero() + ..setValues( + values[0], + values[1], + values[2], + values[3], + values[4], + values[5], + values[6], + values[7], + values[8], + values[9], + values[10], + values[11], + values[12], + values[13], + values[14], + values[15], + ); /// Zero matrix. Matrix4.zero() : _m4storage = Float32List(16); /// Identity matrix. - factory Matrix4.identity() => - Matrix4.zero() - .._m4storage[0] = 1.0 - .._m4storage[5] = 1.0 - .._m4storage[10] = 1.0 - .._m4storage[15] = 1.0; + factory Matrix4.identity() => Matrix4.zero() + .._m4storage[0] = 1.0 + .._m4storage[5] = 1.0 + .._m4storage[10] = 1.0 + .._m4storage[15] = 1.0; /// Copies values from [other]. factory Matrix4.copy(Matrix4 other) => Matrix4.zero()..setFrom(other); @@ -106,28 +105,24 @@ class Matrix4 { factory Matrix4.outer(Vector4 u, Vector4 v) => Matrix4.zero()..setOuter(u, v); /// Rotation of [radians] around X. - factory Matrix4.rotationX(double radians) => - Matrix4.zero() - .._m4storage[15] = 1.0 - ..setRotationX(radians); + factory Matrix4.rotationX(double radians) => Matrix4.zero() + .._m4storage[15] = 1.0 + ..setRotationX(radians); /// Rotation of [radians] around Y. - factory Matrix4.rotationY(double radians) => - Matrix4.zero() - .._m4storage[15] = 1.0 - ..setRotationY(radians); + factory Matrix4.rotationY(double radians) => Matrix4.zero() + .._m4storage[15] = 1.0 + ..setRotationY(radians); /// Rotation of [radians] around Z. - factory Matrix4.rotationZ(double radians) => - Matrix4.zero() - .._m4storage[15] = 1.0 - ..setRotationZ(radians); + factory Matrix4.rotationZ(double radians) => Matrix4.zero() + .._m4storage[15] = 1.0 + ..setRotationZ(radians); /// Translation matrix. - factory Matrix4.translation(Vector3 translation) => - Matrix4.zero() - ..setIdentity() - ..setTranslation(translation); + factory Matrix4.translation(Vector3 translation) => Matrix4.zero() + ..setIdentity() + ..setTranslation(translation); /// Translation matrix. factory Matrix4.translationValues(double x, double y, double z) => diff --git a/packages/vector_math/lib/src/vector_math/quaternion.dart b/packages/vector_math/lib/src/vector_math/quaternion.dart index c1b1b8b..3e9890a 100644 --- a/packages/vector_math/lib/src/vector_math/quaternion.dart +++ b/packages/vector_math/lib/src/vector_math/quaternion.dart @@ -132,10 +132,9 @@ class Quaternion { _qStorage[1] = (rotationMatrixStorage[6] - rotationMatrixStorage[2]) * s; _qStorage[2] = (rotationMatrixStorage[1] - rotationMatrixStorage[3]) * s; } else { - final i = - rotationMatrixStorage[0] < rotationMatrixStorage[4] - ? (rotationMatrixStorage[4] < rotationMatrixStorage[8] ? 2 : 1) - : (rotationMatrixStorage[0] < rotationMatrixStorage[8] ? 2 : 0); + final i = rotationMatrixStorage[0] < rotationMatrixStorage[4] + ? (rotationMatrixStorage[4] < rotationMatrixStorage[8] ? 2 : 1) + : (rotationMatrixStorage[0] < rotationMatrixStorage[8] ? 2 : 0); final int j = (i + 1) % 3; final int k = (i + 2) % 3; double s = math.sqrt( diff --git a/packages/vector_math/lib/src/vector_math/vector2.dart b/packages/vector_math/lib/src/vector_math/vector2.dart index 74095f8..5df6635 100644 --- a/packages/vector_math/lib/src/vector_math/vector2.dart +++ b/packages/vector_math/lib/src/vector_math/vector2.dart @@ -367,14 +367,12 @@ class Vector2 implements Vector { /// Round entries in this towards zero. void roundToZero() { - _v2storage[1] = - _v2storage[1] < 0.0 - ? _v2storage[1].ceilToDouble() - : _v2storage[1].floorToDouble(); - _v2storage[0] = - _v2storage[0] < 0.0 - ? _v2storage[0].ceilToDouble() - : _v2storage[0].floorToDouble(); + _v2storage[1] = _v2storage[1] < 0.0 + ? _v2storage[1].ceilToDouble() + : _v2storage[1].floorToDouble(); + _v2storage[0] = _v2storage[0] < 0.0 + ? _v2storage[0].ceilToDouble() + : _v2storage[0].floorToDouble(); } /// Clone of this. diff --git a/packages/vector_math/lib/src/vector_math/vector3.dart b/packages/vector_math/lib/src/vector_math/vector3.dart index ebaad7b..988f3c3 100644 --- a/packages/vector_math/lib/src/vector_math/vector3.dart +++ b/packages/vector_math/lib/src/vector_math/vector3.dart @@ -519,18 +519,15 @@ class Vector3 implements Vector { /// Round entries in this towards zero. void roundToZero() { - _v3storage[2] = - _v3storage[2] < 0.0 - ? _v3storage[2].ceilToDouble() - : _v3storage[2].floorToDouble(); - _v3storage[1] = - _v3storage[1] < 0.0 - ? _v3storage[1].ceilToDouble() - : _v3storage[1].floorToDouble(); - _v3storage[0] = - _v3storage[0] < 0.0 - ? _v3storage[0].ceilToDouble() - : _v3storage[0].floorToDouble(); + _v3storage[2] = _v3storage[2] < 0.0 + ? _v3storage[2].ceilToDouble() + : _v3storage[2].floorToDouble(); + _v3storage[1] = _v3storage[1] < 0.0 + ? _v3storage[1].ceilToDouble() + : _v3storage[1].floorToDouble(); + _v3storage[0] = _v3storage[0] < 0.0 + ? _v3storage[0].ceilToDouble() + : _v3storage[0].floorToDouble(); } /// Clone of this. diff --git a/packages/vector_math/lib/src/vector_math/vector4.dart b/packages/vector_math/lib/src/vector_math/vector4.dart index ff93275..414fa53 100644 --- a/packages/vector_math/lib/src/vector_math/vector4.dart +++ b/packages/vector_math/lib/src/vector_math/vector4.dart @@ -419,22 +419,18 @@ class Vector4 implements Vector { /// Round entries in this towards zero. void roundToZero() { - _v4storage[3] = - _v4storage[3] < 0.0 - ? _v4storage[3].ceilToDouble() - : _v4storage[3].floorToDouble(); - _v4storage[2] = - _v4storage[2] < 0.0 - ? _v4storage[2].ceilToDouble() - : _v4storage[2].floorToDouble(); - _v4storage[1] = - _v4storage[1] < 0.0 - ? _v4storage[1].ceilToDouble() - : _v4storage[1].floorToDouble(); - _v4storage[0] = - _v4storage[0] < 0.0 - ? _v4storage[0].ceilToDouble() - : _v4storage[0].floorToDouble(); + _v4storage[3] = _v4storage[3] < 0.0 + ? _v4storage[3].ceilToDouble() + : _v4storage[3].floorToDouble(); + _v4storage[2] = _v4storage[2] < 0.0 + ? _v4storage[2].ceilToDouble() + : _v4storage[2].floorToDouble(); + _v4storage[1] = _v4storage[1] < 0.0 + ? _v4storage[1].ceilToDouble() + : _v4storage[1].floorToDouble(); + _v4storage[0] = _v4storage[0] < 0.0 + ? _v4storage[0].ceilToDouble() + : _v4storage[0].floorToDouble(); } /// Create a copy of this. diff --git a/packages/vector_math/lib/src/vector_math_64/aabb2.dart b/packages/vector_math/lib/src/vector_math_64/aabb2.dart index 16ceb93..5fb2087 100644 --- a/packages/vector_math/lib/src/vector_math_64/aabb2.dart +++ b/packages/vector_math/lib/src/vector_math_64/aabb2.dart @@ -43,10 +43,9 @@ class Aabb2 { Vector2 get max => _max; /// The center of the AABB. - Vector2 get center => - _min.clone() - ..add(_max) - ..scale(0.5); + Vector2 get center => _min.clone() + ..add(_max) + ..scale(0.5); /// Set the AABB by a [center] and [halfExtents]. void setCenterAndHalfExtents(Vector2 center, Vector2 halfExtents) { @@ -109,17 +108,15 @@ class Aabb2 { /// Create a copy of this that is transformed by the transform [t] and store /// it in [out]. - Aabb2 transformed(Matrix3 t, Aabb2 out) => - out - ..copyFrom(this) - ..transform(t); + Aabb2 transformed(Matrix3 t, Aabb2 out) => out + ..copyFrom(this) + ..transform(t); /// Create a copy of this that is rotated by the rotation matrix [t] and /// store it in [out]. - Aabb2 rotated(Matrix3 t, Aabb2 out) => - out - ..copyFrom(this) - ..rotate(t); + Aabb2 rotated(Matrix3 t, Aabb2 out) => out + ..copyFrom(this) + ..rotate(t); /// Set the min and max of this so that this is a hull of this and /// [other]. diff --git a/packages/vector_math/lib/src/vector_math_64/aabb3.dart b/packages/vector_math/lib/src/vector_math_64/aabb3.dart index 405a26e..b5096f8 100644 --- a/packages/vector_math/lib/src/vector_math_64/aabb3.dart +++ b/packages/vector_math/lib/src/vector_math_64/aabb3.dart @@ -62,10 +62,9 @@ class Aabb3 { Vector3 get max => _max; /// The center of the AABB. - Vector3 get center => - _min.clone() - ..add(_max) - ..scale(0.5); + Vector3 get center => _min.clone() + ..add(_max) + ..scale(0.5); /// Set the AABB by a [center] and [halfExtents]. void setCenterAndHalfExtents(Vector3 center, Vector3 halfExtents) { @@ -266,17 +265,15 @@ class Aabb3 { /// Create a copy of this that is transformed by the transform [t] and store /// it in [out]. - Aabb3 transformed(Matrix4 t, Aabb3 out) => - out - ..copyFrom(this) - ..transform(t); + Aabb3 transformed(Matrix4 t, Aabb3 out) => out + ..copyFrom(this) + ..transform(t); /// Create a copy of this that is rotated by the rotation matrix [t] and /// store it in [out]. - Aabb3 rotated(Matrix4 t, Aabb3 out) => - out - ..copyFrom(this) - ..rotate(t); + Aabb3 rotated(Matrix4 t, Aabb3 out) => out + ..copyFrom(this) + ..rotate(t); void getPN(Vector3 planeNormal, Vector3 outP, Vector3 outN) { if (planeNormal.x < 0.0) { diff --git a/packages/vector_math/lib/src/vector_math_64/colors.dart b/packages/vector_math/lib/src/vector_math_64/colors.dart index c5c07d7..53194ec 100644 --- a/packages/vector_math/lib/src/vector_math_64/colors.dart +++ b/packages/vector_math/lib/src/vector_math_64/colors.dart @@ -269,10 +269,9 @@ class Colors { if (hslColor.y == 0.0) { rgbColor.setValues(hslColor.z, hslColor.z, hslColor.z, hslColor.a); } else { - final double q = - hslColor.z < 0.5 - ? hslColor.z * (1.0 + hslColor.y) - : hslColor.z + hslColor.y - hslColor.z * hslColor.y; + final double q = hslColor.z < 0.5 + ? hslColor.z * (1.0 + hslColor.y) + : hslColor.z + hslColor.y - hslColor.z * hslColor.y; final double p = 2.0 * hslColor.z - q; final double r = _hueToRgb(p, q, hslColor.x + 1.0 / 3.0); diff --git a/packages/vector_math/lib/src/vector_math_64/matrix2.dart b/packages/vector_math/lib/src/vector_math_64/matrix2.dart index 9302491..804aee8 100644 --- a/packages/vector_math/lib/src/vector_math_64/matrix2.dart +++ b/packages/vector_math/lib/src/vector_math_64/matrix2.dart @@ -19,10 +19,9 @@ class Matrix2 { Matrix2.zero() : _m2storage = Float64List(4); /// Identity matrix. - factory Matrix2.identity() => - Matrix2.zero() - .._m2storage[0] = 1.0 - .._m2storage[3] = 1.0; + factory Matrix2.identity() => Matrix2.zero() + .._m2storage[0] = 1.0 + .._m2storage[3] = 1.0; /// Copies values from [other]. factory Matrix2.copy(Matrix2 other) => Matrix2.zero()..setFrom(other); diff --git a/packages/vector_math/lib/src/vector_math_64/matrix3.dart b/packages/vector_math/lib/src/vector_math_64/matrix3.dart index 494d22d..a15db74 100644 --- a/packages/vector_math/lib/src/vector_math_64/matrix3.dart +++ b/packages/vector_math/lib/src/vector_math_64/matrix3.dart @@ -27,28 +27,27 @@ class Matrix3 { ..setValues(arg0, arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8); /// New matrix from [values]. - factory Matrix3.fromList(List values) => - Matrix3.zero()..setValues( - values[0], - values[1], - values[2], - values[3], - values[4], - values[5], - values[6], - values[7], - values[8], - ); + factory Matrix3.fromList(List values) => Matrix3.zero() + ..setValues( + values[0], + values[1], + values[2], + values[3], + values[4], + values[5], + values[6], + values[7], + values[8], + ); /// Constructs a new [Matrix3] filled with zeros. Matrix3.zero() : _m3storage = Float64List(9); /// Identity matrix. - factory Matrix3.identity() => - Matrix3.zero() - .._m3storage[0] = 1.0 - .._m3storage[4] = 1.0 - .._m3storage[8] = 1.0; + factory Matrix3.identity() => Matrix3.zero() + .._m3storage[0] = 1.0 + .._m3storage[4] = 1.0 + .._m3storage[8] = 1.0; /// Copes values from [other]. factory Matrix3.copy(Matrix3 other) => Matrix3.zero()..setFrom(other); diff --git a/packages/vector_math/lib/src/vector_math_64/matrix4.dart b/packages/vector_math/lib/src/vector_math_64/matrix4.dart index b2fcd08..0985d2a 100644 --- a/packages/vector_math/lib/src/vector_math_64/matrix4.dart +++ b/packages/vector_math/lib/src/vector_math_64/matrix4.dart @@ -29,57 +29,56 @@ class Matrix4 { double arg13, double arg14, double arg15, - ) => - Matrix4.zero()..setValues( - arg0, - arg1, - arg2, - arg3, - arg4, - arg5, - arg6, - arg7, - arg8, - arg9, - arg10, - arg11, - arg12, - arg13, - arg14, - arg15, - ); + ) => Matrix4.zero() + ..setValues( + arg0, + arg1, + arg2, + arg3, + arg4, + arg5, + arg6, + arg7, + arg8, + arg9, + arg10, + arg11, + arg12, + arg13, + arg14, + arg15, + ); /// New matrix from [values]. - factory Matrix4.fromList(List values) => - Matrix4.zero()..setValues( - values[0], - values[1], - values[2], - values[3], - values[4], - values[5], - values[6], - values[7], - values[8], - values[9], - values[10], - values[11], - values[12], - values[13], - values[14], - values[15], - ); + factory Matrix4.fromList(List values) => Matrix4.zero() + ..setValues( + values[0], + values[1], + values[2], + values[3], + values[4], + values[5], + values[6], + values[7], + values[8], + values[9], + values[10], + values[11], + values[12], + values[13], + values[14], + values[15], + ); /// Zero matrix. Matrix4.zero() : _m4storage = Float64List(16); /// Identity matrix. - factory Matrix4.identity() => - Matrix4.zero() - .._m4storage[0] = 1.0 - .._m4storage[5] = 1.0 - .._m4storage[10] = 1.0 - .._m4storage[15] = 1.0; + factory Matrix4.identity() => Matrix4.zero() + .._m4storage[0] = 1.0 + .._m4storage[5] = 1.0 + .._m4storage[10] = 1.0 + .._m4storage[15] = 1.0; /// Copies values from [other]. factory Matrix4.copy(Matrix4 other) => Matrix4.zero()..setFrom(other); @@ -106,28 +105,24 @@ class Matrix4 { factory Matrix4.outer(Vector4 u, Vector4 v) => Matrix4.zero()..setOuter(u, v); /// Rotation of [radians] around X. - factory Matrix4.rotationX(double radians) => - Matrix4.zero() - .._m4storage[15] = 1.0 - ..setRotationX(radians); + factory Matrix4.rotationX(double radians) => Matrix4.zero() + .._m4storage[15] = 1.0 + ..setRotationX(radians); /// Rotation of [radians] around Y. - factory Matrix4.rotationY(double radians) => - Matrix4.zero() - .._m4storage[15] = 1.0 - ..setRotationY(radians); + factory Matrix4.rotationY(double radians) => Matrix4.zero() + .._m4storage[15] = 1.0 + ..setRotationY(radians); /// Rotation of [radians] around Z. - factory Matrix4.rotationZ(double radians) => - Matrix4.zero() - .._m4storage[15] = 1.0 - ..setRotationZ(radians); + factory Matrix4.rotationZ(double radians) => Matrix4.zero() + .._m4storage[15] = 1.0 + ..setRotationZ(radians); /// Translation matrix. - factory Matrix4.translation(Vector3 translation) => - Matrix4.zero() - ..setIdentity() - ..setTranslation(translation); + factory Matrix4.translation(Vector3 translation) => Matrix4.zero() + ..setIdentity() + ..setTranslation(translation); /// Translation matrix. factory Matrix4.translationValues(double x, double y, double z) => diff --git a/packages/vector_math/lib/src/vector_math_64/quaternion.dart b/packages/vector_math/lib/src/vector_math_64/quaternion.dart index 68ebf8f..7edca5d 100644 --- a/packages/vector_math/lib/src/vector_math_64/quaternion.dart +++ b/packages/vector_math/lib/src/vector_math_64/quaternion.dart @@ -132,10 +132,9 @@ class Quaternion { _qStorage[1] = (rotationMatrixStorage[6] - rotationMatrixStorage[2]) * s; _qStorage[2] = (rotationMatrixStorage[1] - rotationMatrixStorage[3]) * s; } else { - final i = - rotationMatrixStorage[0] < rotationMatrixStorage[4] - ? (rotationMatrixStorage[4] < rotationMatrixStorage[8] ? 2 : 1) - : (rotationMatrixStorage[0] < rotationMatrixStorage[8] ? 2 : 0); + final i = rotationMatrixStorage[0] < rotationMatrixStorage[4] + ? (rotationMatrixStorage[4] < rotationMatrixStorage[8] ? 2 : 1) + : (rotationMatrixStorage[0] < rotationMatrixStorage[8] ? 2 : 0); final int j = (i + 1) % 3; final int k = (i + 2) % 3; double s = math.sqrt( diff --git a/packages/vector_math/lib/src/vector_math_64/vector2.dart b/packages/vector_math/lib/src/vector_math_64/vector2.dart index a086016..e5de199 100644 --- a/packages/vector_math/lib/src/vector_math_64/vector2.dart +++ b/packages/vector_math/lib/src/vector_math_64/vector2.dart @@ -367,14 +367,12 @@ class Vector2 implements Vector { /// Round entries in this towards zero. void roundToZero() { - _v2storage[1] = - _v2storage[1] < 0.0 - ? _v2storage[1].ceilToDouble() - : _v2storage[1].floorToDouble(); - _v2storage[0] = - _v2storage[0] < 0.0 - ? _v2storage[0].ceilToDouble() - : _v2storage[0].floorToDouble(); + _v2storage[1] = _v2storage[1] < 0.0 + ? _v2storage[1].ceilToDouble() + : _v2storage[1].floorToDouble(); + _v2storage[0] = _v2storage[0] < 0.0 + ? _v2storage[0].ceilToDouble() + : _v2storage[0].floorToDouble(); } /// Clone of this. diff --git a/packages/vector_math/lib/src/vector_math_64/vector3.dart b/packages/vector_math/lib/src/vector_math_64/vector3.dart index 8735480..7edcdaa 100644 --- a/packages/vector_math/lib/src/vector_math_64/vector3.dart +++ b/packages/vector_math/lib/src/vector_math_64/vector3.dart @@ -519,18 +519,15 @@ class Vector3 implements Vector { /// Round entries in this towards zero. void roundToZero() { - _v3storage[2] = - _v3storage[2] < 0.0 - ? _v3storage[2].ceilToDouble() - : _v3storage[2].floorToDouble(); - _v3storage[1] = - _v3storage[1] < 0.0 - ? _v3storage[1].ceilToDouble() - : _v3storage[1].floorToDouble(); - _v3storage[0] = - _v3storage[0] < 0.0 - ? _v3storage[0].ceilToDouble() - : _v3storage[0].floorToDouble(); + _v3storage[2] = _v3storage[2] < 0.0 + ? _v3storage[2].ceilToDouble() + : _v3storage[2].floorToDouble(); + _v3storage[1] = _v3storage[1] < 0.0 + ? _v3storage[1].ceilToDouble() + : _v3storage[1].floorToDouble(); + _v3storage[0] = _v3storage[0] < 0.0 + ? _v3storage[0].ceilToDouble() + : _v3storage[0].floorToDouble(); } /// Clone of this. diff --git a/packages/vector_math/lib/src/vector_math_64/vector4.dart b/packages/vector_math/lib/src/vector_math_64/vector4.dart index d30f8f9..72c089a 100644 --- a/packages/vector_math/lib/src/vector_math_64/vector4.dart +++ b/packages/vector_math/lib/src/vector_math_64/vector4.dart @@ -419,22 +419,18 @@ class Vector4 implements Vector { /// Round entries in this towards zero. void roundToZero() { - _v4storage[3] = - _v4storage[3] < 0.0 - ? _v4storage[3].ceilToDouble() - : _v4storage[3].floorToDouble(); - _v4storage[2] = - _v4storage[2] < 0.0 - ? _v4storage[2].ceilToDouble() - : _v4storage[2].floorToDouble(); - _v4storage[1] = - _v4storage[1] < 0.0 - ? _v4storage[1].ceilToDouble() - : _v4storage[1].floorToDouble(); - _v4storage[0] = - _v4storage[0] < 0.0 - ? _v4storage[0].ceilToDouble() - : _v4storage[0].floorToDouble(); + _v4storage[3] = _v4storage[3] < 0.0 + ? _v4storage[3].ceilToDouble() + : _v4storage[3].floorToDouble(); + _v4storage[2] = _v4storage[2] < 0.0 + ? _v4storage[2].ceilToDouble() + : _v4storage[2].floorToDouble(); + _v4storage[1] = _v4storage[1] < 0.0 + ? _v4storage[1].ceilToDouble() + : _v4storage[1].floorToDouble(); + _v4storage[0] = _v4storage[0] < 0.0 + ? _v4storage[0].ceilToDouble() + : _v4storage[0].floorToDouble(); } /// Create a copy of this. diff --git a/packages/vector_math/lib/src/vector_math_geometry/mesh_geometry.dart b/packages/vector_math/lib/src/vector_math_geometry/mesh_geometry.dart index 69588ee..ee9245d 100644 --- a/packages/vector_math/lib/src/vector_math_geometry/mesh_geometry.dart +++ b/packages/vector_math/lib/src/vector_math_geometry/mesh_geometry.dart @@ -211,8 +211,9 @@ class MeshGeometry { // When combining meshes they must all have a matching set of VertexAttribs final MeshGeometry firstMesh = meshes[0]; int totalVerts = firstMesh.length; - int totalIndices = - firstMesh.indices != null ? firstMesh.indices!.length : 0; + int totalIndices = firstMesh.indices != null + ? firstMesh.indices!.length + : 0; for (var i = 1; i < meshes.length; ++i) { final MeshGeometry srcMesh = meshes[i]; if (!firstMesh.attribsAreCompatible(srcMesh)) { diff --git a/packages/vector_math/test/aabb3_test.dart b/packages/vector_math/test/aabb3_test.dart index aa4e4d5..fe6de6a 100644 --- a/packages/vector_math/test/aabb3_test.dart +++ b/packages/vector_math/test/aabb3_test.dart @@ -11,8 +11,15 @@ import 'package:vector_math/vector_math.dart'; import 'test_utils.dart'; void testAabb3ByteBufferInstanciation() { - final ByteBuffer buffer = - Float32List.fromList([1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0]).buffer; + final ByteBuffer buffer = Float32List.fromList([ + 1.0, + 2.0, + 3.0, + 4.0, + 5.0, + 6.0, + 7.0, + ]).buffer; final aabb = Aabb3.fromBuffer(buffer, 0); final aabbOffest = Aabb3.fromBuffer(buffer, Float32List.bytesPerElement); diff --git a/packages/vector_math/test/obb3_test.dart b/packages/vector_math/test/obb3_test.dart index a7cd8c3..69ed186 100644 --- a/packages/vector_math/test/obb3_test.dart +++ b/packages/vector_math/test/obb3_test.dart @@ -11,10 +11,9 @@ import 'package:vector_math/vector_math.dart'; import 'test_utils.dart'; void testCorners() { - final a = - Obb3() - ..center.setValues(0.0, 0.0, 0.0) - ..halfExtents.setValues(5.0, 5.0, 5.0); + final a = Obb3() + ..center.setValues(0.0, 0.0, 0.0) + ..halfExtents.setValues(5.0, 5.0, 5.0); final corner = Vector3.zero(); a.copyCorner(0, corner); @@ -43,10 +42,9 @@ void testCorners() { } void testTranslate() { - final a = - Obb3() - ..center.setValues(0.0, 0.0, 0.0) - ..halfExtents.setValues(5.0, 5.0, 5.0); + final a = Obb3() + ..center.setValues(0.0, 0.0, 0.0) + ..halfExtents.setValues(5.0, 5.0, 5.0); final corner = Vector3.zero(); a.translate(Vector3(-1.0, 2.0, 3.0)); @@ -77,10 +75,9 @@ void testTranslate() { } void testRotate() { - final a = - Obb3() - ..center.setValues(0.0, 0.0, 0.0) - ..halfExtents.setValues(5.0, 5.0, 5.0); + final a = Obb3() + ..center.setValues(0.0, 0.0, 0.0) + ..halfExtents.setValues(5.0, 5.0, 5.0); final corner = Vector3.zero(); final matrix = Matrix3.rotationY(radians(-45.0)); @@ -112,10 +109,9 @@ void testRotate() { } void testTransform() { - final a = - Obb3() - ..center.setValues(0.0, 0.0, 0.0) - ..halfExtents.setValues(5.0, 5.0, 5.0); + final a = Obb3() + ..center.setValues(0.0, 0.0, 0.0) + ..halfExtents.setValues(5.0, 5.0, 5.0); final corner = Vector3.zero(); final matrix = Matrix4.diagonal3Values(3.0, 3.0, 3.0); @@ -147,10 +143,9 @@ void testTransform() { } void testClosestPointTo() { - final a = - Obb3() - ..center.setValues(0.0, 0.0, 0.0) - ..halfExtents.setValues(2.0, 2.0, 2.0); + final a = Obb3() + ..center.setValues(0.0, 0.0, 0.0) + ..halfExtents.setValues(2.0, 2.0, 2.0); final b = Vector3(3.0, 3.0, 3.0); final c = Vector3(3.0, 3.0, -3.0); final closestPoint = Vector3.zero(); @@ -175,55 +170,45 @@ void testClosestPointTo() { } void testIntersectionObb3() { - final a = - Obb3() - ..center.setValues(0.0, 0.0, 0.0) - ..halfExtents.setValues(2.0, 2.0, 2.0); - - final b = - Obb3() - ..center.setValues(3.0, 0.0, 0.0) - ..halfExtents.setValues(0.5, 0.5, 0.5); - - final c = - Obb3() - ..center.setValues(0.0, 3.0, 0.0) - ..halfExtents.setValues(0.5, 0.5, 0.5); - - final d = - Obb3() - ..center.setValues(0.0, 0.0, 3.0) - ..halfExtents.setValues(0.5, 0.5, 0.5); - - final e = - Obb3() - ..center.setValues(-3.0, 0.0, 0.0) - ..halfExtents.setValues(0.5, 0.5, 0.5); - - final f = - Obb3() - ..center.setValues(0.0, -3.0, 0.0) - ..halfExtents.setValues(0.5, 0.5, 0.5); - - final g = - Obb3() - ..center.setValues(0.0, 0.0, -3.0) - ..halfExtents.setValues(0.5, 0.5, 0.5); - - final u = - Obb3() - ..center.setValues(1.0, 1.0, 1.0) - ..halfExtents.setValues(0.5, 0.5, 0.5); - - final v = - Obb3() - ..center.setValues(10.0, 10.0, -10.0) - ..halfExtents.setValues(2.0, 2.0, 2.0); - - final w = - Obb3() - ..center.setValues(10.0, 0.0, 0.0) - ..halfExtents.setValues(1.0, 1.0, 1.0); + final a = Obb3() + ..center.setValues(0.0, 0.0, 0.0) + ..halfExtents.setValues(2.0, 2.0, 2.0); + + final b = Obb3() + ..center.setValues(3.0, 0.0, 0.0) + ..halfExtents.setValues(0.5, 0.5, 0.5); + + final c = Obb3() + ..center.setValues(0.0, 3.0, 0.0) + ..halfExtents.setValues(0.5, 0.5, 0.5); + + final d = Obb3() + ..center.setValues(0.0, 0.0, 3.0) + ..halfExtents.setValues(0.5, 0.5, 0.5); + + final e = Obb3() + ..center.setValues(-3.0, 0.0, 0.0) + ..halfExtents.setValues(0.5, 0.5, 0.5); + + final f = Obb3() + ..center.setValues(0.0, -3.0, 0.0) + ..halfExtents.setValues(0.5, 0.5, 0.5); + + final g = Obb3() + ..center.setValues(0.0, 0.0, -3.0) + ..halfExtents.setValues(0.5, 0.5, 0.5); + + final u = Obb3() + ..center.setValues(1.0, 1.0, 1.0) + ..halfExtents.setValues(0.5, 0.5, 0.5); + + final v = Obb3() + ..center.setValues(10.0, 10.0, -10.0) + ..halfExtents.setValues(2.0, 2.0, 2.0); + + final w = Obb3() + ..center.setValues(10.0, 0.0, 0.0) + ..halfExtents.setValues(1.0, 1.0, 1.0); // a - b expect(a.intersectsWithObb3(b), isFalse); @@ -317,10 +302,9 @@ void testIntersectionObb3() { void testIntersectionVector3() { //final parent = new Aabb3.minMax(_v(1.0,1.0,1.0), _v(8.0,8.0,8.0)); - final parent = - Obb3() - ..center.setValues(4.5, 4.5, 4.5) - ..halfExtents.setValues(3.5, 3.5, 3.5); + final parent = Obb3() + ..center.setValues(4.5, 4.5, 4.5) + ..halfExtents.setValues(3.5, 3.5, 3.5); final Vector3 child = $v3(7.0, 7.0, 7.0); final Vector3 cutting = $v3(1.0, 2.0, 1.0); final Vector3 outside1 = $v3(-10.0, 10.0, 10.0);