gpt4 book ai didi

rotation - 在 Flutter 中的 X 上旋转 3D

转载 作者:IT老高 更新时间:2023-10-28 12:37:12 31 4
gpt4 key购买 nike

我一直在使用 Flutter 旋转,

new Matrix4.identity()
..rotateX(度 * 3.1415927/180),

但是,问题是,我希望它类似于下图。我可以使用 Flutter 在 x 轴上实现类似 3D 的旋转吗?

即使存在从 3D 到 2D 的映射或有替代方案那会得到相同的结果。提前致谢。

rotate3d diagram

OpenCV 中的示例图像:How to calculate perspective transform for OpenCV from rotation angles?

最佳答案

感谢 this discussion , 和 this repo ,经过一天多的寻找答案,

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)
),
);

这是结果图片

mobile flutter rotation 3d perspective

请阅读 little theory关于这个话题。

关于rotation - 在 Flutter 中的 X 上旋转 3D,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/50457809/

31 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com