如何检查分割平面是否为实平面
how to check if the segmented plane is a real plane
我得到了一个平面的三个参数,但我需要确保它们定义了一个平面。是否有一种数学方法可以从参数a
, b
, c
和d
来检验这个方程是否符合一个平面?
一般平面由式
给出ax + by + cz = d
一个有效平面是存在一个非空的,满足上述方程的,3的固有子集。即存在一组点(x, y, z)∈v 3满足方程,并且在v 3中存在其他点不能满足方程。
当(a2 + b2 + c2)> 0时发生,当a、b和c中至少有一个非零时发生。因此,您所需要做的就是检查a, b和c中至少有一个非零。 这可能会对您的问题有所帮助。它可能不会直接回答你的问题,但可能会导致这样一个答案。在我以前的一个数学图书馆里,我确实有一门课是关于三维空间中的平面的。这个类确实使用了另一个类Vector3,我不会在这里展示它,但它具有大多数常见的函数和操作,你可以在任何数学向量类中找到。
#ifndef PLANE_H
#define PLANE_H
#include "stdafx.h"
#include "Core.h"
// General Equation Of A Plane
//
// --- Ax + By + Cz + D = 0 ---
//
class Plane {
public:
bool _bOk;
private:
Vector3 _v3Point;
Vector3 _v3Normal;
public:
inline Plane();
inline Plane( Vector3 v3Point, Vector3 v3Normal );
inline Plane( Vector3 v3Point1, Vector3 v3Point2, Vector3 v3Point3 );
~Plane();
inline Vector3 GetNormal();
}; // Plane
// -----------------------------------------------------------------------
// Plane()
// Constructor - Set Plane To Be Horizontal At Origin With Normal In +Y
inline Plane::Plane() {
_v3Point = Vector3( 0.0f, 0.0f, 0.0f );
_v3Normal = Vector3( 0.0f, 1.0f, 0.0f );
_bOk = true;
} // Plane
// -----------------------------------------------------------------------
// Plane()
// Constructor - Set Plane To Given Point And Normal
inline Plane::Plane( Vector3 v3Point, Vector3 v3Normal ) {
_v3Point = v3Point;
_v3Normal = v3Normal;
if ( v3Normal.IsZero() ) {
_bOk = false;
return;
}
_bOk = true;
_v3Normal.Normalize();
} // Plane
// -----------------------------------------------------------------------
// Plane()
// Constructor - Define A Plane Given Three Points
inline Plane::Plane( Vector3 v3Point1, Vector3 v3Point2, Vector3 v3Point3) {
_v3Point = v3Point1;
// Get Two Vectors From The Given Points
Vector3 v3Vector1;
Vector3 v3Vector2;
v3Vector1 = v3Point3 - v3Point2;
v3Vector2 = v3Point1 - v3Point2;
// Get Normal By Crossing The Two Vectors
_v3Normal = v3Vector1.Cross( v3Vector2 );
if ( _v3Normal.IsZero() ) {
_bOk = false;
}
_bOk = true;
_v3Normal.Normalize();
} // Plane
// -----------------------------------------------------------------------
// GetNormal()
// Return The Normal To The Plane
inline Vector3 Plane::GetNormal() {
return _v3Normal;
} // Plane
#endif // PLANE_H
相关文章:
- 在提升multi_index容器中,是否定义了"default index"?
- 在C++STL中是否有Polyval(Matlab函数)等价物?
- 检查输入是否不是整数或数字
- 是否可以初始化不可复制类型的成员变量(或基类)
- 在C++中,是否可以基于给定的标识符创建基类的新实例,反之亦然
- 是否可以通过C++扩展强制多个python进程共享同一内存
- 此代码是否违反一个定义规则
- 是否需要删除包含对象的"pair"?
- 是否可以从int转换为enum类类型
- 无论条件是否为true,if总是在c++中执行
- 如何找到大小'x'数组是否完全填充,在C++?
- 检查值是否在集合p1和p2中,但不在p3中
- 是否可以在编译时初始化数组,以便在运行时不会花费时间?
- 检查 std::shared_ptr<> 的当前底层类型是否为 T
- 在c++中检查长方体是否尽可能快地重叠(无迭代)
- GL_SHADERSTORAGE_BUFFER位置是否与其他着色器位置冲突
- 检查由三个 3D 点组成的平面是否与立方体相交
- 从本机C++结构构建时,是否可以优化平面缓冲区序列化
- 是否有一个平面的未排序映射/集实现
- 如何检查分割平面是否为实平面