Browse Source

added forgotten overload vector sub and mult

develop
Robin Thoni 7 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
     VectorXD<X>& sub(const VectorXD<X>& other);
28
     VectorXD<X>& sub(const VectorXD<X>& other);
29
 
29
 
30
     VectorXD<X>& mult(double k);
30
     VectorXD<X>& mult(double k);
31
+    VectorXD<X>& mult(double scalars[X]);
31
     VectorXD<X>& mult(const VectorXD<X>& k);
32
     VectorXD<X>& mult(const VectorXD<X>& k);
32
 
33
 
33
     VectorXD<X>& div(double k);
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
     double dotProduct(const VectorXD<X>& other) const;
39
     double dotProduct(const VectorXD<X>& other) const;
36
 
40
 

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

101
     return *this;
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
 tmpl VectorXD<X> &VectorXD<X>::mult(const VectorXD<X> &other)
109
 tmpl VectorXD<X> &VectorXD<X>::mult(const VectorXD<X> &other)
105
 {
110
 {
106
     for (unsigned i = 0; i < X; ++i) {
111
     for (unsigned i = 0; i < X; ++i) {
110
 }
115
 }
111
 
116
 
112
 tmpl VectorXD<X> &VectorXD<X>::div(double k)
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
     for (unsigned i = 0; i < X; ++i) {
133
     for (unsigned i = 0; i < X; ++i) {
115
-        _scalars[i] /= k;
134
+        _scalars[i] /= other._scalars[i];
116
     }
135
     }
117
     return *this;
136
     return *this;
118
 }
137
 }

Loading…
Cancel
Save