本文整理汇总了C++中Plane::DistanceToPoint方法的典型用法代码示例。如果您正苦于以下问题:C++ Plane::DistanceToPoint方法的具体用法?C++ Plane::DistanceToPoint怎么用?C++ Plane::DistanceToPoint使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Plane
的用法示例。
在下文中一共展示了Plane::DistanceToPoint方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: if
//! Clip poly by plane
void Polygon3::ClipByPlane(const Plane & plane)
{
// TODO: test / check performance / optimize / эта пиздец! count чему в начале равен?
Vector<Vector3> resultVector;
int32 i2;
int32 count = 0;
for(int32 i = 0; i < pointCount; ++i)
{
i2 = i + 1;
if (i2 >= pointCount) i2 = 0;
float32 d1 = plane.DistanceToPoint(points[i]);
float32 d2 = plane.DistanceToPoint(points[i2]);
if ((d1 >= POLYGON_EPSILON) && (d2 >= POLYGON_EPSILON))
{
resultVector.push_back(points[i]);
resultVector.push_back(points[i2]);
count += 2;
} else if ((d1 >= POLYGON_EPSILON) && (d2 <= -POLYGON_EPSILON))
{
Vector3 res;
res.Lerp(points[i], points[i2], d1 / (d1 - d2));
resultVector.push_back(points[i]);
resultVector.push_back(res);
count += 2;
} else if ((d1 <= -POLYGON_EPSILON) && (d2 >= POLYGON_EPSILON))
{
Vector3 res;
res.Lerp(points[i], points[i2], -d1 / (-d1 + d2));
resultVector.push_back(res);
//resultVector.push_back(points[i]);
count += 1;
}
}
points.clear();
for (int32 i = 0; i < count; ++i)
points.push_back(resultVector[i]);
}
示例2: castTo
bool Ray::castTo(Plane target_, Vec3 &output_) {
//Ray is parrallel to plane
if (Vec3::dot(target_.normal, dir) == 0) {
return false;
}
if (target_.DistanceToPoint(point) < 0) {
if (Vec3::dot(target_.normal, dir) > 0) {
output_ = point + dir * (-(Vec3::dot(point, target_.normal) + target_.D) / Vec3::dot(target_.normal, dir));
return true;
} else {
return false;
}
} else {
if (Vec3::dot(target_.normal, dir) < 0) {
output_ = point + dir * (-(Vec3::dot(point, target_.normal) + target_.D) / Vec3::dot(target_.normal, dir));
return true;
} else {
return false;
}
}
}