实时碰撞检测书有以下等式。
// 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 作为浮点数。我该怎么办?我知道在 glm 或类似的东西中它只会使用运算符。
GLKVector3 的长度会给我我需要的吗?