Strong mode and linter clean-up for vector_math
diff --git a/lib/src/vector_math/aabb3.dart b/lib/src/vector_math/aabb3.dart
index ea887c9..c7c1488 100644
--- a/lib/src/vector_math/aabb3.dart
+++ b/lib/src/vector_math/aabb3.dart
@@ -86,41 +86,41 @@
/// Set the AABB to enclose a [triangle].
void setTriangle(Triangle triangle) {
_min.setValues(
- Math.min(triangle._point0.x,
- Math.min(triangle._point1.x, triangle._point2.x)),
- Math.min(triangle._point0.y,
- Math.min(triangle._point1.y, triangle._point2.y)),
- Math.min(triangle._point0.z,
- Math.min(triangle._point1.z, triangle._point2.z)));
+ math.min(triangle._point0.x,
+ math.min(triangle._point1.x, triangle._point2.x)),
+ math.min(triangle._point0.y,
+ math.min(triangle._point1.y, triangle._point2.y)),
+ math.min(triangle._point0.z,
+ math.min(triangle._point1.z, triangle._point2.z)));
_max.setValues(
- Math.max(triangle._point0.x,
- Math.max(triangle._point1.x, triangle._point2.x)),
- Math.max(triangle._point0.y,
- Math.max(triangle._point1.y, triangle._point2.y)),
- Math.max(triangle._point0.z,
- Math.max(triangle._point1.z, triangle._point2.z)));
+ math.max(triangle._point0.x,
+ math.max(triangle._point1.x, triangle._point2.x)),
+ math.max(triangle._point0.y,
+ math.max(triangle._point1.y, triangle._point2.y)),
+ math.max(triangle._point0.z,
+ math.max(triangle._point1.z, triangle._point2.z)));
}
/// Set the AABB to enclose a [quad].
void setQuad(Quad quad) {
_min.setValues(
- Math.min(quad._point0.x,
- Math.min(quad._point1.x, Math.min(quad._point2.x, quad._point3.x))),
- Math.min(quad._point0.y,
- Math.min(quad._point1.y, Math.min(quad._point2.y, quad._point3.y))),
- Math.min(
+ math.min(quad._point0.x,
+ math.min(quad._point1.x, math.min(quad._point2.x, quad._point3.x))),
+ math.min(quad._point0.y,
+ math.min(quad._point1.y, math.min(quad._point2.y, quad._point3.y))),
+ math.min(
quad._point0.z,
- Math.min(
- quad._point1.z, Math.min(quad._point2.z, quad._point3.z))));
+ math.min(
+ quad._point1.z, math.min(quad._point2.z, quad._point3.z))));
_max.setValues(
- Math.max(quad._point0.x,
- Math.max(quad._point1.x, Math.max(quad._point2.x, quad._point3.x))),
- Math.max(quad._point0.y,
- Math.max(quad._point1.y, Math.max(quad._point2.y, quad._point3.y))),
- Math.max(
+ math.max(quad._point0.x,
+ math.max(quad._point1.x, math.max(quad._point2.x, quad._point3.x))),
+ math.max(quad._point0.y,
+ math.max(quad._point1.y, math.max(quad._point2.y, quad._point3.y))),
+ math.max(
quad._point0.z,
- Math.max(
- quad._point1.z, Math.max(quad._point2.z, quad._point3.z))));
+ math.max(
+ quad._point1.z, math.max(quad._point2.z, quad._point3.z))));
}
/// Set the AABB to enclose a [obb].
@@ -430,11 +430,11 @@
p0 = _v0.z * _f0.y - _v0.y * _f0.z;
p2 = _v2.z * _f0.y - _v2.y * _f0.z;
r = _aabbHalfExtents[1] * _f0.z.abs() + _aabbHalfExtents[2] * _f0.y.abs();
- if (Math.max(-Math.max(p0, p2), Math.min(p0, p2)) > r + epsilon) {
+ if (math.max(-math.max(p0, p2), math.min(p0, p2)) > r + epsilon) {
return false; // Axis is a separating axis
}
- a = Math.min(p0, p2) - r;
+ a = math.min(p0, p2) - r;
if (result != null && (result._depth == null || result._depth < a)) {
result._depth = a;
_u0.crossInto(_f0, result.axis);
@@ -448,11 +448,11 @@
p0 = _v0.z * _f1.y - _v0.y * _f1.z;
p1 = _v1.z * _f1.y - _v1.y * _f1.z;
r = _aabbHalfExtents[1] * _f1.z.abs() + _aabbHalfExtents[2] * _f1.y.abs();
- if (Math.max(-Math.max(p0, p1), Math.min(p0, p1)) > r + epsilon) {
+ if (math.max(-math.max(p0, p1), math.min(p0, p1)) > r + epsilon) {
return false; // Axis is a separating axis
}
- a = Math.min(p0, p1) - r;
+ a = math.min(p0, p1) - r;
if (result != null && (result._depth == null || result._depth < a)) {
result._depth = a;
_u0.crossInto(_f1, result.axis);
@@ -466,11 +466,11 @@
p0 = _v0.z * _f2.y - _v0.y * _f2.z;
p1 = _v1.z * _f2.y - _v1.y * _f2.z;
r = _aabbHalfExtents[1] * _f2.z.abs() + _aabbHalfExtents[2] * _f2.y.abs();
- if (Math.max(-Math.max(p0, p1), Math.min(p0, p1)) > r + epsilon) {
+ if (math.max(-math.max(p0, p1), math.min(p0, p1)) > r + epsilon) {
return false; // Axis is a separating axis
}
- a = Math.min(p0, p1) - r;
+ a = math.min(p0, p1) - r;
if (result != null && (result._depth == null || result._depth < a)) {
result._depth = a;
_u0.crossInto(_f2, result.axis);
@@ -484,11 +484,11 @@
p0 = _v0.x * _f0.z - _v0.z * _f0.x;
p2 = _v2.x * _f0.z - _v2.z * _f0.x;
r = _aabbHalfExtents[0] * _f0.z.abs() + _aabbHalfExtents[2] * _f0.x.abs();
- if (Math.max(-Math.max(p0, p2), Math.min(p0, p2)) > r + epsilon) {
+ if (math.max(-math.max(p0, p2), math.min(p0, p2)) > r + epsilon) {
return false; // Axis is a separating axis
}
- a = Math.min(p0, p2) - r;
+ a = math.min(p0, p2) - r;
if (result != null && (result._depth == null || result._depth < a)) {
result._depth = a;
_u1.crossInto(_f0, result.axis);
@@ -502,11 +502,11 @@
p0 = _v0.x * _f1.z - _v0.z * _f1.x;
p1 = _v1.x * _f1.z - _v1.z * _f1.x;
r = _aabbHalfExtents[0] * _f1.z.abs() + _aabbHalfExtents[2] * _f1.x.abs();
- if (Math.max(-Math.max(p0, p1), Math.min(p0, p1)) > r + epsilon) {
+ if (math.max(-math.max(p0, p1), math.min(p0, p1)) > r + epsilon) {
return false; // Axis is a separating axis
}
- a = Math.min(p0, p1) - r;
+ a = math.min(p0, p1) - r;
if (result != null && (result._depth == null || result._depth < a)) {
result._depth = a;
_u1.crossInto(_f1, result.axis);
@@ -520,11 +520,11 @@
p0 = _v0.x * _f2.z - _v0.z * _f2.x;
p1 = _v1.x * _f2.z - _v1.z * _f2.x;
r = _aabbHalfExtents[0] * _f2.z.abs() + _aabbHalfExtents[2] * _f2.x.abs();
- if (Math.max(-Math.max(p0, p1), Math.min(p0, p1)) > r + epsilon) {
+ if (math.max(-math.max(p0, p1), math.min(p0, p1)) > r + epsilon) {
return false; // Axis is a separating axis
}
- a = Math.min(p0, p1) - r;
+ a = math.min(p0, p1) - r;
if (result != null && (result._depth == null || result._depth < a)) {
result._depth = a;
_u1.crossInto(_f2, result.axis);
@@ -538,11 +538,11 @@
p0 = _v0.y * _f0.x - _v0.x * _f0.y;
p2 = _v2.y * _f0.x - _v2.x * _f0.y;
r = _aabbHalfExtents[0] * _f0.y.abs() + _aabbHalfExtents[1] * _f0.x.abs();
- if (Math.max(-Math.max(p0, p2), Math.min(p0, p2)) > r + epsilon) {
+ if (math.max(-math.max(p0, p2), math.min(p0, p2)) > r + epsilon) {
return false; // Axis is a separating axis
}
- a = Math.min(p0, p2) - r;
+ a = math.min(p0, p2) - r;
if (result != null && (result._depth == null || result._depth < a)) {
result._depth = a;
_u2.crossInto(_f0, result.axis);
@@ -556,11 +556,11 @@
p0 = _v0.y * _f1.x - _v0.x * _f1.y;
p1 = _v1.y * _f1.x - _v1.x * _f1.y;
r = _aabbHalfExtents[0] * _f1.y.abs() + _aabbHalfExtents[1] * _f1.x.abs();
- if (Math.max(-Math.max(p0, p1), Math.min(p0, p1)) > r + epsilon) {
+ if (math.max(-math.max(p0, p1), math.min(p0, p1)) > r + epsilon) {
return false; // Axis is a separating axis
}
- a = Math.min(p0, p1) - r;
+ a = math.min(p0, p1) - r;
if (result != null && (result._depth == null || result._depth < a)) {
result._depth = a;
_u2.crossInto(_f1, result.axis);
@@ -574,11 +574,11 @@
p0 = _v0.y * _f2.x - _v0.x * _f2.y;
p1 = _v1.y * _f2.x - _v1.x * _f2.y;
r = _aabbHalfExtents[0] * _f2.y.abs() + _aabbHalfExtents[1] * _f2.x.abs();
- if (Math.max(-Math.max(p0, p1), Math.min(p0, p1)) > r + epsilon) {
+ if (math.max(-math.max(p0, p1), math.min(p0, p1)) > r + epsilon) {
return false; // Axis is a separating axis
}
- a = Math.min(p0, p1) - r;
+ a = math.min(p0, p1) - r;
if (result != null && (result._depth == null || result._depth < a)) {
result._depth = a;
_u2.crossInto(_f2, result.axis);
@@ -587,31 +587,31 @@
// Test the three axes corresponding to the face normals of AABB b (category 1). // Exit if...
// ... [-e0, e0] and [min(v0.x,v1.x,v2.x), max(v0.x,v1.x,v2.x)] do not overlap
- if (Math.max(_v0.x, Math.max(_v1.x, _v2.x)) < -_aabbHalfExtents[0] ||
- Math.min(_v0.x, Math.min(_v1.x, _v2.x)) > _aabbHalfExtents[0]) {
+ if (math.max(_v0.x, math.max(_v1.x, _v2.x)) < -_aabbHalfExtents[0] ||
+ math.min(_v0.x, math.min(_v1.x, _v2.x)) > _aabbHalfExtents[0]) {
return false;
}
- a = Math.min(_v0.x, Math.min(_v1.x, _v2.x)) - _aabbHalfExtents[0];
+ a = math.min(_v0.x, math.min(_v1.x, _v2.x)) - _aabbHalfExtents[0];
if (result != null && (result._depth == null || result._depth < a)) {
result._depth = a;
result.axis.setFrom(_u0);
}
// ... [-e1, e1] and [min(v0.y,v1.y,v2.y), max(v0.y,v1.y,v2.y)] do not overlap
- if (Math.max(_v0.y, Math.max(_v1.y, _v2.y)) < -_aabbHalfExtents[1] ||
- Math.min(_v0.y, Math.min(_v1.y, _v2.y)) > _aabbHalfExtents[1]) {
+ if (math.max(_v0.y, math.max(_v1.y, _v2.y)) < -_aabbHalfExtents[1] ||
+ math.min(_v0.y, math.min(_v1.y, _v2.y)) > _aabbHalfExtents[1]) {
return false;
}
- a = Math.min(_v0.y, Math.min(_v1.y, _v2.y)) - _aabbHalfExtents[1];
+ a = math.min(_v0.y, math.min(_v1.y, _v2.y)) - _aabbHalfExtents[1];
if (result != null && (result._depth == null || result._depth < a)) {
result._depth = a;
result.axis.setFrom(_u1);
}
// ... [-e2, e2] and [min(v0.z,v1.z,v2.z), max(v0.z,v1.z,v2.z)] do not overlap
- if (Math.max(_v0.z, Math.max(_v1.z, _v2.z)) < -_aabbHalfExtents[2] ||
- Math.min(_v0.z, Math.min(_v1.z, _v2.z)) > _aabbHalfExtents[2]) {
+ if (math.max(_v0.z, math.max(_v1.z, _v2.z)) < -_aabbHalfExtents[2] ||
+ math.min(_v0.z, math.min(_v1.z, _v2.z)) > _aabbHalfExtents[2]) {
return false;
}
- a = Math.min(_v0.z, Math.min(_v1.z, _v2.z)) - _aabbHalfExtents[2];
+ a = math.min(_v0.z, math.min(_v1.z, _v2.z)) - _aabbHalfExtents[2];
if (result != null && (result._depth == null || result._depth < a)) {
result._depth = a;
result.axis.setFrom(_u2);
diff --git a/lib/src/vector_math/colors.dart b/lib/src/vector_math/colors.dart
index 0d980bb..ff6a7d6 100644
--- a/lib/src/vector_math/colors.dart
+++ b/lib/src/vector_math/colors.dart
@@ -142,9 +142,9 @@
final double exponent = 1.0 / gamma;
gammaColor
- ..r = Math.pow(linearColor.r, exponent).toDouble()
- ..g = Math.pow(linearColor.g, exponent).toDouble()
- ..b = Math.pow(linearColor.b, exponent).toDouble()
+ ..r = math.pow(linearColor.r, exponent).toDouble()
+ ..g = math.pow(linearColor.g, exponent).toDouble()
+ ..b = math.pow(linearColor.b, exponent).toDouble()
..a = linearColor.a;
}
@@ -154,17 +154,17 @@
static void gammaToLinear(Vector4 gammaColor, Vector4 linearColor,
[double gamma = 2.2]) {
linearColor
- ..r = Math.pow(gammaColor.r, gamma).toDouble()
- ..g = Math.pow(gammaColor.g, gamma).toDouble()
- ..b = Math.pow(gammaColor.b, gamma).toDouble()
+ ..r = math.pow(gammaColor.r, gamma).toDouble()
+ ..g = math.pow(gammaColor.g, gamma).toDouble()
+ ..b = math.pow(gammaColor.b, gamma).toDouble()
..a = gammaColor.a;
}
/// Convert [rgbColor] from rgb color model to the hue, saturation, and value
/// (HSV) color model and store it in [hsvColor].
static void rgbToHsv(Vector4 rgbColor, Vector4 hsvColor) {
- final double max = Math.max(Math.max(rgbColor.r, rgbColor.g), rgbColor.b);
- final double min = Math.min(Math.min(rgbColor.r, rgbColor.g), rgbColor.b);
+ final double max = math.max(math.max(rgbColor.r, rgbColor.g), rgbColor.b);
+ final double min = math.min(math.min(rgbColor.r, rgbColor.g), rgbColor.b);
final double d = max - min;
final double v = max;
final double s = max == 0.0 ? 0.0 : d / max;
@@ -220,8 +220,8 @@
/// Convert [rgbColor] from rgb color model to the hue, saturation, and
/// lightness (HSL) color model and store it in [hslColor].
static void rgbToHsl(Vector4 rgbColor, Vector4 hslColor) {
- final double max = Math.max(Math.max(rgbColor.r, rgbColor.g), rgbColor.b);
- final double min = Math.min(Math.min(rgbColor.r, rgbColor.g), rgbColor.b);
+ final double max = math.max(math.max(rgbColor.r, rgbColor.g), rgbColor.b);
+ final double min = math.min(math.min(rgbColor.r, rgbColor.g), rgbColor.b);
final double l = (max + min) / 2.0;
double h = 0.0;
double s = 0.0;
diff --git a/lib/src/vector_math/constants.dart b/lib/src/vector_math/constants.dart
index 3056dc1..e2c2840 100644
--- a/lib/src/vector_math/constants.dart
+++ b/lib/src/vector_math/constants.dart
@@ -5,7 +5,7 @@
part of vector_math;
/// Constant factor to convert and angle from degrees to radians.
-const double degrees2Radians = Math.PI / 180.0;
+const double degrees2Radians = math.PI / 180.0;
/// Constant factor to convert and angle from radians to degrees.
-const double radians2Degrees = 180.0 / Math.PI;
+const double radians2Degrees = 180.0 / math.PI;
diff --git a/lib/src/vector_math/matrix2.dart b/lib/src/vector_math/matrix2.dart
index 265f3bf..d02adff 100644
--- a/lib/src/vector_math/matrix2.dart
+++ b/lib/src/vector_math/matrix2.dart
@@ -366,8 +366,8 @@
/// Turns the matrix into a rotation of [radians]
void setRotation(double radians) {
- final double c = Math.cos(radians);
- final double s = Math.sin(radians);
+ final double c = math.cos(radians);
+ final double s = math.sin(radians);
_m2storage[0] = c;
_m2storage[1] = s;
_m2storage[2] = -s;
diff --git a/lib/src/vector_math/matrix3.dart b/lib/src/vector_math/matrix3.dart
index 254d76b..a8f0e49 100644
--- a/lib/src/vector_math/matrix3.dart
+++ b/lib/src/vector_math/matrix3.dart
@@ -538,8 +538,8 @@
/// Turns the matrix into a rotation of [radians] around X
void setRotationX(double radians) {
- final double c = Math.cos(radians);
- final double s = Math.sin(radians);
+ final double c = math.cos(radians);
+ final double s = math.sin(radians);
_m3storage[0] = 1.0;
_m3storage[1] = 0.0;
_m3storage[2] = 0.0;
@@ -553,8 +553,8 @@
/// Turns the matrix into a rotation of [radians] around Y
void setRotationY(double radians) {
- final double c = Math.cos(radians);
- final double s = Math.sin(radians);
+ final double c = math.cos(radians);
+ final double s = math.sin(radians);
_m3storage[0] = c;
_m3storage[1] = 0.0;
_m3storage[2] = s;
@@ -568,8 +568,8 @@
/// Turns the matrix into a rotation of [radians] around Z
void setRotationZ(double radians) {
- final double c = Math.cos(radians);
- final double s = Math.sin(radians);
+ final double c = math.cos(radians);
+ final double s = math.sin(radians);
_m3storage[0] = c;
_m3storage[1] = s;
_m3storage[2] = 0.0;
diff --git a/lib/src/vector_math/matrix4.dart b/lib/src/vector_math/matrix4.dart
index 492d7a3..c722dd6 100644
--- a/lib/src/vector_math/matrix4.dart
+++ b/lib/src/vector_math/matrix4.dart
@@ -287,22 +287,22 @@
/// Skew matrix around X axis
factory Matrix4.skewX(double alpha) {
final Matrix4 m = new Matrix4.identity();
- m._m4storage[4] = Math.tan(alpha);
+ m._m4storage[4] = math.tan(alpha);
return m;
}
/// Skew matrix around Y axis.
factory Matrix4.skewY(double beta) {
final Matrix4 m = new Matrix4.identity();
- m._m4storage[1] = Math.tan(beta);
+ m._m4storage[1] = math.tan(beta);
return m;
}
/// Skew matrix around X axis (alpha) and Y axis (beta).
factory Matrix4.skew(double alpha, double beta) {
final Matrix4 m = new Matrix4.identity();
- m._m4storage[1] = Math.tan(beta);
- m._m4storage[4] = Math.tan(alpha);
+ m._m4storage[1] = math.tan(beta);
+ m._m4storage[4] = math.tan(alpha);
return m;
}
@@ -745,8 +745,8 @@
final double x = axisStorage[0] / len;
final double y = axisStorage[1] / len;
final double z = axisStorage[2] / len;
- final double c = Math.cos(angle);
- final double s = Math.sin(angle);
+ final double c = math.cos(angle);
+ final double s = math.sin(angle);
final double C = 1.0 - c;
final double m11 = x * x * C + c;
final double m12 = x * y * C - z * s;
@@ -797,8 +797,8 @@
/// Rotate this [angle] radians around X
void rotateX(double angle) {
- final double cosAngle = Math.cos(angle);
- final double sinAngle = Math.sin(angle);
+ final double cosAngle = math.cos(angle);
+ final double sinAngle = math.sin(angle);
final double t1 = _m4storage[4] * cosAngle + _m4storage[8] * sinAngle;
final double t2 = _m4storage[5] * cosAngle + _m4storage[9] * sinAngle;
final double t3 = _m4storage[6] * cosAngle + _m4storage[10] * sinAngle;
@@ -819,8 +819,8 @@
/// Rotate this matrix [angle] radians around Y
void rotateY(double angle) {
- final double cosAngle = Math.cos(angle);
- final double sinAngle = Math.sin(angle);
+ final double cosAngle = math.cos(angle);
+ final double sinAngle = math.sin(angle);
final double t1 = _m4storage[0] * cosAngle + _m4storage[8] * -sinAngle;
final double t2 = _m4storage[1] * cosAngle + _m4storage[9] * -sinAngle;
final double t3 = _m4storage[2] * cosAngle + _m4storage[10] * -sinAngle;
@@ -841,8 +841,8 @@
/// Rotate this matrix [angle] radians around Z
void rotateZ(double angle) {
- final double cosAngle = Math.cos(angle);
- final double sinAngle = Math.sin(angle);
+ final double cosAngle = math.cos(angle);
+ final double sinAngle = math.sin(angle);
final double t1 = _m4storage[0] * cosAngle + _m4storage[4] * sinAngle;
final double t2 = _m4storage[1] * cosAngle + _m4storage[5] * sinAngle;
final double t3 = _m4storage[2] * cosAngle + _m4storage[6] * sinAngle;
@@ -1183,7 +1183,7 @@
final double scaleZSq = _m4storage[8] * _m4storage[8] +
_m4storage[9] * _m4storage[9] +
_m4storage[10] * _m4storage[10];
- return Math.sqrt(Math.max(scaleXSq, Math.max(scaleYSq, scaleZSq)));
+ return math.sqrt(math.max(scaleXSq, math.max(scaleYSq, scaleZSq)));
}
/// Transposes just the upper 3x3 rotation matrix.
@@ -1316,8 +1316,8 @@
/// Sets the upper 3x3 to a rotation of [radians] around X
void setRotationX(double radians) {
- final double c = Math.cos(radians);
- final double s = Math.sin(radians);
+ final double c = math.cos(radians);
+ final double s = math.sin(radians);
_m4storage[0] = 1.0;
_m4storage[1] = 0.0;
_m4storage[2] = 0.0;
@@ -1334,8 +1334,8 @@
/// Sets the upper 3x3 to a rotation of [radians] around Y
void setRotationY(double radians) {
- final double c = Math.cos(radians);
- final double s = Math.sin(radians);
+ final double c = math.cos(radians);
+ final double s = math.sin(radians);
_m4storage[0] = c;
_m4storage[1] = 0.0;
_m4storage[2] = -s;
@@ -1352,8 +1352,8 @@
/// Sets the upper 3x3 to a rotation of [radians] around Z
void setRotationZ(double radians) {
- final double c = Math.cos(radians);
- final double s = Math.sin(radians);
+ final double c = math.cos(radians);
+ final double s = math.sin(radians);
_m4storage[0] = c;
_m4storage[1] = s;
_m4storage[2] = 0.0;
diff --git a/lib/src/vector_math/opengl.dart b/lib/src/vector_math/opengl.dart
index 211660d..50b1b53 100644
--- a/lib/src/vector_math/opengl.dart
+++ b/lib/src/vector_math/opengl.dart
@@ -110,7 +110,7 @@
/// (always positive).
void setPerspectiveMatrix(Matrix4 perspectiveMatrix, double fovYRadians,
double aspectRatio, double zNear, double zFar) {
- final double height = Math.tan(fovYRadians * 0.5);
+ final double height = math.tan(fovYRadians * 0.5);
final double width = height * aspectRatio;
final double near_minus_far = zNear - zFar;
@@ -149,7 +149,7 @@
/// (always positive).
void setInfiniteMatrix(Matrix4 infiniteMatrix, double fovYRadians,
double aspectRatio, double zNear) {
- final double height = Math.tan(fovYRadians * 0.5);
+ final double height = math.tan(fovYRadians * 0.5);
final double width = height * aspectRatio;
infiniteMatrix
diff --git a/lib/src/vector_math/quaternion.dart b/lib/src/vector_math/quaternion.dart
index 9fbd348..0370e11 100644
--- a/lib/src/vector_math/quaternion.dart
+++ b/lib/src/vector_math/quaternion.dart
@@ -64,7 +64,7 @@
/// Constructs a quaternion with a random rotation. The random number
/// generator [rn] is used to generate the random numbers for the rotation.
- factory Quaternion.random(Math.Random rn) =>
+ factory Quaternion.random(math.Random rn) =>
new Quaternion._()..setRandom(rn);
/// Constructs a quaternion set to the identity quaternion.
@@ -114,12 +114,12 @@
if (len == 0.0) {
return;
}
- final double halfSin = Math.sin(radians * 0.5) / len;
+ final double halfSin = math.sin(radians * 0.5) / len;
final Float32List axisStorage = axis.storage;
_qStorage[0] = axisStorage[0] * halfSin;
_qStorage[1] = axisStorage[1] * halfSin;
_qStorage[2] = axisStorage[2] * halfSin;
- _qStorage[3] = Math.cos(radians * 0.5);
+ _qStorage[3] = math.cos(radians * 0.5);
}
/// Set the quaternion with rotation from a rotation matrix [rotationMatrix].
@@ -127,7 +127,7 @@
final Float32List rotationMatrixStorage = rotationMatrix.storage;
final double trace = rotationMatrix.trace();
if (trace > 0.0) {
- double s = Math.sqrt(trace + 1.0);
+ double s = math.sqrt(trace + 1.0);
_qStorage[3] = s * 0.5;
s = 0.5 / s;
_qStorage[0] = (rotationMatrixStorage[5] - rotationMatrixStorage[7]) * s;
@@ -139,7 +139,7 @@
: (rotationMatrixStorage[0] < rotationMatrixStorage[8] ? 2 : 0);
final int j = (i + 1) % 3;
final int k = (i + 2) % 3;
- double s = Math.sqrt(rotationMatrixStorage[rotationMatrix.index(i, i)] -
+ double s = math.sqrt(rotationMatrixStorage[rotationMatrix.index(i, i)] -
rotationMatrixStorage[rotationMatrix.index(j, j)] -
rotationMatrixStorage[rotationMatrix.index(k, k)] +
1.0);
@@ -162,12 +162,12 @@
final Vector3 v2 = b.normalized();
final double c = v1.dot(v2);
- double angle = Math.acos(c);
+ double angle = math.acos(c);
Vector3 axis = v1.cross(v2);
if ((1.0 + c).abs() < 0.0005) {
// c \approx -1 indicates 180 degree rotation
- angle = Math.PI;
+ angle = math.PI;
// a and b are parallel in opposite directions. We need any
// vector as our rotation axis that is perpendicular.
@@ -190,18 +190,18 @@
/// Set the quaternion to a random rotation. The random number generator [rn]
/// is used to generate the random numbers for the rotation.
- void setRandom(Math.Random rn) {
+ void setRandom(math.Random rn) {
// From: "Uniform Random Rotations", Ken Shoemake, Graphics Gems III,
// pg. 124-132.
final double x0 = rn.nextDouble();
- final double r1 = Math.sqrt(1.0 - x0);
- final double r2 = Math.sqrt(x0);
- final double t1 = Math.PI * 2.0 * rn.nextDouble();
- final double t2 = Math.PI * 2.0 * rn.nextDouble();
- final double c1 = Math.cos(t1);
- final double s1 = Math.sin(t1);
- final double c2 = Math.cos(t2);
- final double s2 = Math.sin(t2);
+ final double r1 = math.sqrt(1.0 - x0);
+ final double r2 = math.sqrt(x0);
+ final double t1 = math.PI * 2.0 * rn.nextDouble();
+ final double t2 = math.PI * 2.0 * rn.nextDouble();
+ final double c1 = math.cos(t1);
+ final double s1 = math.sin(t1);
+ final double c2 = math.cos(t2);
+ final double s2 = math.sin(t2);
_qStorage[0] = s1 * r1;
_qStorage[1] = c1 * r1;
_qStorage[2] = s2 * r2;
@@ -235,12 +235,12 @@
final double halfYaw = yaw * 0.5;
final double halfPitch = pitch * 0.5;
final double halfRoll = roll * 0.5;
- final double cosYaw = Math.cos(halfYaw);
- final double sinYaw = Math.sin(halfYaw);
- final double cosPitch = Math.cos(halfPitch);
- final double sinPitch = Math.sin(halfPitch);
- final double cosRoll = Math.cos(halfRoll);
- final double sinRoll = Math.sin(halfRoll);
+ final double cosYaw = math.cos(halfYaw);
+ final double sinYaw = math.sin(halfYaw);
+ final double cosPitch = math.cos(halfPitch);
+ final double sinPitch = math.sin(halfPitch);
+ final double cosRoll = math.cos(halfRoll);
+ final double sinRoll = math.sin(halfRoll);
_qStorage[0] = cosRoll * sinPitch * cosYaw + sinRoll * cosPitch * sinYaw;
_qStorage[1] = cosRoll * cosPitch * sinYaw - sinRoll * sinPitch * cosYaw;
_qStorage[2] = sinRoll * cosPitch * cosYaw - cosRoll * sinPitch * sinYaw;
@@ -287,7 +287,7 @@
Quaternion inverted() => clone()..inverse();
/// [radians] of rotation around the [axis] of the rotation.
- double get radians => 2.0 * Math.acos(_qStorage[3]);
+ double get radians => 2.0 * math.acos(_qStorage[3]);
/// [axis] of rotation.
Vector3 get axis {
@@ -297,7 +297,7 @@
return new Vector3.zero();
}
- final double scale = 1.0 / Math.sqrt(den);
+ final double scale = 1.0 / math.sqrt(den);
return new Vector3(
_qStorage[0] * scale, _qStorage[1] * scale, _qStorage[2] * scale);
}
@@ -312,7 +312,7 @@
}
/// Length.
- double get length => Math.sqrt(length2);
+ double get length => math.sqrt(length2);
/// Returns a copy of [v] rotated by quaternion.
Vector3 rotated(Vector3 v) {
diff --git a/lib/src/vector_math/ray.dart b/lib/src/vector_math/ray.dart
index be07926..60efc11 100644
--- a/lib/src/vector_math/ray.dart
+++ b/lib/src/vector_math/ray.dart
@@ -63,7 +63,7 @@
if (m2 > r2) {
return null;
}
- final double q = Math.sqrt(r2 - m2);
+ final double q = math.sqrt(r2 - m2);
return (l2 > r2) ? s - q : s + q;
}
diff --git a/lib/src/vector_math/third_party/noise.dart b/lib/src/vector_math/third_party/noise.dart
index b1fa59f..a20aa40 100644
--- a/lib/src/vector_math/third_party/noise.dart
+++ b/lib/src/vector_math/third_party/noise.dart
@@ -82,12 +82,12 @@
List<int> _permMod12;
// Skewing and unskewing factors for 2, 3, and 4 dimensions
- static final double _F2 = 0.5 * (Math.sqrt(3.0) - 1.0);
- static final double _G2 = (3.0 - Math.sqrt(3.0)) / 6.0;
+ static final double _F2 = 0.5 * (math.sqrt(3.0) - 1.0);
+ static final double _G2 = (3.0 - math.sqrt(3.0)) / 6.0;
static const double _F3 = 1.0 / 3.0;
static const double _G3 = 1.0 / 6.0;
- static final double _F4 = (Math.sqrt(5.0) - 1.0) / 4.0;
- static final double _G4 = (5.0 - Math.sqrt(5.0)) / 20.0;
+ static final double _F4 = (math.sqrt(5.0) - 1.0) / 4.0;
+ static final double _G4 = (5.0 - math.sqrt(5.0)) / 20.0;
double _dot2(List<double> g, double x, double y) => g[0] * x + g[1] * y;
@@ -97,8 +97,8 @@
double _dot4(List<double> g, double x, double y, double z, double w) =>
g[0] * x + g[1] * y + g[2] * z + g[3] * w;
- SimplexNoise([Math.Random r]) {
- r ??= new Math.Random();
+ SimplexNoise([math.Random r]) {
+ r ??= new math.Random();
final List<int> p =
new List<int>.generate(256, (_) => r.nextInt(256), growable: false);
_perm = new List<int>.generate(p.length * 2, (int i) => p[i % p.length],
diff --git a/lib/src/vector_math/vector.dart b/lib/src/vector_math/vector.dart
index 6207f07..a6952a4 100644
--- a/lib/src/vector_math/vector.dart
+++ b/lib/src/vector_math/vector.dart
@@ -37,11 +37,11 @@
/// Sets [u] and [v] to be two vectors orthogonal to each other and
/// [planeNormal].
void buildPlaneVectors(final Vector3 planeNormal, Vector3 u, Vector3 v) {
- if (planeNormal.z.abs() > Math.SQRT1_2) {
+ if (planeNormal.z.abs() > math.SQRT1_2) {
// choose u in y-z plane
final double a =
planeNormal.y * planeNormal.y + planeNormal.z * planeNormal.z;
- final double k = 1.0 / Math.sqrt(a);
+ final double k = 1.0 / math.sqrt(a);
u
..x = 0.0
..y = -planeNormal.z * k
@@ -55,7 +55,7 @@
// choose u in x-y plane
final double a =
planeNormal.x * planeNormal.x + planeNormal.y * planeNormal.y;
- final double k = 1.0 / Math.sqrt(a);
+ final double k = 1.0 / math.sqrt(a);
u
..x = -planeNormal[1] * k
..y = planeNormal[0] * k
diff --git a/lib/src/vector_math/vector2.dart b/lib/src/vector_math/vector2.dart
index ab06cf2..30b6f13 100644
--- a/lib/src/vector_math/vector2.dart
+++ b/lib/src/vector_math/vector2.dart
@@ -15,15 +15,15 @@
/// Set the values of [result] to the minimum of [a] and [b] for each line.
static void min(Vector2 a, Vector2 b, Vector2 result) {
result
- ..x = Math.min(a.x, b.x)
- ..y = Math.min(a.y, b.y);
+ ..x = math.min(a.x, b.x)
+ ..y = math.min(a.y, b.y);
}
/// Set the values of [result] to the maximum of [a] and [b] for each line.
static void max(Vector2 a, Vector2 b, Vector2 result) {
result
- ..x = Math.max(a.x, b.x)
- ..y = Math.max(a.y, b.y);
+ ..x = math.max(a.x, b.x)
+ ..y = math.max(a.y, b.y);
}
/// Interpolate between [min] and [max] with the amount of [a] using a linear
@@ -60,8 +60,8 @@
/// Generate random vector in the range (0, 0) to (1, 1). You can
/// optionally pass your own random number generator.
- factory Vector2.random([Math.Random rng]) {
- rng = rng == null ? new Math.Random() : rng;
+ factory Vector2.random([math.Random rng]) {
+ rng = rng == null ? new math.Random() : rng;
return new Vector2(rng.nextDouble(), rng.nextDouble());
}
@@ -144,7 +144,7 @@
}
/// Length.
- double get length => Math.sqrt(length2);
+ double get length => math.sqrt(length2);
/// Length squared.
double get length2 {
@@ -183,7 +183,7 @@
}
/// Distance from [this] to [arg]
- double distanceTo(Vector2 arg) => Math.sqrt(distanceToSquared(arg));
+ double distanceTo(Vector2 arg) => math.sqrt(distanceToSquared(arg));
/// Squared distance from [this] to [arg]
double distanceToSquared(Vector2 arg) {
@@ -202,7 +202,7 @@
final double d = dot(other);
- return Math.acos(d.clamp(-1.0, 1.0));
+ return math.acos(d.clamp(-1.0, 1.0));
}
/// Returns the signed angle between [this] and [other] in radians.
@@ -215,7 +215,7 @@
final double s = cross(other);
final double c = dot(other);
- return Math.atan2(s, c);
+ return math.atan2(s, c);
}
/// Inner product.
diff --git a/lib/src/vector_math/vector3.dart b/lib/src/vector_math/vector3.dart
index f46ab60..d2644fa 100644
--- a/lib/src/vector_math/vector3.dart
+++ b/lib/src/vector_math/vector3.dart
@@ -15,17 +15,17 @@
/// Set the values of [result] to the minimum of [a] and [b] for each line.
static void min(Vector3 a, Vector3 b, Vector3 result) {
result
- ..x = Math.min(a.x, b.x)
- ..y = Math.min(a.y, b.y)
- ..z = Math.min(a.z, b.z);
+ ..x = math.min(a.x, b.x)
+ ..y = math.min(a.y, b.y)
+ ..z = math.min(a.z, b.z);
}
/// Set the values of [result] to the maximum of [a] and [b] for each line.
static void max(Vector3 a, Vector3 b, Vector3 result) {
result
- ..x = Math.max(a.x, b.x)
- ..y = Math.max(a.y, b.y)
- ..z = Math.max(a.z, b.z);
+ ..x = math.max(a.x, b.x)
+ ..y = math.max(a.y, b.y)
+ ..z = math.max(a.z, b.z);
}
/// Interpolate between [min] and [max] with the amount of [a] using a linear
@@ -64,8 +64,8 @@
/// Generate random vector in the range (0, 0, 0) to (1, 1, 1). You can
/// optionally pass your own random number generator.
- factory Vector3.random([Math.Random rng]) {
- rng = rng == null ? new Math.Random() : rng;
+ factory Vector3.random([math.Random rng]) {
+ rng = rng == null ? new math.Random() : rng;
return new Vector3(rng.nextDouble(), rng.nextDouble(), rng.nextDouble());
}
@@ -154,7 +154,7 @@
}
/// Length.
- double get length => Math.sqrt(length2);
+ double get length => math.sqrt(length2);
/// Length squared.
double get length2 {
@@ -195,7 +195,7 @@
}
/// Distance from [this] to [arg]
- double distanceTo(Vector3 arg) => Math.sqrt(distanceToSquared(arg));
+ double distanceTo(Vector3 arg) => math.sqrt(distanceToSquared(arg));
/// Squared distance from [this] to [arg]
double distanceToSquared(Vector3 arg) {
@@ -218,7 +218,7 @@
final double d = dot(other);
- return Math.acos(d.clamp(-1.0, 1.0));
+ return math.acos(d.clamp(-1.0, 1.0));
}
/// Returns the signed angle between [this] and [other] around [normal]
diff --git a/lib/src/vector_math/vector4.dart b/lib/src/vector_math/vector4.dart
index 7117310..e1f312a 100644
--- a/lib/src/vector_math/vector4.dart
+++ b/lib/src/vector_math/vector4.dart
@@ -11,19 +11,19 @@
/// Set the values of [result] to the minimum of [a] and [b] for each line.
static void min(Vector4 a, Vector4 b, Vector4 result) {
result
- ..x = Math.min(a.x, b.x)
- ..y = Math.min(a.y, b.y)
- ..z = Math.min(a.z, b.z)
- ..w = Math.min(a.w, b.w);
+ ..x = math.min(a.x, b.x)
+ ..y = math.min(a.y, b.y)
+ ..z = math.min(a.z, b.z)
+ ..w = math.min(a.w, b.w);
}
/// Set the values of [result] to the maximum of [a] and [b] for each line.
static void max(Vector4 a, Vector4 b, Vector4 result) {
result
- ..x = Math.max(a.x, b.x)
- ..y = Math.max(a.y, b.y)
- ..z = Math.max(a.z, b.z)
- ..w = Math.max(a.w, b.w);
+ ..x = math.max(a.x, b.x)
+ ..y = math.max(a.y, b.y)
+ ..z = math.max(a.z, b.z)
+ ..w = math.max(a.w, b.w);
}
/// Interpolate between [min] and [max] with the amount of [a] using a linear
@@ -70,8 +70,8 @@
/// Generate random vector in the range (0, 0, 0, 0) to (1, 1, 1, 1). You can
/// optionally pass your own random number generator.
- factory Vector4.random([Math.Random rng]) {
- rng = rng == null ? new Math.Random() : rng;
+ factory Vector4.random([math.Random rng]) {
+ rng = rng == null ? new math.Random() : rng;
return new Vector4(
rng.nextDouble(), rng.nextDouble(), rng.nextDouble(), rng.nextDouble());
}
@@ -176,7 +176,7 @@
}
/// Length.
- double get length => Math.sqrt(length2);
+ double get length => math.sqrt(length2);
/// Length squared.
double get length2 {
@@ -219,7 +219,7 @@
}
/// Distance from [this] to [arg]
- double distanceTo(Vector4 arg) => Math.sqrt(distanceToSquared(arg));
+ double distanceTo(Vector4 arg) => math.sqrt(distanceToSquared(arg));
/// Squared distance from [this] to [arg]
double distanceToSquared(Vector4 arg) {
diff --git a/lib/vector_math.dart b/lib/vector_math.dart
index c7cfaa9..a9c1a32 100644
--- a/lib/vector_math.dart
+++ b/lib/vector_math.dart
@@ -19,8 +19,8 @@
/// numbers for storage.
library vector_math;
+import 'dart:math' as math;
import 'dart:typed_data';
-import 'dart:math' as Math;
import 'hash.dart' as quiver;
part 'src/vector_math/utilities.dart';