matrix_rotate_arbitrary_axis 1.1.0 copy "matrix_rotate_arbitrary_axis: ^1.1.0" to clipboard
matrix_rotate_arbitrary_axis: ^1.1.0 copied to clipboard

Simple library to generate rotation matrix around arbitrary axis

example/lib/main.dart

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

void main() {
  runApp(MyApp());
}

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

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

  final String title;

  @override
  _MyHomePageState createState() => _MyHomePageState();
}

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

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

  @override
  void dispose() {
    super.dispose();
    animationController.dispose();
  }

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(
        title: Text(widget.title),
      ),
      body: Center(
        child: Column(
          mainAxisAlignment: MainAxisAlignment.center,
          children: <Widget>[
            AnimatedBuilder(
              animation: animationController,
              builder: (context, child) {
                final angleTween = Tween<double>(begin: 0.0, end: 3.14)
                    .animate(animationController);
                return Transform(
                  transform:
                      RotationMatrix(0, 0, 0, 1, 1, 1, angleTween.value).matrix,
                  child: Container(
                    color: Colors.blue,
                    width: 300,
                    height: 300,
                  ),
                );
              },
            ),
          ],
        ),
      ),
    );
  }
}
2
likes
160
pub points
0%
popularity

Publisher

verified publisherroszkowski.dev

Simple library to generate rotation matrix around arbitrary axis

Repository (GitHub)
View/report issues

Documentation

API reference

License

Apache-2.0 (license)

Dependencies

vector_math

More

Packages that depend on matrix_rotate_arbitrary_axis