本文介绍了缩放3D模型,找到原点的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

为了更好地了解矩阵转换的工作原理,我很难了解实际发生的事情,因此我决定编写一些脚本来采用3D模型,然后执行一些平移,旋转和缩放操作,因为查看当我使用不同的值时实际发生的情况可能会有所帮助.

To get a better idea of how matrix transformations work cause I'm having a fairly hard time seeing what actually happens, I decided to write some scripts that will take a 3D model and then do some translations, rotations, and scaling, since looking at what actually happens when I play around with different values may be helpful.

我已经编写了用于解析3D模型的脚本,所以现在我只需要编写转换函数即可.

I've already written the scripts to parse a 3D model, so now I just need to write the transformation functions.

我正在使用Euclid模块,这是处理矩阵的一些建议之一(尽管这个问题并不是真正针对python的,所以我省略了该标签)

I am using the Euclid module, which was amongst several suggestions for working with matrices (though this question is not really python-specific so I left out that tag)

到目前为止,我已经能够根据我提供的x,y,z值成功转换模型.

So far I've been able to successfully translate a model based on the x,y,z values that I provide.

现在,我正在研究缩放功能,并且还设法通过任何因素对模型进行缩放,但是由于模型并未集中在缩放范围"上,因此我很难将其即时"缩放来源.

Now I'm working on the scaling function, and have also managed to scale the model by whatever factor, but I'm having a hard time getting it to scale "on the spot" since the model isn't centered at the origin.

我如何构建一个考虑任意模型中心的变换矩阵?

How can I build a transform matrix that will take into account the center of some arbitrary model?

推荐答案

您可以通过以下转换在"P"点附近缩放":

You may scale "around" a point P by the following transformation:

translate(scale(translate(model, -P)), P)

即对于顶点X,您拥有

X' = P + s * (X-P) = s*X + (P-s*P)

这篇关于缩放3D模型,找到原点的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

09-01 23:06