vtkPlane和vtkPlaneSource

 

1、vtkPlane

vtkPlane provides methods for various plane computations. These include projecting points onto a plane, evaluating the plane equation, and returning plane normal. vtkPlane is a concrete implementation of the abstract class vtkImplicitFunction.

成员函数:void EvaluateFunction(double x[3])、void EvaluateFunction(double x,double y,double z)用于估算点x[3]是否位于平面上、平面前或平面后(法线方向为前),它是从抽象类vtkImplicitFunction继承而来,在基类中它是一个纯虚函数。
       void EvaluateGradient (double x[3], double g[3])用于估算点x[3]处函数倾斜度
              void vtkPlane::SetNormal(double x[3])、void vtkPlane::SetNormal(double x,double y,double z)  Set/get平面法向量.平面是由“点”和“法向量”定义的。 
              void Set/GetOrigin(double x[3])与SetNormal用法类似。
              void vtkPlane::Push(double distance)该函数可以将平面沿着法线方向移动distance距离
              在成员函数中还定义了点、矢量向某个平面投影的功能函数,如ProjectPoint、ProjectVector等。

隐函数的数学表达式为F(x,y,z)=w,平面的隐函数方程有点法式和一般式。在vtkPlane中采用的是点法式隐函数
点法式平面隐函数方程为:A(x-x0)+B(y-y0)+C(z-z0)=w, (A,B,C)为平面法向量,即vtkPlane中的Normal,(x0,y0,z0)为平面上一点,即vtkPlane中的Origin。
平面的一般式方程为:Ax+By+Cz=w

EvaluateFunction的源代码如下:  

double vtkPlane::EvaluateFunction(double x[3])
{
  return ( this->Normal[0]*(x[0]-this->Origin[0]) +
           this->Normal[1]*(x[1]-this->Origin[1]) +
           this->Normal[2]*(x[2]-this->Origin[2]) );
}

 

Examples:
vtkPlane (Examples)
Tests:
vtkPlane (Tests)

 

vtkPlane.h源代码:

#include "vtkCommonDataModelModule.h" // For export macro
#include "vtkImplicitFunction.h"

class VTKCOMMONDATAMODEL_EXPORT vtkPlane : public vtkImplicitFunction
{
public:
  // Description
  // Construct plane passing through origin and normal to z-axis.
  static vtkPlane *New();

  vtkTypeMacro(vtkPlane,vtkImplicitFunction);
  void PrintSelf(ostream& os, vtkIndent indent);

  // Description
  // Evaluate plane equation for point x[3].
  double EvaluateFunction(double x[3]);
  double EvaluateFunction(double x, double y, double z)
    {
     return this->vtkImplicitFunction::EvaluateFunction(x, y, z); } ;

  // Description
  // Evaluate function gradient at point x[3].
  void EvaluateGradient(double x[3], double g[3]);

  // Description:
  // Set/get plane normal. Plane is defined by point and normal.
  vtkSetVector3Macro(Normal,double);
  vtkGetVectorMacro(Normal,double,3);

  // Description:
  // Set/get point through which plane passes. Plane is defined by point
  // and normal.
  vtkSetVector3Macro(Origin,double);
  vtkGetVectorMacro(Origin,double,3);

  // Description:
  // Translate the plane in the direction of the normal by the
  // distance specified.  Negative values move the plane in the
  // opposite direction.
  void Push(double distance);

  // Description
  // Project a point x onto plane defined by origin and normal. The
  // projected point is returned in xproj. NOTE : normal assumed to
  // have magnitude 1.
  static void ProjectPoint(double x[3], double origin[3], double normal[3],
                           double xproj[3]);
  void ProjectPoint(double x[3], double xproj[3]);

  // Description
  // Project a vector v onto plane defined by origin and normal. The
  // projected vector is returned in vproj.
  static void ProjectVector(double v[3], double origin[3], double normal[3],
                           double vproj[3]);
  void ProjectVector(double v[3], double vproj[3]);

  // Description
  // Project a point x onto plane defined by origin and normal. The
  // projected point is returned in xproj. NOTE : normal does NOT have to
  // have magnitude 1.
  static void GeneralizedProjectPoint(double x[3], double origin[3],
                                      double normal[3], double xproj[3]);
  void GeneralizedProjectPoint(double x[3], double xproj[3]);


  // Description:
  // Quick evaluation of plane equation n(x-origin)=0.
  static double Evaluate(double normal[3], double origin[3], double x[3]);

  // Description:
  // Return the distance of a point x to a plane defined by n(x-p0) = 0. The
  // normal n[3] must be magnitude=1.
  static double DistanceToPlane(double x[3], double n[3], double p0[3]);
  double DistanceToPlane(double x[3]);

  // Description:
  // Given a line defined by the two points p1,p2; and a plane defined by the
  // normal n and point p0, compute an intersection. The parametric
  // coordinate along the line is returned in t, and the coordinates of
  // intersection are returned in x. A zero is returned if the plane and line
  // do not intersect between (0<=t<=1). If the plane and line are parallel,
  // zero is returned and t is set to VTK_LARGE_DOUBLE.
  static int IntersectWithLine(double p1[3], double p2[3], double n[3],
                               double p0[3], double& t, double x[3]);
  int IntersectWithLine(double p1[3], double p2[3], double& t, double x[3]);

protected:
 
  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值