⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 vector3d.h

📁 Ion Team Lord Of The Rings Demo 模拟指环王的3D游戏 VS.NET编译 里面提供高级渲染算法
💻 H
字号:

class Vector3d
  {
  public:
    Vector3d()
    {}
    ;
    Vector3d(float X, float Y, float Z)
    {
      Coords[0] = X;
      Coords[1] = Y;
      Coords[2] = Z;
    }
    Vector3d(Vector3d const &other)
    {
      *this = other;
    }
    ~Vector3d()
    {}
    ;
    float Coords[3];

    Vector3d const &operator=(Vector3d const &other);
    Vector3d const &operator+=(Vector3d const &other);
    Vector3d const &operator-=(Vector3d const &other);

    bool const operator==(Vector3d const &other);
    bool const operator!=(Vector3d const &other);

    int iTag; // for whatever :D


  }
;

Vector3d const &Vector3d::operator=(Vector3d const &other)
{
  Coords[0] = other.Coords[0];
  Coords[1] = other.Coords[1];
  Coords[2] = other.Coords[2];
  return *this;
}

Vector3d const &Vector3d::operator+=(Vector3d const &other)
{
  Coords[0] = Coords[0] + other.Coords[0];
  Coords[1] = Coords[1] + other.Coords[1];
  Coords[2] = Coords[2] + other.Coords[2];
  return *this;
}

Vector3d const &Vector3d::operator-=(Vector3d const &other)
{
  Coords[0] = Coords[0] - other.Coords[0];
  Coords[1] = Coords[1] - other.Coords[1];
  Coords[2] = Coords[2] - other.Coords[2];
  return *this;
}

bool const Vector3d::operator==(Vector3d const &other)
{
  if (Coords[0] == other.Coords[0] && Coords[1] == other.Coords[1] && Coords[2] == other.Coords[2])
    return true;
  return false;
}
bool const Vector3d::operator!=(Vector3d const &other)
{
  if (Coords[0] != other.Coords[0] || Coords[1] != other.Coords[1] || Coords[2] != other.Coords[2])
    return true;
  return false;
}

Vector3d operator+ (Vector3d const &v, Vector3d const &other)
{
  return Vector3d (v.Coords[0] + other.Coords[0],
                   v.Coords[1] + other.Coords[1],
                   v.Coords[2] + other.Coords[2]);
}

inline Vector3d operator- (Vector3d const &v, Vector3d const &other)
{
  return Vector3d (v.Coords[0] - other.Coords[0],
                   v.Coords[1] - other.Coords[1],
                   v.Coords[2] - other.Coords[2]);
}

inline Vector3d operator- (Vector3d const &v)
{
  return Vector3d (-v.Coords[0],
                   -v.Coords[1],
                   -v.Coords[2]);
}

inline Vector3d operator* (Vector3d const &v, Vector3d const &other)
{
  return Vector3d (v.Coords[1] * other.Coords[2] - v.Coords[2] * other.Coords[1],
                   v.Coords[2] * other.Coords[0] - v.Coords[0] * other.Coords[2],
                   v.Coords[0] * other.Coords[1] - v.Coords[1] * other.Coords[0]);
}


inline Vector3d operator* (Vector3d const &v, float const &Value)
{
  return Vector3d (v.Coords[0] * (float)Value,
                   v.Coords[1] * (float)Value,
                   v.Coords[2] * (float)Value);
}

inline Vector3d operator/ (Vector3d const &v, float const &Value)
{
  return Vector3d (v.Coords[0] / Value,
                   v.Coords[1] / Value,
                   v.Coords[2] / Value);
}


Vector3d v3dZero( 0.0, 0.0, 0.0 );

⌨️ 快捷键说明

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