如何网状成-1正常化为1,然后从归一目到原来还原? [英] How to normalize a mesh into -1 to 1, then revert from normalized mesh to original one?

查看:128
本文介绍了如何网状成-1正常化为1,然后从归一目到原来还原?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有在X,Y,Z格式的网格模型。让说。

I have a mesh model in X, Y, Z format. Lets say.

Points *P;

在第一步骤中,我想这个目成正常化(-1,-1,-1)(1,1,1)。
这里正常化的手段本网格放入一箱(-1,-1,-1)(1,1,1)。

In first step, I want to normalize this mesh into (-1, -1, -1) to (1, 1, 1). Here normalize means to fit this mesh into a box of (-1, -1, -1) to (1, 1, 1).

在那之后我做一些处理,以规范化的网格,最后我希望恢复尺寸类似的与原来的网格。

then after that I do some processing to normalized mesh, finally i want to revert the dimensions to similar with the original mesh.

STEP-1:
    P =原始网格尺寸;

step-1: P = Original Mesh dimensions;

步2:
    NP =正常化(P); //从(-1,-1,-1)(1,1,1)

step-2: nP = Normalize(P); // from (-1, -1, -1) to (1, 1, 1)

步3:
    CNP =做点什么(NP),顶点数量有所增加或减少。

step-3: cnP = do something with (nP), number of vertices has increased or decreased.

步4:
    原始网格尺寸=恢复(CNP); //尺寸应该是相同的与原网

step-4: Original Mesh dimensions = Revert(cnP); // dimension should be same with the original mesh

我该怎么办呢?

推荐答案

我知道它是多么容易迷失在编程和彻底无缘基础数学的简单性。但请相信我,这真的很简单。

I know how easy it can be to get lost in programming and completely miss the simplicity of the underlying math. But trust me, it really is simple.

最直观的方式去了解你的问题大概是这样的:

The most intuitive way to go about your problem is probably this:


  1. 确定所有三个坐标轴的最小值和最大值(即 X 以Z )。此信息由您的立方体的八个角的顶点遏制。在六个变量(例如, min_x max_x ,等等)。

  1. determine the minimum and maximum value for all three coordinate axes (i.e., x, y and z). This information is contained by the eight corner vertices of your cube. Save these six values in six variables (e.g., min_x, max_x, etc.).

有关网格中所有点 P =(X,Y,Z),计算

For all points p = (x,y,z) in the mesh, compute

q =  ( 2.0*(x-min_x)/(max_x-min_x) - 1.0
       2.0*(y-min_y)/(max_y-min_y) - 1.0
       2.0*(z-min_z)/(max_z-min_z) - 1.0 )

现在等于 P 转换为间隔( - 1,-1, -1) - (+ 1,+ 1,+ 1)的

now q equals p translated to the interval (-1,-1,-1) -- (+1,+1,+1).

做任何你需要在这个中间网格做。

Do whatever you need to do on this intermediate grid.

转换所有坐标 Q =(XX,YY,ZZ)通过执行逆运算回原来的网格:

Convert all coordinates q = (xx, yy, zz) back to the original grid by doing the inverse operation:

p =  ( (xx+1.0)*(max_x-min_x)/2.0 + min_x
       (yy+1.0)*(max_y-min_y)/2.0 + min_y
       (zz+1.0)*(max_z-min_z)/2.0 + min_z )


  • 清理你所做的任何混乱,并继续与你的程序的其余部分。

  • Clean up any mess you've made and continue with the rest of your program.

    这是那么容易,它可能要做更多的工作,以找出库中包含这些功能是不是比他们自己写的。

    This is so easy, it's probably a lot more work to find out which library contains these functions than it is to write them yourself.

    这篇关于如何网状成-1正常化为1,然后从归一目到原来还原?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

  • 查看全文
    登录 关闭
    扫码关注1秒登录
    发送“验证码”获取 | 15天全站免登陆