Fix more Dart 2 core library constant names. (#194)
diff --git a/changelog.md b/changelog.md
index 8e9c587..dcf6252 100644
--- a/changelog.md
+++ b/changelog.md
@@ -1,5 +1,9 @@
# Changelog - vector_math
+## v 2.0.9 - July 2018
+
+- Internal fix to use Dart 2 core library constant names.
+
## v 2.0.8 - Unreleased
## v 2.0.7 - April 2018
diff --git a/lib/src/vector_math/constants.dart b/lib/src/vector_math/constants.dart
index e2c2840..3b3350d 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/quaternion.dart b/lib/src/vector_math/quaternion.dart
index c25305b..ec090d7 100644
--- a/lib/src/vector_math/quaternion.dart
+++ b/lib/src/vector_math/quaternion.dart
@@ -167,7 +167,7 @@
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.
@@ -196,8 +196,8 @@
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 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);
diff --git a/lib/src/vector_math/vector.dart b/lib/src/vector_math/vector.dart
index a6952a4..ab634d2 100644
--- a/lib/src/vector_math/vector.dart
+++ b/lib/src/vector_math/vector.dart
@@ -37,7 +37,7 @@
/// 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;
diff --git a/lib/src/vector_math_64/constants.dart b/lib/src/vector_math_64/constants.dart
index 32c5fc2..fb5c52e 100644
--- a/lib/src/vector_math_64/constants.dart
+++ b/lib/src/vector_math_64/constants.dart
@@ -5,7 +5,7 @@
part of vector_math_64;
/// 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_64/quaternion.dart b/lib/src/vector_math_64/quaternion.dart
index f2e626d..e8bd61d 100644
--- a/lib/src/vector_math_64/quaternion.dart
+++ b/lib/src/vector_math_64/quaternion.dart
@@ -167,7 +167,7 @@
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.
@@ -196,8 +196,8 @@
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 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);
diff --git a/lib/src/vector_math_64/vector.dart b/lib/src/vector_math_64/vector.dart
index 09e6428..e1bc2ed 100644
--- a/lib/src/vector_math_64/vector.dart
+++ b/lib/src/vector_math_64/vector.dart
@@ -37,7 +37,7 @@
/// 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;
diff --git a/lib/src/vector_math_geometry/generators/circle_generator.dart b/lib/src/vector_math_geometry/generators/circle_generator.dart
index 6a55dd0..54e70c1 100644
--- a/lib/src/vector_math_geometry/generators/circle_generator.dart
+++ b/lib/src/vector_math_geometry/generators/circle_generator.dart
@@ -21,7 +21,7 @@
List<GeometryFilter> filters,
int segments: 64,
double thetaStart: 0.0,
- double thetaLength: math.PI * 2.0}) {
+ double thetaLength: math.pi * 2.0}) {
_radius = radius;
_segments = segments;
_thetaStart = thetaStart;
diff --git a/lib/src/vector_math_geometry/generators/cylinder_generator.dart b/lib/src/vector_math_geometry/generators/cylinder_generator.dart
index 432224b..4a5d28c 100644
--- a/lib/src/vector_math_geometry/generators/cylinder_generator.dart
+++ b/lib/src/vector_math_geometry/generators/cylinder_generator.dart
@@ -70,32 +70,32 @@
for (int x = 0; x <= _segments; ++x) {
final double u = x / _segments;
- positions[i++] = new Vector3(_topRadius * math.cos(u * math.PI * 2.0),
- _height * 0.5, _topRadius * math.sin(u * math.PI * 2.0));
+ positions[i++] = new Vector3(_topRadius * math.cos(u * math.pi * 2.0),
+ _height * 0.5, _topRadius * math.sin(u * math.pi * 2.0));
}
// Bottom
for (int x = 0; x <= _segments; ++x) {
final double u = x / _segments;
- positions[i++] = new Vector3(_bottomRadius * math.cos(u * math.PI * 2.0),
- _height * -0.5, _bottomRadius * math.sin(u * math.PI * 2.0));
+ positions[i++] = new Vector3(_bottomRadius * math.cos(u * math.pi * 2.0),
+ _height * -0.5, _bottomRadius * math.sin(u * math.pi * 2.0));
}
// Top cap
for (int x = 0; x < _segments; ++x) {
final double u = x / _segments;
- positions[i++] = new Vector3(_topRadius * math.cos(u * math.PI * 2.0),
- _height * 0.5, _topRadius * math.sin(u * math.PI * 2.0));
+ positions[i++] = new Vector3(_topRadius * math.cos(u * math.pi * 2.0),
+ _height * 0.5, _topRadius * math.sin(u * math.pi * 2.0));
}
// Bottom cap
for (int x = 0; x < _segments; ++x) {
final double u = x / _segments;
- positions[i++] = new Vector3(_bottomRadius * math.cos(u * math.PI * 2.0),
- _height * -0.5, _bottomRadius * math.sin(u * math.PI * 2.0));
+ positions[i++] = new Vector3(_bottomRadius * math.cos(u * math.pi * 2.0),
+ _height * -0.5, _bottomRadius * math.sin(u * math.pi * 2.0));
}
}
@@ -118,14 +118,14 @@
// Top cap
for (int x = 0; x < _segments; ++x) {
- final double r = (x / _segments) * math.PI * 2.0;
+ final double r = (x / _segments) * math.pi * 2.0;
texCoords[i++] =
new Vector2((math.cos(r) * 0.5 + 0.5), (math.sin(r) * 0.5 + 0.5));
}
// Bottom cap
for (int x = 0; x < _segments; ++x) {
- final double r = (x / _segments) * math.PI * 2.0;
+ final double r = (x / _segments) * math.pi * 2.0;
texCoords[i++] =
new Vector2((math.cos(r) * 0.5 + 0.5), (math.sin(r) * 0.5 + 0.5));
}
diff --git a/lib/src/vector_math_geometry/generators/ring_generator.dart b/lib/src/vector_math_geometry/generators/ring_generator.dart
index ee7c852..4c25dc3 100644
--- a/lib/src/vector_math_geometry/generators/ring_generator.dart
+++ b/lib/src/vector_math_geometry/generators/ring_generator.dart
@@ -23,7 +23,7 @@
List<GeometryFilter> filters,
int segments: 64,
double thetaStart: 0.0,
- double thetaLength: math.PI * 2.0,
+ double thetaLength: math.pi * 2.0,
bool stripTextureCoordinates: true}) {
_innerRadius = innerRadius;
_outerRadius = outerRadius;
diff --git a/lib/src/vector_math_geometry/generators/sphere_generator.dart b/lib/src/vector_math_geometry/generators/sphere_generator.dart
index 66a970f..5b37f30 100644
--- a/lib/src/vector_math_geometry/generators/sphere_generator.dart
+++ b/lib/src/vector_math_geometry/generators/sphere_generator.dart
@@ -51,14 +51,14 @@
int i = 0;
for (int y = 0; y <= _latSegments; ++y) {
final double v = y / _latSegments;
- final double sv = math.sin(v * math.PI);
- final double cv = math.cos(v * math.PI);
+ final double sv = math.sin(v * math.pi);
+ final double cv = math.cos(v * math.pi);
for (int x = 0; x <= _lonSegments; ++x) {
final double u = x / _lonSegments;
- positions[i++] = new Vector3(_radius * math.cos(u * math.PI * 2.0) * sv,
- _radius * cv, _radius * math.sin(u * math.PI * 2.0) * sv);
+ positions[i++] = new Vector3(_radius * math.cos(u * math.pi * 2.0) * sv,
+ _radius * cv, _radius * math.sin(u * math.pi * 2.0) * sv);
}
}
}
@@ -83,14 +83,14 @@
int i = 0;
for (int y = 0; y <= _latSegments; ++y) {
final double v = y / _latSegments;
- final double sv = math.sin(v * math.PI);
- final double cv = math.cos(v * math.PI);
+ final double sv = math.sin(v * math.pi);
+ final double cv = math.cos(v * math.pi);
for (int x = 0; x <= _lonSegments; ++x) {
final double u = x / _lonSegments;
- normals[i++] = new Vector3(math.cos(u * math.PI * 2.0) * sv, cv,
- math.sin(u * math.PI * 2.0) * sv);
+ normals[i++] = new Vector3(math.cos(u * math.pi * 2.0) * sv, cv,
+ math.sin(u * math.pi * 2.0) * sv);
}
}
}
diff --git a/pubspec.yaml b/pubspec.yaml
index cfaf2e5..9381ece 100644
--- a/pubspec.yaml
+++ b/pubspec.yaml
@@ -1,5 +1,5 @@
name: vector_math
-version: 2.0.8
+version: 2.0.9
author: John McCutchan <john@johnmccutchan.com>
description: A Vector Math library for 2D and 3D applications.
homepage: https://github.com/google/vector_math.dart
diff --git a/test/aabb2_test.dart b/test/aabb2_test.dart
index a0c5191..b7c4106 100644
--- a/test/aabb2_test.dart
+++ b/test/aabb2_test.dart
@@ -165,7 +165,7 @@
}
void testAabb2Rotate() {
- final rotation = new Matrix3.rotationZ(math.PI / 4);
+ final rotation = new Matrix3.rotationZ(math.pi / 4);
final input = new Aabb2.minMax($v2(1.0, 1.0), $v2(3.0, 3.0));
final result = input..rotate(rotation);
@@ -179,7 +179,7 @@
}
void testAabb2Transform() {
- final rotation = new Matrix3.rotationZ(math.PI / 4);
+ final rotation = new Matrix3.rotationZ(math.pi / 4);
final input = new Aabb2.minMax($v2(1.0, 1.0), $v2(3.0, 3.0));
final result = input..transform(rotation);
diff --git a/test/matrix2_test.dart b/test/matrix2_test.dart
index 2c7b194..bfaf55a 100644
--- a/test/matrix2_test.dart
+++ b/test/matrix2_test.dart
@@ -53,7 +53,7 @@
}
void testMatrix2Transform() {
- var rot = new Matrix2.rotation(math.PI / 4);
+ var rot = new Matrix2.rotation(math.pi / 4);
final input = new Vector2(0.234245234259, 0.890723489233);
final expected = new Vector2(
diff --git a/test/matrix3_test.dart b/test/matrix3_test.dart
index 5721a3b..9308e70 100644
--- a/test/matrix3_test.dart
+++ b/test/matrix3_test.dart
@@ -188,9 +188,9 @@
}
void testMatrix3Transform() {
- Matrix3 rotX = new Matrix3.rotationX(math.PI / 4);
- Matrix3 rotY = new Matrix3.rotationY(math.PI / 4);
- Matrix3 rotZ = new Matrix3.rotationZ(math.PI / 4);
+ Matrix3 rotX = new Matrix3.rotationX(math.pi / 4);
+ Matrix3 rotY = new Matrix3.rotationY(math.pi / 4);
+ Matrix3 rotZ = new Matrix3.rotationZ(math.pi / 4);
final input = new Vector3(1.0, 0.0, 0.0);
relativeTest(rotX.transformed(input), input);
@@ -201,7 +201,7 @@
}
void testMatrix3Transform2() {
- Matrix3 rotZ = new Matrix3.rotationZ(math.PI / 4);
+ Matrix3 rotZ = new Matrix3.rotationZ(math.pi / 4);
Matrix3 trans = new Matrix3(1.0, 0.0, 3.0, 0.0, 1.0, 2.0, 3.0, 2.0, 1.0);
Matrix3 transB =
new Matrix3.fromList([1.0, 0.0, 3.0, 0.0, 1.0, 2.0, 3.0, 2.0, 1.0]);
@@ -216,8 +216,8 @@
}
void testMatrix3AbsoluteRotate2() {
- Matrix3 rotZ = new Matrix3.rotationZ(-math.PI / 4);
- Matrix3 rotZcw = new Matrix3.rotationZ(math.PI / 4);
+ Matrix3 rotZ = new Matrix3.rotationZ(-math.pi / 4);
+ Matrix3 rotZcw = new Matrix3.rotationZ(math.pi / 4);
// Add translation
rotZ.setEntry(2, 0, 3.0);
rotZ.setEntry(2, 1, 2.0);
diff --git a/test/matrix4_test.dart b/test/matrix4_test.dart
index a626c2f..e6f6caf 100644
--- a/test/matrix4_test.dart
+++ b/test/matrix4_test.dart
@@ -428,12 +428,12 @@
}
void testMatrix4GetRotation() {
- final mat4 = new Matrix4.rotationX(math.PI) *
- new Matrix4.rotationY(-math.PI) *
- new Matrix4.rotationZ(math.PI) as Matrix4;
- final mat3 = new Matrix3.rotationX(math.PI) *
- new Matrix3.rotationY(-math.PI) *
- new Matrix3.rotationZ(math.PI) as Matrix3;
+ final mat4 = new Matrix4.rotationX(math.pi) *
+ new Matrix4.rotationY(-math.pi) *
+ new Matrix4.rotationZ(math.pi) as Matrix4;
+ final mat3 = new Matrix3.rotationX(math.pi) *
+ new Matrix3.rotationY(-math.pi) *
+ new Matrix3.rotationZ(math.pi) as Matrix3;
final matRot = mat4.getRotation();
relativeTest(mat3, matRot);
@@ -489,7 +489,7 @@
}
void testMatrix4PerspectiveTransform() {
- final matrix = makePerspectiveMatrix(math.PI, 1.0, 1.0, 100.0);
+ final matrix = makePerspectiveMatrix(math.pi, 1.0, 1.0, 100.0);
final vec = new Vector3(10.0, 20.0, 30.0);
matrix.perspectiveTransform(vec);
diff --git a/test/obb3_test.dart b/test/obb3_test.dart
index c40ef02..49cd9b4 100644
--- a/test/obb3_test.dart
+++ b/test/obb3_test.dart
@@ -164,11 +164,11 @@
a.closestPointTo(b, closestPoint);
- absoluteTest(closestPoint, new Vector3(math.SQRT2, math.SQRT2, 2.0));
+ absoluteTest(closestPoint, new Vector3(math.sqrt2, math.sqrt2, 2.0));
a.closestPointTo(c, closestPoint);
- absoluteTest(closestPoint, new Vector3(math.SQRT2, math.SQRT2, -2.0));
+ absoluteTest(closestPoint, new Vector3(math.sqrt2, math.sqrt2, -2.0));
}
void testIntersectionObb3() {
diff --git a/test/opengl_matrix_test.dart b/test/opengl_matrix_test.dart
index c5f904e..a729bd0 100644
--- a/test/opengl_matrix_test.dart
+++ b/test/opengl_matrix_test.dart
@@ -65,7 +65,7 @@
}
void testPerspectiveMatrix() {
- final double fov = PI / 2;
+ final double fov = pi / 2;
final double aspectRatio = 2.0;
final double zNear = 1.0;
final double zFar = 100.0;
@@ -80,7 +80,7 @@
}
void testInfiniteMatrix() {
- final double fov = PI / 2;
+ final double fov = pi / 2;
final double aspectRatio = 2.0;
final double zNear = 1.0;
diff --git a/test/quaternion_test.dart b/test/quaternion_test.dart
index 459dffd..38cf3c3 100644
--- a/test/quaternion_test.dart
+++ b/test/quaternion_test.dart
@@ -181,8 +181,8 @@
// Test conversion to and from axis-angle representation
{
Quaternion q =
- new Quaternion.axisAngle(new Vector3(0.0, 1.0, 0.0), 0.5 * math.PI);
- relativeTest(q.radians, 0.5 * math.PI);
+ new Quaternion.axisAngle(new Vector3(0.0, 1.0, 0.0), 0.5 * math.pi);
+ relativeTest(q.radians, 0.5 * math.pi);
relativeTest(q.axis, new Vector3(0.0, 1.0, 0.0));
}
@@ -199,7 +199,7 @@
Vector3 a = new Vector3(1.0, 0.0, 0.0);
Vector3 b = new Vector3(0.0, 1.0, 0.0);
Quaternion q = new Quaternion.fromTwoVectors(a, b);
- relativeTest(q.radians, 0.5 * math.PI);
+ relativeTest(q.radians, 0.5 * math.pi);
relativeTest(q.axis, new Vector3(0.0, 0.0, 1.0));
}
{
@@ -215,7 +215,7 @@
Vector3 a = new Vector3(1.0, 0.0, 0.0);
Vector3 b = new Vector3(-1.0, 0.0, 0.0);
Quaternion q = new Quaternion.fromTwoVectors(a, b);
- relativeTest(q.radians, math.PI);
+ relativeTest(q.radians, math.pi);
}
}
diff --git a/test/utilities_test.dart b/test/utilities_test.dart
index 4f904ab..d51fb65 100644
--- a/test/utilities_test.dart
+++ b/test/utilities_test.dart
@@ -13,11 +13,11 @@
import 'test_utils.dart';
void testDegrees() {
- relativeTest(degrees(math.PI), 180.0);
+ relativeTest(degrees(math.pi), 180.0);
}
void testRadians() {
- relativeTest(radians(90.0), math.PI / 2.0);
+ relativeTest(radians(90.0), math.pi / 2.0);
}
void testMix() {
diff --git a/test/vector2_test.dart b/test/vector2_test.dart
index 4fa3c6a..eb6b20c 100644
--- a/test/vector2_test.dart
+++ b/test/vector2_test.dart
@@ -262,9 +262,9 @@
final tol = 1e-8;
expect(v0.angleTo(v0), equals(0.0));
- expect(v0.angleTo(v1), equals(math.PI / 2.0));
- expect(v0.angleTo(v2), closeTo(math.PI / 4.0, tol));
- expect(v0.angleTo(v3), closeTo(math.PI / 4.0, tol));
+ expect(v0.angleTo(v1), equals(math.pi / 2.0));
+ expect(v0.angleTo(v2), closeTo(math.pi / 4.0, tol));
+ expect(v0.angleTo(v3), closeTo(math.pi / 4.0, tol));
}
void testVector2AngleToSigned() {
@@ -273,9 +273,9 @@
final v2 = new Vector2(-1.0, 0.0);
expect(v0.angleToSigned(v0), equals(0.0));
- expect(v0.angleToSigned(v1), equals(math.PI / 2.0));
- expect(v1.angleToSigned(v0), equals(-math.PI / 2.0));
- expect(v0.angleToSigned(v2), equals(math.PI));
+ expect(v0.angleToSigned(v1), equals(math.pi / 2.0));
+ expect(v1.angleToSigned(v0), equals(-math.pi / 2.0));
+ expect(v0.angleToSigned(v2), equals(math.pi));
}
void testVector2Clamp() {
diff --git a/test/vector3_test.dart b/test/vector3_test.dart
index 516d716..0983329 100644
--- a/test/vector3_test.dart
+++ b/test/vector3_test.dart
@@ -362,9 +362,9 @@
final tol = 1e-8;
expect(v0.angleTo(v0), equals(0.0));
- expect(v0.angleTo(v1), equals(math.PI / 2.0));
- expect(v0.angleTo(v2), closeTo(math.PI / 4.0, tol));
- expect(v0.angleTo(v3), closeTo(math.PI / 4.0, tol));
+ expect(v0.angleTo(v1), equals(math.pi / 2.0));
+ expect(v0.angleTo(v2), closeTo(math.pi / 4.0, tol));
+ expect(v0.angleTo(v3), closeTo(math.pi / 4.0, tol));
}
void testVector3AngleToSigned() {
@@ -373,8 +373,8 @@
final n = new Vector3(0.0, 0.0, 1.0);
expect(v0.angleToSigned(v0, n), equals(0.0));
- expect(v0.angleToSigned(v1, n), equals(math.PI / 2.0));
- expect(v1.angleToSigned(v0, n), equals(-math.PI / 2.0));
+ expect(v0.angleToSigned(v1, n), equals(math.pi / 2.0));
+ expect(v1.angleToSigned(v0, n), equals(-math.pi / 2.0));
}
void testVector3Clamp() {