V3FIT
Main Page
Related Pages
Modules
Modules List
Module Members
All
a
b
c
d
e
f
g
h
i
j
k
l
m
n
o
p
q
r
s
t
u
v
w
x
y
z
Functions/Subroutines
a
b
c
d
e
f
g
h
i
l
m
o
p
r
s
t
u
v
w
y
Variables
a
b
c
d
e
f
g
h
i
j
k
l
m
n
o
p
q
r
s
t
u
v
w
x
z
Data Types List
Data Types List
Data Types
Class Hierarchy
Data Fields
All
a
b
c
d
e
f
g
h
i
j
k
l
m
n
o
p
r
s
t
u
v
w
x
y
z
~
Functions/Subroutines
a
b
c
d
e
f
g
i
l
m
n
p
r
s
t
u
v
x
y
~
Variables
a
b
c
d
e
f
g
h
i
j
k
l
m
n
o
p
r
s
t
u
v
w
x
y
z
Files
File List
File Members
All
b
c
g
i
l
m
n
p
t
v
w
Functions/Subroutines
b
c
g
i
m
p
t
v
w
Variables
Enumerations
Macros
•
All
Classes
Namespaces
Files
Functions
Variables
Enumerations
Macros
Pages
LGRID
Sources
vector3d.cpp
1
//
2
// vector3d.cpp
3
// lgrid
4
//
5
// Created by Cianciosa, Mark R. on 2/7/16.
6
// Copyright © 2016 Cianciosa, Mark R. All rights reserved.
7
//
8
9
#include "vector3d.hpp"
10
#include <cmath>
11
12
//------------------------------------------------------------------------------
20
//------------------------------------------------------------------------------
21
vector3d::vector3d
(
const
double
x_,
const
double
y_,
const
double
z_) :
22
x(x_), y(y_), z(z_) {
23
}
24
25
//------------------------------------------------------------------------------
31
//------------------------------------------------------------------------------
32
const
double
vector3d::length
()
const
{
33
return
sqrt(
dot_product
(*
this
, *
this
));
34
}
35
36
//------------------------------------------------------------------------------
42
//------------------------------------------------------------------------------
43
const
vector3d
vector3d::normalize
()
const
{
44
return
*
this
/this->
length
();
45
}
46
47
//------------------------------------------------------------------------------
55
//------------------------------------------------------------------------------
56
const
vector3d
vector3d::cross_product
(
const
vector3d
&v1,
const
vector3d
&v2) {
57
return
vector3d
(v1.
y
*v2.
z
- v1.
z
*v2.
y
,
58
v1.
z
*v2.
x
- v1.
x
*v2.
z
,
59
v1.
x
*v2.
y
- v1.
y
*v2.
x
);
60
}
61
62
//------------------------------------------------------------------------------
70
//------------------------------------------------------------------------------
71
const
double
vector3d::dot_product
(
const
vector3d
&v1,
const
vector3d
&v2) {
72
return
v1.
x
*v2.
x
+ v1.
y
*v2.
y
+ v1.
z
*v2.
z
;
73
}
74
75
//------------------------------------------------------------------------------
83
//------------------------------------------------------------------------------
84
const
vector3d
operator+(
const
vector3d
&v1,
const
vector3d
&v2) {
85
return
vector3d
(v1.
x
+ v2.
x
, v1.
y
+ v2.
y
, v1.
z
+ v2.
z
);
86
}
87
88
//------------------------------------------------------------------------------
96
//------------------------------------------------------------------------------
97
const
vector3d
operator-(
const
vector3d
&v1,
const
vector3d
&v2) {
98
return
vector3d
(v1.
x
- v2.
x
, v1.
y
- v2.
y
, v1.
z
- v2.
z
);
99
}
100
101
//------------------------------------------------------------------------------
109
//------------------------------------------------------------------------------
110
const
vector3d
operator/(
const
vector3d
&v1,
const
double
d) {
111
return
vector3d
(v1.
x
/d, v1.
y
/d, v1.
z
/d);
112
}
vector3d::cross_product
static const vector3d cross_product(const vector3d &v1, const vector3d &v2)
Takes the cross product of two vectors.
Definition:
vector3d.cpp:56
vector3d::vector3d
vector3d(const double x_, const double y_, const double z_)
vector3d constructor.
Definition:
vector3d.cpp:21
vector3d
A vector.
Definition:
vector3d.hpp:19
vector3d::x
const double x
x component.
Definition:
vector3d.hpp:22
vector3d::dot_product
static const double dot_product(const vector3d &v1, const vector3d &v2)
Takes the doc product of two vectors.
Definition:
vector3d.cpp:71
vector3d::normalize
const vector3d normalize() const
Normalize vector3d instance.
Definition:
vector3d.cpp:43
vector3d::length
const double length() const
Length of a vector3d instance.
Definition:
vector3d.cpp:32
vector3d::y
const double y
y component.
Definition:
vector3d.hpp:24
vector3d::z
const double z
z component.
Definition:
vector3d.hpp:26
Generated on Thu Mar 5 2020 15:49:23 for V3FIT by
1.8.17