| 44 default: |
44 default: |
| 45 throw std::runtime_error("Non-axis given to Vertex::operator[]"); |
45 throw std::runtime_error("Non-axis given to Vertex::operator[]"); |
| 46 } |
46 } |
| 47 } |
47 } |
| 48 |
48 |
| 49 double Vertex::operator[](Axis axis) const |
49 Vertex::ValueType Vertex::operator[](Axis axis) const |
| 50 { |
50 { |
| 51 switch (axis) |
51 switch (axis) |
| 52 { |
52 { |
| 53 case X: |
53 case X: |
| 54 return this->x; |
54 return this->x; |
| 55 case Y: |
55 case Y: |
| 56 return this->y; |
56 return this->y; |
| 57 case Z: |
57 case Z: |
| 58 return this->z; |
58 return this->z; |
| 59 default: |
59 default: |
| 60 return 0.0; |
60 return 0; |
| 61 } |
61 } |
| 62 } |
62 } |
| 63 |
63 |
| 64 void Vertex::setCoordinate(Axis axis, qreal value) |
64 void Vertex::setCoordinate(Axis axis, ValueType value) |
| 65 { |
65 { |
| 66 (*this)[axis] = value; |
66 (*this)[axis] = value; |
| 67 } |
67 } |
| 68 |
68 |
| 69 Vertex VertexFromVector(const QVector3D& vector) |
69 Vertex VertexFromVector(const QVector3D& vector) |
| 70 { |
70 { |
| 71 return {vector.x(), vector.y(), vector.z()}; |
71 return {vector.x(), vector.y(), vector.z()}; |
| 72 } |
72 } |
| 73 |
73 |
| 74 Vertex Vertex::operator*(qreal scalar) const |
74 Vertex Vertex::operator*(ValueType scalar) const |
| 75 { |
75 { |
| 76 return {this->x * scalar, this->y * scalar, this->z * scalar}; |
76 return {this->x * scalar, this->y * scalar, this->z * scalar}; |
| 77 } |
77 } |
| 78 |
78 |
| 79 Vertex& Vertex::operator+=(const QVector3D& other) |
79 Vertex& Vertex::operator+=(const QVector3D& other) |