【发布时间】:2014-07-18 15:27:01
【问题描述】:
我有以下 3D 数据:
- 射线原点(x、y、z)
- 射线方向(x、y、z)
- 四个矩形角 (x,y,z)
现在我正在寻找一个简单的 c++ 函数来计算矩形是否与光线相交。我不需要交叉点坐标,只需要一个“是/否”布尔值。 我用谷歌搜索了很多,但不幸的是我找不到任何适合我要求的简单功能。我希望我可以避免编写自己的函数,因为向量计算很久以前就开始了:-(!如果有人有想法,我很感激任何帮助。
谢谢……
编辑:
感谢您的帮助。这正是我正在寻找的,但我的 vxl 库有问题。首先,我已经下载并编译了源代码。然后,在测试库时,当我尝试创建具有三个 3D 点的平面时出现以下错误。
“未定义对 `vgl_plane_3d::vgl_plane_3d(vgl_point_3d const&, vgl_point_3d const&, vgl_point_3d const&)'的引用|”
我的代码:
// -----------------------------------------------
#include <vgl/vgl_point_3d.h>
#include <vgl/vgl_plane_3d.h>
#include <vgl/vgl_intersection.h>
void createTestPlane(void);
using namespace std;
int main()
{
createTestPlane();
return 0;
}
void createTestPlane()
{
vgl_point_3d<double> PlaneP0(1.0,0.0,0.0);
vgl_point_3d<double> PlaneP1(1.0,0.0,1.0);
vgl_point_3d<double> PlaneP2(1.0,1.0,0.0);
vgl_plane_3d<double> testConstruction();
vgl_plane_3d<double> Plane(PlaneP0,PlaneP1,PlaneP2);
}
// -----------------------------------------------
我不知道问题出在哪里,因为具有三个 3D 点的构造函数在“”标题中可用。默认构造函数似乎工作正常。
部分头文件:
// -----------------------------------------------
// Default constructor: horizontal XY-plane (equation 1.z = 0)
inline vgl_plane_3d () : a_(0), b_(0), c_(1), d_(0) {}
//: Construct from three non-collinear points
// The plane will contain all three points \a p1, \a p2 and \a p3.
vgl_plane_3d (vgl_point_3d<T> const& p1,
vgl_point_3d<T> const& p2,
vgl_point_3d<T> const& p3);
// -----------------------------------------------
有人知道我做错了什么吗?
【问题讨论】:
标签: c++ 3d intersection rectangles raytracing