Very fast 3D distance check?

后端 未结 13 1901
南方客
南方客 2021-01-31 15:40

Is there a way to do a quick and dirty 3D distance check where the results are rough, but it is very very fast? I need to do depth sorting. I use STL sort like this

13条回答
  •  猫巷女王i
    2021-01-31 16:26

    If this is simply a value for sorting, then you can swap the sqrt() for a abs(). If you need to compare distances against set values, get the square of that value.

    E.g. instead of checking sqrt(...) against a, you can compare abs(...) against a*a.

提交回复
热议问题