vector3d.h

来自「This is a simple code sample to interpol」· C头文件 代码 · 共 46 行

H
46
字号
#ifndef __VECTOR_H
#define __VECTOR_H

/* --------------------------------------------------------------------------
   3d-vector 
   for operations in 3d euclidean space 
   -------------------------------------------------------------------------- */
class vector3d
{
public:
  double x;
  double y; 
  double z;

public:
  // construct
  vector3d (void) { }
  vector3d (const class vector3d &v) { 
    x=v.x; y=v.y; z=v.z; }
  vector3d (double x0, double y0, double z0) { 
    x=x0; y=y0; z=z0; }

  // set
  virtual void set (const class vector3d &v) { 
    x=v.x; y=v.y; z=v.z; }
  virtual void set (double x0, double y0, double z0) { 
    x=x0; y=y0; z=z0; }

  // set
  class vector3d& operator = (const class vector3d &v) {
    set(v); 
    return(*this);
  }

  // dot operations
  class vector3d& operator += (const class vector3d &v) { 
    x += v.x; 
    y += v.y; 
    z += v.z; 
    return(*this); 
  }

  // ...
};

#endif

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?