source: trunk/vizservers/nanovis/Vector3.h @ 827

Last change on this file since 827 was 819, checked in by vrinside, 16 years ago

Added several member functions

File size: 1.8 KB
Line 
1/*
2 * ----------------------------------------------------------------------
3 * Vector3.h : Vector class with 3 components
4 *
5 * ======================================================================
6 *  AUTHOR:  Wei Qiao <qiaow@purdue.edu>
7 *           Purdue Rendering and Perceptualization Lab (PURPL)
8 *
9 *  Copyright (c) 2004-2006  Purdue Research Foundation
10 *
11 *  See the file "license.terms" for information on usage and
12 *  redistribution of this file, and for a DISCLAIMER OF ALL WARRANTIES.
13 * ======================================================================
14 */
15#ifndef _VECTOR3_H_
16#define _VECTOR3_H_
17
18class Mat4x4;
19
20class Vector3{
21
22public:
23        float x, y, z;
24        Vector3(float _x, float _y, float _z);
25        Vector3();
26
27        Vector3 operator +(Vector3 &op2);       
28        Vector3 operator -(Vector3 &op2);
29        bool equal(Vector3 &op2);
30        //float operator *(Vector3 &op2);       //dot product
31        float operator *(Vector3 &op2);         //dot product
32        Vector3 operator *(float op2);    //mul per component
33        Vector3 operator /(float op2);    //mul per component
34        void operator <(Vector3 &op2);    //assign     
35        Vector3 operator ^(Vector3 &op2); //cross product
36        Vector3 normalize();
37        Vector3 rot_x(float degree);      //rotation about x
38        Vector3 rot_y(float degree);      //rotation about y
39        Vector3 rot_z(float degree);      //rotation about z
40        void set(float newx, float newy, float newz);
41        void print();
42        float distance(Vector3 &another) const; //compute distance
43        float distanceSquare(Vector3 &another) const;   //compute distance
44        float distanceSquare(float vx, float vy, float vz) const;       //compute distance
45
46        //fast version
47        Vector3 cross(Vector3 op2);
48
49    float dot(const Vector3& vec) const;
50
51    void transform(const Vector3& vec, const Mat4x4& mat);
52    float length() const;
53};
54
55#endif
Note: See TracBrowser for help on using the repository browser.