matrix_rotate_arbitrary_axis 1.0.0+1

  • Readme
  • Changelog
  • Example
  • Installing
  • new49

matrix_rotate_arbitrary_axis #

Library to generate rotation matrix around arbitrary axis.

Original implementation of RotationMatrix class (matrix_rotate_arbitrary_axis.dart) by Glenn Murray.

Usage #

If you want to apply rotation matrix to canvas in Flutter you can just call:

// Build a rotation matrix for rotations about the line through (a, b, c) 
// parallel to [uUn, vUn, wUn] by the angle theta. 
final rotationMatrix = RotationMatrix(a, b, c, uUn, vUn, wUn, angleInRadians);
final matrix = rotationMatrix.getMatrix();

The parameters are:

  • [a] x-coordinate of a point on the line of rotation.
  • [b] y-coordinate of a point on the line of rotation.
  • [c] z-coordinate of a point on the line of rotation.
  • [uUn] x-coordinate of the line's direction vector (unnormalized).
  • [vUn] y-coordinate of the line's direction vector (unnormalized).
  • [wUn] z-coordinate of the line's direction vector (unnormalized).
  • [theta] The angle of rotation, in radians.

Example #

See example in the example folder

example animation

[1.0.0+1] - Example added [May 2020] #

  • Added Flutter example app to show basic usage

[1.0.0] - Initial release [April 2020] #

  • Initial version ported from Java code


import 'package:flutter/material.dart';
import 'package:matrix_rotate_arbitrary_axis/matrix_rotate_arbitrary_axis.dart';

void main() {

class MyApp extends StatelessWidget {
  Widget build(BuildContext context) {
    return MaterialApp(
      title: 'Example App',
      theme: ThemeData(
        visualDensity: VisualDensity.adaptivePlatformDensity,
      debugShowCheckedModeBanner: false,
      home: MyHomePage(title: 'matrix_rotate_arbitrary_axis'),

class MyHomePage extends StatefulWidget {
  MyHomePage({Key key, this.title}) : super(key: key);

  final String title;

  _MyHomePageState createState() => _MyHomePageState();

class _MyHomePageState extends State<MyHomePage> with TickerProviderStateMixin {
  AnimationController animationController;

  void initState() {
    animationController =
        AnimationController(vsync: this, duration: Duration(seconds: 4));
    animationController.repeat(reverse: true);

  void dispose() {

  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(
        title: Text(widget.title),
      body: Center(
        child: Column(
          children: <Widget>[
              animation: animationController,
              builder: (context, child) {
                final angleTween = Tween<double>(begin: 0.0, end: 3.14)
                return Transform(
                  transform: RotationMatrix(0, 0, 0, 1, 1, 1, angleTween.value)
                  child: Container(
                    width: 300,
                    height: 300,

Use this package as a library

1. Depend on it

Add this to your package's pubspec.yaml file:

  matrix_rotate_arbitrary_axis: ^1.0.0+1

2. Install it

You can install packages from the command line:

with pub:

$ pub get

with Flutter:

$ flutter pub get

Alternatively, your editor might support pub get or flutter pub get. Check the docs for your editor to learn more.

3. Import it

Now in your Dart code, you can use:

import 'package:matrix_rotate_arbitrary_axis/matrix_rotate_arbitrary_axis.dart';
Describes how popular the package is relative to other packages. [more]
Code health derived from static analysis. [more]
Reflects how tidy and up-to-date the package is. [more]
Weighted score of the above. [more]
Learn more about scoring.

We analyzed this package on May 25, 2020, and provided a score, details, and suggestions below. Analysis was completed with status completed using:

  • Dart: 2.8.1
  • pana: 0.13.8-dev

Maintenance suggestions

The package description is too short. (-3 points)

Add more detail to the description field of pubspec.yaml. Use 60 to 180 characters to describe the package, what it does, and its target use case.


Package Constraint Resolved Available
Direct dependencies
Dart SDK >=2.7.0 <3.0.0
vector_math ^2.0.8 2.0.8
Dev dependencies