forked from thestk/stk
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Vector3D.h
68 lines (49 loc) · 1.37 KB
/
Vector3D.h
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
#ifndef STK_VECTOR3D_H
#define STK_VECTOR3D_H
#include "Stk.h"
#include <cmath>
namespace stk {
/***************************************************/
/*! \class Vector3D
\brief STK 3D vector class.
This class implements a three-dimensional vector.
by Perry R. Cook, 1995--2023.
*/
/***************************************************/
class Vector3D : public Stk
{
public:
//! Default constructor taking optional initial X, Y, and Z values.
Vector3D( StkFloat x = 0.0, StkFloat y = 0.0, StkFloat z = 0.0 ) { setXYZ( x, y, z ); };
//! Get the current X value.
StkFloat getX( void ) { return X_; };
//! Get the current Y value.
StkFloat getY( void ) { return Y_; };
//! Get the current Z value.
StkFloat getZ( void ) { return Z_; };
//! Calculate the vector length.
StkFloat getLength( void );
//! Set the X, Y, and Z values simultaniously.
void setXYZ( StkFloat x, StkFloat y, StkFloat z ) { X_ = x; Y_ = y; Z_ = z; };
//! Set the X value.
void setX( StkFloat x ) { X_ = x; };
//! Set the Y value.
void setY( StkFloat y ) { Y_ = y; };
//! Set the Z value.
void setZ( StkFloat z ) { Z_ = z; };
protected:
StkFloat X_;
StkFloat Y_;
StkFloat Z_;
};
inline StkFloat Vector3D :: getLength( void )
{
StkFloat temp;
temp = X_ * X_;
temp += Y_ * Y_;
temp += Z_ * Z_;
temp = sqrt( temp );
return temp;
}
} // stk namespace
#endif