EIC Software
Reference for
EIC
simulation and reconstruction software on GitHub
Home page
Related Pages
Modules
Namespaces
Classes
Files
External Links
File List
File Members
All
Classes
Namespaces
Files
Functions
Variables
Typedefs
Enumerations
Enumerator
Friends
Macros
Groups
Pages
vector3.h
Go to the documentation of this file.
Or view
the newest version in sPHENIX GitHub for file vector3.h
1
2
//
3
// Copyright 2010
4
//
5
// This file is part of starlight.
6
//
7
// starlight is free software: you can redistribute it and/or modify
8
// it under the terms of the GNU General Public License as published by
9
// the Free Software Foundation, either version 3 of the License, or
10
// (at your option) any later version.
11
//
12
// starlight is distributed in the hope that it will be useful,
13
// but WITHOUT ANY WARRANTY; without even the implied warranty of
14
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15
// GNU General Public License for more details.
16
//
17
// You should have received a copy of the GNU General Public License
18
// along with starlight. If not, see <http://www.gnu.org/licenses/>.
19
//
21
//
22
// File and Version Information:
23
// $Rev:: 28 $: revision of last commit
24
// $Author:: bgrube $: author of last commit
25
// $Date:: 2010-12-10 18:30:01 +0000 #$: date of last commit
26
//
27
// Description:
28
//
29
//
30
//
32
33
34
#ifndef VECTOR3_H
35
#define VECTOR3_H
36
37
38
#include <iostream>
39
#include <cmath>
40
41
42
class
vector3
43
{
44
public
:
45
vector3
();
46
vector3
(
const
vector3
&) =
default
;
47
vector3
(
double
*vec);
48
vector3
(
double
x
,
double
y
,
double
z
);
49
virtual
~vector3
();
50
51
const
double
*
GetVector
()
const
{
return
_vec
; }
52
53
void
SetVector
(
double
x,
double
y,
double
z);
54
void
SetVector
(
double
*vec);
55
56
vector3
&
operator =
(
const
vector3
& vec)
57
{
58
if
(
this
!= &vec)
59
for
(
unsigned
int
i = 0; i < 3; ++i)
60
_vec
[i] = vec.
_vec
[i];
61
return
*
this
;
62
}
63
64
vector3
&
operator +=
(
const
vector3
& vec)
65
{
66
for
(
unsigned
int
i = 0; i < 3; ++i)
67
_vec
[i] += vec.
_vec
[i];
68
return
*
this
;
69
}
70
vector3
&
operator -=
(
const
vector3
& vec)
71
{
72
for
(
unsigned
int
i = 0; i < 3; ++i)
73
_vec
[i] -= vec.
_vec
[i];
74
return
*
this
;
75
}
76
77
double
X
()
const
{
return
_vec
[0]; }
78
double
Y
()
const
{
return
_vec
[1]; }
79
double
Z
()
const
{
return
_vec
[2]; }
80
81
double
Mag2
()
const
{
return
_vec
[0] *
_vec
[0] +
_vec
[1] *
_vec
[1] +
_vec
[2] *
_vec
[2]; }
82
double
Mag
()
const
{
return
sqrt(
Mag2
()); }
83
84
friend
std::ostream&
operator <<
(std::ostream& out,
85
const
vector3
& vec)
86
{
87
out <<
"("
<< vec.
X
() <<
", "
<< vec.
Y
() <<
", "
<< vec.
Z
() <<
")"
;
88
return
out;
89
}
90
91
private
:
92
93
double
_vec
[3];
94
95
};
96
97
98
#endif // VECTOR3_H
estarlight
blob
master
include
vector3.h
Built by
Jin Huang
. updated:
Mon Jan 22 2024 12:43:38
using
1.8.2 with
EIC GitHub integration