Skip to content

Commit 501a779

Browse files
munificenttvolkert
authored andcommitted
Fix more Dart 2 core library constant names. (#194)
1 parent 146509a commit 501a779

22 files changed

+74
-70
lines changed

changelog.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,9 @@
11
# Changelog - vector_math
22

3+
## v 2.0.9 - July 2018
4+
5+
- Internal fix to use Dart 2 core library constant names.
6+
37
## v 2.0.8 - Unreleased
48

59
## v 2.0.7 - April 2018

lib/src/vector_math/constants.dart

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
part of vector_math;
66

77
/// Constant factor to convert and angle from degrees to radians.
8-
const double degrees2Radians = math.PI / 180.0;
8+
const double degrees2Radians = math.pi / 180.0;
99

1010
/// Constant factor to convert and angle from radians to degrees.
11-
const double radians2Degrees = 180.0 / math.PI;
11+
const double radians2Degrees = 180.0 / math.pi;

lib/src/vector_math/quaternion.dart

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -167,7 +167,7 @@ class Quaternion {
167167

168168
if ((1.0 + c).abs() < 0.0005) {
169169
// c \approx -1 indicates 180 degree rotation
170-
angle = math.PI;
170+
angle = math.pi;
171171

172172
// a and b are parallel in opposite directions. We need any
173173
// vector as our rotation axis that is perpendicular.
@@ -196,8 +196,8 @@ class Quaternion {
196196
final double x0 = rn.nextDouble();
197197
final double r1 = math.sqrt(1.0 - x0);
198198
final double r2 = math.sqrt(x0);
199-
final double t1 = math.PI * 2.0 * rn.nextDouble();
200-
final double t2 = math.PI * 2.0 * rn.nextDouble();
199+
final double t1 = math.pi * 2.0 * rn.nextDouble();
200+
final double t2 = math.pi * 2.0 * rn.nextDouble();
201201
final double c1 = math.cos(t1);
202202
final double s1 = math.sin(t1);
203203
final double c2 = math.cos(t2);

lib/src/vector_math/vector.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ void cross2B(Vector2 x, double y, Vector2 out) {
3737
/// Sets [u] and [v] to be two vectors orthogonal to each other and
3838
/// [planeNormal].
3939
void buildPlaneVectors(final Vector3 planeNormal, Vector3 u, Vector3 v) {
40-
if (planeNormal.z.abs() > math.SQRT1_2) {
40+
if (planeNormal.z.abs() > math.sqrt1_2) {
4141
// choose u in y-z plane
4242
final double a =
4343
planeNormal.y * planeNormal.y + planeNormal.z * planeNormal.z;

lib/src/vector_math_64/constants.dart

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
part of vector_math_64;
66

77
/// Constant factor to convert and angle from degrees to radians.
8-
const double degrees2Radians = math.PI / 180.0;
8+
const double degrees2Radians = math.pi / 180.0;
99

1010
/// Constant factor to convert and angle from radians to degrees.
11-
const double radians2Degrees = 180.0 / math.PI;
11+
const double radians2Degrees = 180.0 / math.pi;

lib/src/vector_math_64/quaternion.dart

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -167,7 +167,7 @@ class Quaternion {
167167

168168
if ((1.0 + c).abs() < 0.0005) {
169169
// c \approx -1 indicates 180 degree rotation
170-
angle = math.PI;
170+
angle = math.pi;
171171

172172
// a and b are parallel in opposite directions. We need any
173173
// vector as our rotation axis that is perpendicular.
@@ -196,8 +196,8 @@ class Quaternion {
196196
final double x0 = rn.nextDouble();
197197
final double r1 = math.sqrt(1.0 - x0);
198198
final double r2 = math.sqrt(x0);
199-
final double t1 = math.PI * 2.0 * rn.nextDouble();
200-
final double t2 = math.PI * 2.0 * rn.nextDouble();
199+
final double t1 = math.pi * 2.0 * rn.nextDouble();
200+
final double t2 = math.pi * 2.0 * rn.nextDouble();
201201
final double c1 = math.cos(t1);
202202
final double s1 = math.sin(t1);
203203
final double c2 = math.cos(t2);

lib/src/vector_math_64/vector.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ void cross2B(Vector2 x, double y, Vector2 out) {
3737
/// Sets [u] and [v] to be two vectors orthogonal to each other and
3838
/// [planeNormal].
3939
void buildPlaneVectors(final Vector3 planeNormal, Vector3 u, Vector3 v) {
40-
if (planeNormal.z.abs() > math.SQRT1_2) {
40+
if (planeNormal.z.abs() > math.sqrt1_2) {
4141
// choose u in y-z plane
4242
final double a =
4343
planeNormal.y * planeNormal.y + planeNormal.z * planeNormal.z;

lib/src/vector_math_geometry/generators/circle_generator.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ class CircleGenerator extends GeometryGenerator {
2121
List<GeometryFilter> filters,
2222
int segments: 64,
2323
double thetaStart: 0.0,
24-
double thetaLength: math.PI * 2.0}) {
24+
double thetaLength: math.pi * 2.0}) {
2525
_radius = radius;
2626
_segments = segments;
2727
_thetaStart = thetaStart;

lib/src/vector_math_geometry/generators/cylinder_generator.dart

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -70,32 +70,32 @@ class CylinderGenerator extends GeometryGenerator {
7070
for (int x = 0; x <= _segments; ++x) {
7171
final double u = x / _segments;
7272

73-
positions[i++] = new Vector3(_topRadius * math.cos(u * math.PI * 2.0),
74-
_height * 0.5, _topRadius * math.sin(u * math.PI * 2.0));
73+
positions[i++] = new Vector3(_topRadius * math.cos(u * math.pi * 2.0),
74+
_height * 0.5, _topRadius * math.sin(u * math.pi * 2.0));
7575
}
7676

7777
// Bottom
7878
for (int x = 0; x <= _segments; ++x) {
7979
final double u = x / _segments;
8080

81-
positions[i++] = new Vector3(_bottomRadius * math.cos(u * math.PI * 2.0),
82-
_height * -0.5, _bottomRadius * math.sin(u * math.PI * 2.0));
81+
positions[i++] = new Vector3(_bottomRadius * math.cos(u * math.pi * 2.0),
82+
_height * -0.5, _bottomRadius * math.sin(u * math.pi * 2.0));
8383
}
8484

8585
// Top cap
8686
for (int x = 0; x < _segments; ++x) {
8787
final double u = x / _segments;
8888

89-
positions[i++] = new Vector3(_topRadius * math.cos(u * math.PI * 2.0),
90-
_height * 0.5, _topRadius * math.sin(u * math.PI * 2.0));
89+
positions[i++] = new Vector3(_topRadius * math.cos(u * math.pi * 2.0),
90+
_height * 0.5, _topRadius * math.sin(u * math.pi * 2.0));
9191
}
9292

9393
// Bottom cap
9494
for (int x = 0; x < _segments; ++x) {
9595
final double u = x / _segments;
9696

97-
positions[i++] = new Vector3(_bottomRadius * math.cos(u * math.PI * 2.0),
98-
_height * -0.5, _bottomRadius * math.sin(u * math.PI * 2.0));
97+
positions[i++] = new Vector3(_bottomRadius * math.cos(u * math.pi * 2.0),
98+
_height * -0.5, _bottomRadius * math.sin(u * math.pi * 2.0));
9999
}
100100
}
101101

@@ -118,14 +118,14 @@ class CylinderGenerator extends GeometryGenerator {
118118

119119
// Top cap
120120
for (int x = 0; x < _segments; ++x) {
121-
final double r = (x / _segments) * math.PI * 2.0;
121+
final double r = (x / _segments) * math.pi * 2.0;
122122
texCoords[i++] =
123123
new Vector2((math.cos(r) * 0.5 + 0.5), (math.sin(r) * 0.5 + 0.5));
124124
}
125125

126126
// Bottom cap
127127
for (int x = 0; x < _segments; ++x) {
128-
final double r = (x / _segments) * math.PI * 2.0;
128+
final double r = (x / _segments) * math.pi * 2.0;
129129
texCoords[i++] =
130130
new Vector2((math.cos(r) * 0.5 + 0.5), (math.sin(r) * 0.5 + 0.5));
131131
}

lib/src/vector_math_geometry/generators/ring_generator.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ class RingGenerator extends GeometryGenerator {
2323
List<GeometryFilter> filters,
2424
int segments: 64,
2525
double thetaStart: 0.0,
26-
double thetaLength: math.PI * 2.0,
26+
double thetaLength: math.pi * 2.0,
2727
bool stripTextureCoordinates: true}) {
2828
_innerRadius = innerRadius;
2929
_outerRadius = outerRadius;

lib/src/vector_math_geometry/generators/sphere_generator.dart

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -51,14 +51,14 @@ class SphereGenerator extends GeometryGenerator {
5151
int i = 0;
5252
for (int y = 0; y <= _latSegments; ++y) {
5353
final double v = y / _latSegments;
54-
final double sv = math.sin(v * math.PI);
55-
final double cv = math.cos(v * math.PI);
54+
final double sv = math.sin(v * math.pi);
55+
final double cv = math.cos(v * math.pi);
5656

5757
for (int x = 0; x <= _lonSegments; ++x) {
5858
final double u = x / _lonSegments;
5959

60-
positions[i++] = new Vector3(_radius * math.cos(u * math.PI * 2.0) * sv,
61-
_radius * cv, _radius * math.sin(u * math.PI * 2.0) * sv);
60+
positions[i++] = new Vector3(_radius * math.cos(u * math.pi * 2.0) * sv,
61+
_radius * cv, _radius * math.sin(u * math.pi * 2.0) * sv);
6262
}
6363
}
6464
}
@@ -83,14 +83,14 @@ class SphereGenerator extends GeometryGenerator {
8383
int i = 0;
8484
for (int y = 0; y <= _latSegments; ++y) {
8585
final double v = y / _latSegments;
86-
final double sv = math.sin(v * math.PI);
87-
final double cv = math.cos(v * math.PI);
86+
final double sv = math.sin(v * math.pi);
87+
final double cv = math.cos(v * math.pi);
8888

8989
for (int x = 0; x <= _lonSegments; ++x) {
9090
final double u = x / _lonSegments;
9191

92-
normals[i++] = new Vector3(math.cos(u * math.PI * 2.0) * sv, cv,
93-
math.sin(u * math.PI * 2.0) * sv);
92+
normals[i++] = new Vector3(math.cos(u * math.pi * 2.0) * sv, cv,
93+
math.sin(u * math.pi * 2.0) * sv);
9494
}
9595
}
9696
}

pubspec.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
name: vector_math
2-
version: 2.0.8
2+
version: 2.0.9
33
author: John McCutchan <john@johnmccutchan.com>
44
description: A Vector Math library for 2D and 3D applications.
55
homepage: https://github.com/google/vector_math.dart

test/aabb2_test.dart

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -165,7 +165,7 @@ void testAabb2HullPoint() {
165165
}
166166

167167
void testAabb2Rotate() {
168-
final rotation = new Matrix3.rotationZ(math.PI / 4);
168+
final rotation = new Matrix3.rotationZ(math.pi / 4);
169169
final input = new Aabb2.minMax($v2(1.0, 1.0), $v2(3.0, 3.0));
170170

171171
final result = input..rotate(rotation);
@@ -179,7 +179,7 @@ void testAabb2Rotate() {
179179
}
180180

181181
void testAabb2Transform() {
182-
final rotation = new Matrix3.rotationZ(math.PI / 4);
182+
final rotation = new Matrix3.rotationZ(math.pi / 4);
183183
final input = new Aabb2.minMax($v2(1.0, 1.0), $v2(3.0, 3.0));
184184

185185
final result = input..transform(rotation);

test/matrix2_test.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ void testMatrix2Determinant() {
5353
}
5454

5555
void testMatrix2Transform() {
56-
var rot = new Matrix2.rotation(math.PI / 4);
56+
var rot = new Matrix2.rotation(math.pi / 4);
5757
final input = new Vector2(0.234245234259, 0.890723489233);
5858

5959
final expected = new Vector2(

test/matrix3_test.dart

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -188,9 +188,9 @@ void testMatrix3SelfMultiplyTranspose() {
188188
}
189189

190190
void testMatrix3Transform() {
191-
Matrix3 rotX = new Matrix3.rotationX(math.PI / 4);
192-
Matrix3 rotY = new Matrix3.rotationY(math.PI / 4);
193-
Matrix3 rotZ = new Matrix3.rotationZ(math.PI / 4);
191+
Matrix3 rotX = new Matrix3.rotationX(math.pi / 4);
192+
Matrix3 rotY = new Matrix3.rotationY(math.pi / 4);
193+
Matrix3 rotZ = new Matrix3.rotationZ(math.pi / 4);
194194
final input = new Vector3(1.0, 0.0, 0.0);
195195

196196
relativeTest(rotX.transformed(input), input);
@@ -201,7 +201,7 @@ void testMatrix3Transform() {
201201
}
202202

203203
void testMatrix3Transform2() {
204-
Matrix3 rotZ = new Matrix3.rotationZ(math.PI / 4);
204+
Matrix3 rotZ = new Matrix3.rotationZ(math.pi / 4);
205205
Matrix3 trans = new Matrix3(1.0, 0.0, 3.0, 0.0, 1.0, 2.0, 3.0, 2.0, 1.0);
206206
Matrix3 transB =
207207
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 testMatrix3Transform2() {
216216
}
217217

218218
void testMatrix3AbsoluteRotate2() {
219-
Matrix3 rotZ = new Matrix3.rotationZ(-math.PI / 4);
220-
Matrix3 rotZcw = new Matrix3.rotationZ(math.PI / 4);
219+
Matrix3 rotZ = new Matrix3.rotationZ(-math.pi / 4);
220+
Matrix3 rotZcw = new Matrix3.rotationZ(math.pi / 4);
221221
// Add translation
222222
rotZ.setEntry(2, 0, 3.0);
223223
rotZ.setEntry(2, 1, 2.0);

test/matrix4_test.dart

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -428,12 +428,12 @@ void testMatrix4Rotate() {
428428
}
429429

430430
void testMatrix4GetRotation() {
431-
final mat4 = new Matrix4.rotationX(math.PI) *
432-
new Matrix4.rotationY(-math.PI) *
433-
new Matrix4.rotationZ(math.PI) as Matrix4;
434-
final mat3 = new Matrix3.rotationX(math.PI) *
435-
new Matrix3.rotationY(-math.PI) *
436-
new Matrix3.rotationZ(math.PI) as Matrix3;
431+
final mat4 = new Matrix4.rotationX(math.pi) *
432+
new Matrix4.rotationY(-math.pi) *
433+
new Matrix4.rotationZ(math.pi) as Matrix4;
434+
final mat3 = new Matrix3.rotationX(math.pi) *
435+
new Matrix3.rotationY(-math.pi) *
436+
new Matrix3.rotationZ(math.pi) as Matrix3;
437437
final matRot = mat4.getRotation();
438438

439439
relativeTest(mat3, matRot);
@@ -489,7 +489,7 @@ void testMatrix4Dot() {
489489
}
490490

491491
void testMatrix4PerspectiveTransform() {
492-
final matrix = makePerspectiveMatrix(math.PI, 1.0, 1.0, 100.0);
492+
final matrix = makePerspectiveMatrix(math.pi, 1.0, 1.0, 100.0);
493493
final vec = new Vector3(10.0, 20.0, 30.0);
494494

495495
matrix.perspectiveTransform(vec);

test/obb3_test.dart

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -164,11 +164,11 @@ void testClosestPointTo() {
164164

165165
a.closestPointTo(b, closestPoint);
166166

167-
absoluteTest(closestPoint, new Vector3(math.SQRT2, math.SQRT2, 2.0));
167+
absoluteTest(closestPoint, new Vector3(math.sqrt2, math.sqrt2, 2.0));
168168

169169
a.closestPointTo(c, closestPoint);
170170

171-
absoluteTest(closestPoint, new Vector3(math.SQRT2, math.SQRT2, -2.0));
171+
absoluteTest(closestPoint, new Vector3(math.sqrt2, math.sqrt2, -2.0));
172172
}
173173

174174
void testIntersectionObb3() {

test/opengl_matrix_test.dart

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ void testFrustumMatrix() {
6565
}
6666

6767
void testPerspectiveMatrix() {
68-
final double fov = PI / 2;
68+
final double fov = pi / 2;
6969
final double aspectRatio = 2.0;
7070
final double zNear = 1.0;
7171
final double zFar = 100.0;
@@ -80,7 +80,7 @@ void testPerspectiveMatrix() {
8080
}
8181

8282
void testInfiniteMatrix() {
83-
final double fov = PI / 2;
83+
final double fov = pi / 2;
8484
final double aspectRatio = 2.0;
8585
final double zNear = 1.0;
8686

test/quaternion_test.dart

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -181,8 +181,8 @@ void testQuaternionAxisAngle() {
181181
// Test conversion to and from axis-angle representation
182182
{
183183
Quaternion q =
184-
new Quaternion.axisAngle(new Vector3(0.0, 1.0, 0.0), 0.5 * math.PI);
185-
relativeTest(q.radians, 0.5 * math.PI);
184+
new Quaternion.axisAngle(new Vector3(0.0, 1.0, 0.0), 0.5 * math.pi);
185+
relativeTest(q.radians, 0.5 * math.pi);
186186
relativeTest(q.axis, new Vector3(0.0, 1.0, 0.0));
187187
}
188188

@@ -199,7 +199,7 @@ void testFromTwoVectors() {
199199
Vector3 a = new Vector3(1.0, 0.0, 0.0);
200200
Vector3 b = new Vector3(0.0, 1.0, 0.0);
201201
Quaternion q = new Quaternion.fromTwoVectors(a, b);
202-
relativeTest(q.radians, 0.5 * math.PI);
202+
relativeTest(q.radians, 0.5 * math.pi);
203203
relativeTest(q.axis, new Vector3(0.0, 0.0, 1.0));
204204
}
205205
{
@@ -215,7 +215,7 @@ void testFromTwoVectors() {
215215
Vector3 a = new Vector3(1.0, 0.0, 0.0);
216216
Vector3 b = new Vector3(-1.0, 0.0, 0.0);
217217
Quaternion q = new Quaternion.fromTwoVectors(a, b);
218-
relativeTest(q.radians, math.PI);
218+
relativeTest(q.radians, math.pi);
219219
}
220220
}
221221

test/utilities_test.dart

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,11 +13,11 @@ import 'package:vector_math/vector_math.dart';
1313
import 'test_utils.dart';
1414

1515
void testDegrees() {
16-
relativeTest(degrees(math.PI), 180.0);
16+
relativeTest(degrees(math.pi), 180.0);
1717
}
1818

1919
void testRadians() {
20-
relativeTest(radians(90.0), math.PI / 2.0);
20+
relativeTest(radians(90.0), math.pi / 2.0);
2121
}
2222

2323
void testMix() {

test/vector2_test.dart

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -262,9 +262,9 @@ void testVector2AngleTo() {
262262
final tol = 1e-8;
263263

264264
expect(v0.angleTo(v0), equals(0.0));
265-
expect(v0.angleTo(v1), equals(math.PI / 2.0));
266-
expect(v0.angleTo(v2), closeTo(math.PI / 4.0, tol));
267-
expect(v0.angleTo(v3), closeTo(math.PI / 4.0, tol));
265+
expect(v0.angleTo(v1), equals(math.pi / 2.0));
266+
expect(v0.angleTo(v2), closeTo(math.pi / 4.0, tol));
267+
expect(v0.angleTo(v3), closeTo(math.pi / 4.0, tol));
268268
}
269269

270270
void testVector2AngleToSigned() {
@@ -273,9 +273,9 @@ void testVector2AngleToSigned() {
273273
final v2 = new Vector2(-1.0, 0.0);
274274

275275
expect(v0.angleToSigned(v0), equals(0.0));
276-
expect(v0.angleToSigned(v1), equals(math.PI / 2.0));
277-
expect(v1.angleToSigned(v0), equals(-math.PI / 2.0));
278-
expect(v0.angleToSigned(v2), equals(math.PI));
276+
expect(v0.angleToSigned(v1), equals(math.pi / 2.0));
277+
expect(v1.angleToSigned(v0), equals(-math.pi / 2.0));
278+
expect(v0.angleToSigned(v2), equals(math.pi));
279279
}
280280

281281
void testVector2Clamp() {

0 commit comments

Comments
 (0)