source: trunk/packages/vizservers/nanovis/vrmath/include/vrmath/Vector4f.h @ 3470

Last change on this file since 3470 was 3470, checked in by ldelgass, 11 years ago

Cleanups for nanovis utility libs

  • Property svn:eol-style set to native
File size: 1.5 KB
Line 
1/* -*- mode: c++; c-basic-offset: 4; indent-tabs-mode: nil -*- */
2#ifndef VRVECTOR4F_H
3#define VRVECTOR4F_H
4
5#include <vrmath/Vector3f.h>
6#include <vrmath/Vector4f.h>
7
8class vrMatrix4x4f;
9
10class vrVector4f
11{
12public:
13    vrVector4f() :
14        x(0.0f), y(0.0f), z(0.0f), w(0.0f)
15    {}
16
17    vrVector4f(const vrVector4f& v4) :
18        x(v4.x), y(v4.y), z(v4.z), w(v4.w)
19    {}
20
21    vrVector4f(const vrVector3f& v3, float w1) :
22        x(v3.x), y(v3.y), z(v3.z), w(w1)
23    {}
24
25    vrVector4f(float x1, float y1, float z1, float w1) :
26        x(x1), y(y1), z(z1), w(w1)
27    {}
28
29    void set(float x1, float y1, float z1, float w1);
30 
31    void set(const vrVector3f& v, float w);
32
33    void set(const vrVector4f& v4);
34
35    void divideByW();
36
37    float dot(const vrVector4f& vec);
38
39    void mult(const vrMatrix4x4f& mat, const vrVector4f& vec);
40
41    void mult(const vrMatrix4x4f& mat);
42
43    void transform(const vrVector4f& v, const vrMatrix4x4f& m);
44
45    float x, y, z, w;
46};
47
48inline void vrVector4f::divideByW()
49{
50    if (w != 0) {
51        x /= w; y /= w; z /= w;
52        w = 1.0f;
53    }
54}
55
56inline void vrVector4f::set(float x1, float y1, float z1, float w1)
57{
58    x = x1;
59    y = y1;
60    z = z1;
61    w = w1;
62}
63
64inline void vrVector4f::set(const vrVector4f& v4)
65{
66    x = v4.x;
67    y = v4.y;
68    z = v4.z;
69    w = v4.w;
70}
71
72inline void vrVector4f::set(const vrVector3f& v, float w1)
73{
74    x = v.x;
75    y = v.y;
76    z = v.z;
77    w = w1;
78}
79
80inline float vrVector4f::dot(const vrVector4f& vec)
81{
82    return x * vec.x + y * vec.y + z * vec.z + w * vec.w;
83}
84
85#endif
Note: See TracBrowser for help on using the repository browser.