Warning: file_get_contents(/data/phpspider/zhask/data//catemap/6/cplusplus/137.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C++ 如何检查分段平面是否为真实平面_C++_Math_Geometry - Fatal编程技术网

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

C++ 如何检查分段平面是否为真实平面,c++,math,geometry,C++,Math,Geometry,我得到了一个平面的三个参数,但我需要确保它们定义了一个平面。有没有一种数学方法可以从参数a、b、c和d检查该方程是否适合平面?一般平面由方程给出 ax + by + cz = d 一个有效平面是存在一个非空的、适当的子平面的任何平面ℝ3满足上述方程。也就是说,存在一组点(x,y,z)∈ ℝ3可以满足方程,还有其他点ℝ3这不能满足它 每当(a2+b2+c2)>0时,就会发生这种情况,而当a、b和c中至少有一个非零时,就会发生这种情况。所以,你所需要做的就是检查a、b和c中至少有一个是非零的。一个

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

一般平面由方程给出

ax + by + cz = d
一个有效平面是存在一个非空的、适当的子平面的任何平面ℝ3满足上述方程。也就是说,存在一组点(x,y,z)∈ ℝ3可以满足方程,还有其他点ℝ3这不能满足它


每当(a2+b2+c2)>0时,就会发生这种情况,而当a、b和c中至少有一个非零时,就会发生这种情况。所以,你所需要做的就是检查a、b和c中至少有一个是非零的。

一个总平面由方程给出

ax + by + cz = d
一个有效平面是存在一个非空的、适当的子平面的任何平面ℝ3满足上述方程。也就是说,存在一组点(x,y,z)∈ ℝ3可以满足方程,还有其他点ℝ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

希望这能给你一些启示。

这可能会帮助你解决一些问题。它可能不会直接回答您的问题,但可能会导致这样的答案。在我以前的一个数学库中,我确实有一个涉及三维空间中的平面的类。这个类确实使用了另一个我有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

希望这能给你一些启示。

“那个方程适合一个平面”-什么方程式适合一个平面?“那个方程式适合一个平面”-什么方程式适合一个平面?我有一些系数是负的,我应该把情况看作不是平面吗?@安德烈。至少有一个系数必须是非零的。没有其他限制,任何非零系数的符号不考虑任何有效性。只有当所有系数都为0时,问题才会出现。在这种情况下,如果d≠0或中的所有点ℝ^如果D=0,3将满足方程,这也不能定义一个平面。我有一些系数是负的,我应该把情况看作不是平面吗?@安德烈。至少有一个系数必须是非零。没有其他限制,任何非零系数的符号不考虑任何有效性。只有当所有系数都为0时,问题才会出现。在这种情况下,如果d≠0或中的所有点ℝ^如果d=0,则3将满足方程,这也无法定义平面。