Browse Source

added forgotten overload vector sub and mult

develop
Robin Thoni 8 years ago
parent
commit
9dc5427aec
2 changed files with 24 additions and 1 deletions
  1. 4
    0
      UGameEngine/utils/vectorxd.h
  2. 20
    1
      UGameEngine/utils/vectorxd.hxx

+ 4
- 0
UGameEngine/utils/vectorxd.h View File

@@ -28,9 +28,13 @@ public:
28 28
     VectorXD<X>& sub(const VectorXD<X>& other);
29 29
 
30 30
     VectorXD<X>& mult(double k);
31
+    VectorXD<X>& mult(double scalars[X]);
31 32
     VectorXD<X>& mult(const VectorXD<X>& k);
32 33
 
33 34
     VectorXD<X>& div(double k);
35
+    VectorXD<X>& div(double scalars[X]);
36
+    VectorXD<X>& div(const VectorXD<X>& k);
37
+
34 38
 
35 39
     double dotProduct(const VectorXD<X>& other) const;
36 40
 

+ 20
- 1
UGameEngine/utils/vectorxd.hxx View File

@@ -101,6 +101,11 @@ tmpl VectorXD<X> &VectorXD<X>::mult(double k)
101 101
     return *this;
102 102
 }
103 103
 
104
+tmpl VectorXD<X> &VectorXD<X>::mult(double scalars[X])
105
+{
106
+    return mult(VectorXD<X>(scalars));
107
+}
108
+
104 109
 tmpl VectorXD<X> &VectorXD<X>::mult(const VectorXD<X> &other)
105 110
 {
106 111
     for (unsigned i = 0; i < X; ++i) {
@@ -110,9 +115,23 @@ tmpl VectorXD<X> &VectorXD<X>::mult(const VectorXD<X> &other)
110 115
 }
111 116
 
112 117
 tmpl VectorXD<X> &VectorXD<X>::div(double k)
118
+{
119
+    double scalars[X];
120
+    for (unsigned i = 0; i < X; ++i) {
121
+        scalars[i] = k;
122
+    }
123
+    return div(VectorXD<X>(scalars));
124
+}
125
+
126
+tmpl VectorXD<X> &VectorXD<X>::div(double scalars[X])
127
+{
128
+    return div(VectorXD<X>(scalars));
129
+}
130
+
131
+tmpl VectorXD<X> &VectorXD<X>::div(const VectorXD<X> &other)
113 132
 {
114 133
     for (unsigned i = 0; i < X; ++i) {
115
-        _scalars[i] /= k;
134
+        _scalars[i] /= other._scalars[i];
116 135
     }
117 136
     return *this;
118 137
 }

Loading…
Cancel
Save