如何检查分段平面是否是真实平面

时间:2016-07-05 17:02:42

标签: c++ math geometry

我得到了一个平面的三个参数,但我需要确保它们定义一个平面。是否有一种数学方法可以从参数abcd检查该等式是否适合平面?

2 个答案:

答案 0 :(得分:2)

一般平面由等式

给出
ax + by + cz = d

有效平面是指存在满足上述等式的非空的适当子集ℝ 3 的平面。也就是说,存在一组能够满足的点( x y z )∈ℝ 3 方程式中,ℝ 3 中还有其他一点不能满足它。

只要( a 2 + b 2 + c < sup> 2 )&gt; 0,当 a b c 中的至少一个非零时,将发生这种情况。因此,您需要做的就是检查 a b c 中的至少一个是非零。

答案 1 :(得分:0)

这可能会帮助您解决问题。它可能不会直接回答您的问题,但可能会导致这样的答案。在我的一个较旧的数学库中,我确实有一个涉及3D空间中的平面的类。这个类确实使用了另一个我有Vector3的类,其中我不会在这里展示,但是你可以在任何Vector类中找到大多数用于数学的常用函数和操作。

平面类

#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

希望这可能会给你一些见解。

相关问题