summaryrefslogtreecommitdiff
path: root/common/vector.h
blob: 4a2d5de3e9298a59904f4d29358dac255c8d88b5 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
// Vector.h: interface for the Vector class.
//
//////////////////////////////////////////////////////////////////////

#ifndef _VECTOR_H_
#define _VECTOR_H_

class Vector  
{
 public:
  Vector ();
  Vector (float x, float y, float z);
  Vector (const float *point);
  Vector (const float *p1, const float *p2);
  virtual ~Vector ();

  float X ()
    { return m_fPoint[0]; }
  float Y ()
    { return m_fPoint[1]; }
  float Z ()
    { return m_fPoint[2]; }

  float Dot (Vector& vec);
  float Angle (Vector& vec);
  Vector& Cross (Vector& v1, Vector& v2);
  void Add (const float *point);
  void Add (float x, float y, float z);
  Vector& operator+=(Vector& add);
  Vector& operator-=(Vector& sub);
  Vector& operator*=(float scalar);
  Vector& operator=(Vector& source);
  Vector& operator=(const float *point);
  bool operator==(Vector& vec);

  void ToFloat (float *point);
  void FromFloat (const float *point);
  void FromFloat (float x, float y, float z);
  float Length ();
  void Normalize ();
  void Scale (float scale);

 protected:
  float m_fPoint[3];
};

#endif // _VECTOR_H_