使用两个点计算模型中的压痕深度? [英] Calculate depth of indentation in model using two points?

查看:92
本文介绍了使用两个点计算模型中的压痕深度?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

通过光线投射可以选择GameObjects Collider上的一个点.在短视觉中,用小球体表示两个点,表示用户选择.期望计算模型压痕中任何斑点的深度.当前的想法是使用一种系统,在该系统中,用户选择压痕深度内的一个点,然后选择压痕深度之外的一个点,而不是使用矢量数学来计算深度.

截至目前,我们可获得的信息是空间中的两个点(向量)以及它们之间的距离.我们如何使用上述数据来计算与深度中的点垂直的点?认为如果该点比深度可计算,则为那两个点之间的距离.如何解决这个问题,这是否可行?

视觉:

解决方案

我认为2分是不够的.您可以看到整个场景,知道两个点所在的平面,因此可以看到最短距离(垂直)线段的方向.但是仅两点就有无限多的其他有效平面经过它们.您唯一可以说的是深度受这两点之间的距离的限制.

请考虑以下示例:一个点A(0,0,0)B(2,1,0).压痕有多深?答案是:您不知道.

首先假定平面为(平面a包含点A,平面b包含点B):

  • aX = 0,而bX = 2.那么压痕深度显然是2.
  • aY = 0,而bY = 1.那么压痕深度显然是1.
  • 最后,如果aZ = 0并且bZ = 0,则
  • .那么压痕深度显然为0.

实际上,改变平面方向可以得到0之间的任何深度以及AB之间的距离.

我看到的唯一解决方案是通过选择该平面上的 3 个点来固定两个平面中的至少一个.然后问题变得微不足道了.有3个点,您会发现

形式的平面方程

a*x + b*y + c*z + d = 0

则从点(x1,y1,z1)到该平面的距离为

dist = (a*x1 + b*y1 + c*z1 + d)/sqrt(a^2+b^2+c^2)

Via Raycasting one can select a point on an GameObjects Collider. In the short visual two points are represented with small spheres denoting user selection. The desire is to calculate the depth of any spot in an models indentation. Current thought is to use a system in which the user selects a point within the depth of the indentation and a point outside of it than calculating the depth using Vector math.

As of now, the information available to us is the two points (Vectors) in space and the distance between them. How do we use the aforementioned data to calculate a point perpendicular to the point in the depth? Thought being if this point is calculable than the depth would be the distance between those two points. How to go about this, and is it feasible?

Visual:

解决方案

I don't think that 2 points are enough. You, seeing the whole scene, know the planes where both points lie so you can see the direction of the shortest distance (perpendicular) segment. But just for two points there are infinitely many other valid planes going through them. The only thing you can say is that the depth is bound by the distance between those two points.

Consider following example: one point A is (0,0,0) and B is (2,1,0). How deep is the indentation? The answer is: you don't know.

Assume first that the planes are (the plane a contains the point A and the plane b contains the point B):

  • a is X = 0 while b is X = 2. Then the indentation depth is clearly 2.
  • a is Y = 0 while b is Y = 1. Then the indentation depth is clearly 1.
  • finally if a is Z = 0 and b is Z = 0. Then the indentation depth is clearly 0.

Actually change the planes direction you can get any depth between 0 and the distance between A and B.

The only solution I see is to fix at least one of the two planes by selecting 3 points on that plane. And then the problem becomes trivial. Having 3 points you find the plane equation in a form of

a*x + b*y + c*z + d = 0

Then the distance from a point (x1,y1,z1) to that plane is

dist = (a*x1 + b*y1 + c*z1 + d)/sqrt(a^2+b^2+c^2)

这篇关于使用两个点计算模型中的压痕深度?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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