C&C++   发布时间:2022-04-03  发布网站:大佬教程  code.js-code.com
大佬教程收集整理的这篇文章主要介绍了c – 返回值1.#INF000大佬教程大佬觉得挺不错的,现在分享给大家,也给大家做个参考。
交集算法不起作用;其中一个值tmin,评估为1.#INF000 – 这意味着什么,为什么会发生? tmax似乎很好.

float Ray::Intersects(Bounding@L_696_1@ bounding@L_696_1@)
{
// direction is unit direction vector of the ray
D3DXVECTOR3 dirfrac(
    1.0f / direction.x,1.0f / direction.y,1.0f / direction.z);

D3DXVECTOR3 min = bounding@L_696_1@.Min();
D3DXVECTOR3 max = bounding@L_696_1@.Max();

//min and max are the negative and positive corners of the bounding @L_696_1@
float t1 = (min.x - origin.X) * dirfrac.x;
float t2 = (max.x - origin.X) * dirfrac.x;
float t3 = (min.y - origin.y) * dirfrac.y;
float t4 = (max.y - origin.y) * dirfrac.y;
float t5 = (min.z - origin.z) * dirfrac.z;
float t6 = (max.z - origin.z) * dirfrac.z;

float tmin = max(max(min(t1,t2),min(t3,t4)),min(t5,t6));
float tmax = min(min(max(t1,max(t3,max(t5,t6));

// if tmax < 0,ray (linE) is intersecTing AABB,but whole AABB is behind us
if (tmax < 0) { return -1; }

// if tmin > tmax,ray doesn't intersect AABB
if (tmin > tmaX) { return -1; } //HERE TMIN IS 1.#INFOOO

return tmin; //THIS IS NEVER REACHED
}

解决方法

1.#INF000很可能是正无穷大.如果你得到这个,那么就你的代码而言,这意味着下列之一:

> t1和t2都是无限的
> t3和t4都是无限的
> t5和t6都是无限的

我的猜测是你可能在某个地方除以零,最有可能的是你计算dirfrac的值.

大佬总结

以上是大佬教程为你收集整理的c – 返回值1.#INF000全部内容,希望文章能够帮你解决c – 返回值1.#INF000所遇到的程序开发问题。

如果觉得大佬教程网站内容还不错,欢迎将大佬教程推荐给程序员好友。

本图文内容来源于网友网络收集整理提供,作为学习参考使用,版权属于原作者。
如您有任何意见或建议可联系处理。小编QQ:384754419,请注明来意。