0
实时碰撞检测手册具有以下等式。ObjectiveC中的计算交点
// Compute the t value for the directed line ab intersecting the plane
Vector ab = b - a;
t = (p.d - Dot(p.n, a))/Dot(p.n, ab);
所以我目前作为
GLKVector3 abD = GLKVector3Subtract(b, a);
GLKVector3 planeD = GLKVector3Make(1.0f, 0.0f, 1.0f);
GLKVector3 planeN = GLKVector3Make(0.0f, 1.0f, 0.0f);
//t = (p.d - Dot(p.n, a))/Dot(p.n, ab);
float dotPbA = GLKVector3DotProduct(planeN, a);
float dotPbAbD = GLKVector3DotProduct(planeN, abD);
GLKVector3 nominator = GLKVector3SubtractScalar(planeD, dotPbA);
GLKVector3 t = GLKVector3DivideScalar(nom, dotPbAbD);
// float t = nominator/dotPbA
我需要T作为一个float。我该怎么办?我知道在glm或类似的东西,它只会使用操作符。
将GLKVector3 t的长度给我我需要什么?
AH刨作为浮动。我有它,因为我认为飞机的方程。 – Andrew
该代码运行,但我没有得到T值在0和1之间,当它应该 – Andrew
@Andrew:你的输入数据是什么?该公式似乎是正确的。 –