source:
src/base/vector.cpp@
b51c3b
| Last change on this file since b51c3b was 716da7, checked in by , 14 years ago | |
|---|---|
|
|
| File size: 931 bytes | |
| Rev | Line | |
|---|---|---|
| [48b662] | 1 | /** |
| 2 | * @file vector.cpp | |
| 3 | * @author Julian Iseringhausen <isering@ins.uni-bonn.de> | |
| 4 | * @date Mon Apr 18 12:25:24 2011 | |
| 5 | * | |
| 6 | * @brief VMG::Vector | |
| 7 | * | |
| 8 | */ | |
| 9 | ||
| 10 | ||
| 11 | #ifdef HAVE_CONFIG_H | |
| 12 | #include <config.h> | |
| 13 | #endif | |
| 14 | ||
| 15 | #include "base/index.hpp" | |
| 16 | #include "base/vector.hpp" | |
| 17 | ||
| 18 | using namespace VMG; | |
| 19 | ||
| 20 | Vector::Vector(const Index& index) | |
| 21 | { | |
| 22 | i[0] = static_cast<vmg_float>(index.X()); | |
| 23 | i[1] = static_cast<vmg_float>(index.Y()); | |
| 24 | i[2] = static_cast<vmg_float>(index.Z()); | |
| 25 | } | |
| 26 | ||
| [dfed1c] | 27 | Vector::Vector(const vmg_float& x, const vmg_float& y, const vmg_float& z) |
| [48b662] | 28 | { |
| 29 | i[0]=x; | |
| 30 | i[1]=y; | |
| 31 | i[2]=z; | |
| 32 | } | |
| 33 | ||
| [dfed1c] | 34 | Vector::Vector(const vmg_float& val) |
| [48b662] | 35 | { |
| [716da7] | 36 | std::fill(i, i+3, val); |
| [48b662] | 37 | } |
| [dfed1c] | 38 | |
| 39 | Vector::Vector(const vmg_float* arr) | |
| 40 | { | |
| [716da7] | 41 | std::memcpy(i, arr, 3*sizeof(vmg_float)); |
| [dfed1c] | 42 | } |
| 43 | ||
| [48b662] | 44 | Vector::Vector() |
| 45 | { | |
| [716da7] | 46 | std::fill(i, i+3, 0.0); |
| [48b662] | 47 | } |
| 48 | ||
| [dfed1c] | 49 | std::ostream& VMG::operator<<(std::ostream& out, const Vector& vector) |
| [48b662] | 50 | { |
| [dfed1c] | 51 | out << "{" << vector.X() << " " << vector.Y() << " " << vector.Z() << "}"; |
| 52 | ||
| 53 | return out; | |
| [48b662] | 54 | } |
Note:
See TracBrowser
for help on using the repository browser.
