File: vector3d.hh

package info (click to toggle)
meshio 0.2.0-4
  • links: PTS
  • area: main
  • in suites: woody
  • size: 1,052 kB
  • ctags: 493
  • sloc: sh: 8,765; cpp: 1,438; ansic: 135; makefile: 57
file content (108 lines) | stat: -rwxr-xr-x 3,149 bytes parent folder | download | duplicates (3)
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
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
/* ======================================================================
 * vector3d.hh
 * 
 * This file is part of 3Dwm: The CUBE Window Manager.
 * Copyright (c) 1999, 2000 Niklas Elmqvist. All rights reserved.
 *
 * File created 1999-06-02 by Niklas Elmqvist <d97elm@dtek.chalmers.se>.
 * 
 * The 3Dwm Project
 *      <http://www.medialab.chalmers.se/projects/3dwm>
 * Chalmers Medialab
 *      <http://www.medialab.chalmers.se>
 *
 * This library is free software; you can redistribute it and/or
 * modify it under the terms of the GNU Library General Public
 * License as published by the Free Software Foundation; either
 * version 2 of the License, or (at your option) any later version.
 *
 * This library is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 * Library General Public License for more details.
 *
 * You should have received a copy of the GNU Library General Public
 * License along with this library; if not, write to the
 * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
 * Boston, MA  02111-1307, USA.
 *
 * ======================================================================
 */

#ifndef _VECTOR3D_HH_
#define _VECTOR3D_HH_

// Need to export functions on Win32
#if !defined(APIEXPORT)
#if !defined(WIN32)
#define APIEXPORT
#else
#define APIEXPORT __declspec(dllexport)
#endif 
#endif

// -- Namespace Definitions

namespace MeshIO {

    // -- Class Declarations
    
    // Vector3D class declaration
    class APIEXPORT Vector3D {
    public:
	
	union {
	    struct {
		float x, y, z, w;      // Vector component (named form)
	    } coord;
	    float fCoord[4];           // Vector components (array form)
	};
	
	// Constructors
	Vector3D(void);
	Vector3D(float x, float y, float z, float w = 1.0f);
	Vector3D(float _fCoord[3]);
	
	// Access operator (indexing)
	float &operator [] (int nIndex) { return fCoord[nIndex]; }
	
	// Arithmetric operators (vectorial)
	Vector3D &operator += (const Vector3D vVec);
	Vector3D &operator -= (const Vector3D vVec);
	
	Vector3D operator + (const Vector3D vVec) const;
	Vector3D operator - (const Vector3D vVec) const;
	Vector3D operator / (const Vector3D vVec) const;
	Vector3D operator * (const Vector3D vVec) const;
	
	// Arithmetric operators (scalar)
	Vector3D &operator += (const float fVal);
	Vector3D &operator -= (const float fVal);
	Vector3D &operator /= (const float fVal);
	Vector3D &operator *= (const float fVal);
	
	Vector3D operator + (const float fVal) const;
	Vector3D operator - (const float fVal) const;
	Vector3D operator / (const float fVal) const;
	Vector3D operator * (const float fVal) const;
	
	// Unary arithmetric operators
	Vector3D operator - (void) const;
	
	// Assignment
	Vector3D &operator = (const Vector3D vVec);
	
	// Mathematical operations
	float Magnitude(void);
	void Normalize(void);
	void Clear(void);
    };
    
    // --+ Auxiliary function prototypes
    float Dot(Vector3D vVec1, Vector3D vVec2);
    Vector3D operator * (float fVal, Vector3D vVec);

};

#endif /* vector3d.hh */