| commit | 29000f7d97f02485d727e7f9ccd930298b4d366a | [log] [tgz] |
|---|---|---|
| author | dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> | Mon Dec 01 20:48:27 2025 |
| committer | GitHub <[email protected]> | Mon Dec 01 20:48:27 2025 |
| tree | 0ef4126eed98682d70d0324ba2436ddd69ec27c5 | |
| parent | 70a9a2cb610d040b247f3ca2cd70a94c1c6f6f23 [diff] |
Bump the github-actions group with 2 updates (#356) Bumps the github-actions group with 2 updates: [actions/checkout](https://github.com/actions/checkout) and [coverallsapp/github-action](https://github.com/coverallsapp/github-action). Updates `actions/checkout` from 5.0.0 to 6.0.0 - [Release notes](https://github.com/actions/checkout/releases) - [Changelog](https://github.com/actions/checkout/blob/main/CHANGELOG.md) - [Commits](https://github.com/actions/checkout/compare/08c6903cd8c0fde910a37f88322edcfb5dd907a8...1af3b93b6815bc44a9784bd300feb67ff0d1eeb3) Updates `coverallsapp/github-action` from 2.3.6 to 2.3.7 - [Release notes](https://github.com/coverallsapp/github-action/releases) - [Commits](https://github.com/coverallsapp/github-action/compare/648a8eb78e6d50909eff900e4ec85cab4524a45b...5cbfd81b66ca5d10c19b062c04de0199c215fb6e) --- updated-dependencies: - dependency-name: actions/checkout dependency-version: 6.0.0 dependency-type: direct:production update-type: version-update:semver-major dependency-group: github-actions - dependency-name: coverallsapp/github-action dependency-version: 2.3.7 dependency-type: direct:production update-type: version-update:semver-patch dependency-group: github-actions ... Signed-off-by: dependabot[bot] <[email protected]> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
A Vector math library for 2D and 3D applications.
position.xwz = color.grb;.1. Using the GLSL getter and setter syntax.
import 'package:vector_math/vector_math.dart'; void main() { Vector3 x = Vector3.zero(); // Zero vector Vector4 y = Vector4.all(4.0); // Vector with 4.0 in all lanes x.zyx = y.xzz; // Sets z,y,x the values in x,z,z }
2. Transforming a vector.
import 'dart:math'; import 'package:vector_math/vector_math.dart'; void main() { // Rotation of PI/2 degrees around the Y axis followed by a // translation of (5.0, 2.0, 3.0). Matrix4 T = Matrix4.rotationY(PI * 0.5)..translate(5.0, 2.0, 3.0); // A point. Vector3 position = Vector3(1.0, 1.0, 1.0); // Transform position by T. T.transform3(position); }
3. Invert a matrix
import 'dart:math'; import 'package:vector_math/vector_math.dart'; void main() { // Rotation of 90 degrees around the Y axis followed by a // translation of (5.0, 2.0, 3.0). Matrix4 T = Matrix4.rotationY(PI * 0.5)..translate(5.0, 2.0, 3.0); // Invert T. T.invert(); // Invert just the rotation in T. T.invertRotation(); }
4. Rotate a vector using a quaternion
import 'dart:math'; import 'package:vector_math/vector_math.dart'; void main() { // The X axis. Vector3 axis = Vector3(1.0, 0.0, 0.0); // 90 degrees. double angle = PI / 2.0; // Quaternion encoding a 90 degree rotation along the X axis. Quaternion q = Quaternion.axisAngle(axis, angle); // A point. Vector3 point = Vector3(1.0, 1.0, 1.0); // Rotate point by q. q.rotate(point); }
5. Check if two axis aligned bounding boxes intersect
import 'package:vector_math/vector_math.dart'; void main() { // Define the first box with a minimum and a maximum. Aabb2 aabbOne = Aabb2.minMax(Vector2.zero(), Vector2(4.0, 4.0)); // Define the second box Aabb2 aabbTwo = Aabb2.minMax(Vector2(5.0, 5.0), Vector2(6.0, 6.0)); // Extend the second box to contain a point aabbTwo.hullPoint(Vector2(3.0, 3.0)); // Check if the two boxes intersect, returns true in this case. bool intersect = aabbOne.intersectsWithAabb2(aabbTwo); }
6. Check where a ray and a sphere intersect
import 'package:vector_math/vector_math.dart'; void main() { // Define a ray starting at the origin and going into positive x-direction. Ray ray = Ray.originDirection(Vector3.zero(), Vector3(1.0, 0.0, 0.0)); // Defines a sphere with the center (5.0 0.0 0.0) and a radius of 2. Sphere sphere = Sphere.centerRadius(Vector3(5.0, 0.0, 0.0), 2.0); // Checks if the ray intersect with the sphere and returns the distance of the // intersection from the origin of the ray. Would return null if no intersection // is found. double distanceFromOrigin = ray.intersectsWithSphere(sphere); // Evaluate the position of the intersection, in this case (3.0 0.0 0.0). Vector3 position = ray.at(distanceFromOrigin); }
7. Work with colors
import 'package:vector_math/vector_math.dart'; void main() { // Access a build-in color, colors are stored in 4-dimensional vectors. Vector4 red = Colors.red; Vector4 gray = Vector4.zero(); // Convert the red color to a grayscaled color. Colors.toGrayscale(red, gray); // Parse a blue color from a hex string. Vector4 blue = Vector4.zero(); Colors.fromHexString('#0000FF', blue); // Convert the blue color from RGB to HSL. Colors.rgbToHsl(blue, blue); // Reduce the lightness of the color by 50%. blue.z *= 0.5; // Convert the HSL color back to RGB. Colors.hslToRgb(blue, blue); }
8. Use 64bit float precision (instead of 32bit)
// Use different import statement. // Which is a drop-in replacement for 'package:vector_math/vector_math.dart' import 'package:vector_math/vector_math_64.dart'; void main() { // Types work the same, but using 64 bit storage. Vector3 x = Vector3.zero(); Matrix4 m = Matrix4.identity(); }
To run the unit tests:
~/src/vector_math/> dart test
To automatically generate the latest version of vector_math_64:
~/src/vector_math/> dart tool/generate_vector_math_64.dart