I've been working with Flutter rotation,
new Matrix4.identity()
..rotateX(degrees * 3.1415927 / 180),
but, the problem, I want it to be similar to the diagram below. can I achieve a 3D-like rotation on the x-axis with Flutter?
even if there is a mapping from 3D to 2D or there are alternatives that would get the same result. thanks in advance.
Example image in OpenCV: How to calculate perspective transform for OpenCV from rotation angles?
Rotate Widget with RotatedBox():Pass -1 for 90o or -2 for 180o or -3 for 270o.
thanks to this discussion, and this repo, and after more than a day seeking the answer,
static Matrix4 _pmat(num pv) {
return new Matrix4(
1.0, 0.0, 0.0, 0.0, //
0.0, 1.0, 0.0, 0.0, //
0.0, 0.0, 1.0, pv * 0.001, //
0.0, 0.0, 0.0, 1.0,
);
}
Matrix4 perspective = _pmat(1.0);
// then use it
new Center(
child: new Transform(
child: new FittedBox(
fit: BoxFit.fill,
child: LogoWidget(),
),
alignment: FractionalOffset.center,
transform: perspective.scaled(1.0, 1.0, 1.0)
..rotateX(math.pi - degrees * math.pi / 180)
..rotateY(0.0)
..rotateZ(0.0)
),
);
here is the result image
please read a little theory about this subject.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With