Changeset 1712f542 for libcfa/src/vec/vec3.hfa
 Timestamp:
 Dec 23, 2019, 4:29:10 PM (2 years ago)
 Branches:
 armeh, jacob/cs343translation, master, newastuniqueexpr
 Children:
 596fc4ad
 Parents:
 b84ab40
 File:

 1 edited
Legend:
 Unmodified
 Added
 Removed

libcfa/src/vec/vec3.hfa
rb84ab40 r1712f542 42 42 // Primitive mathematical operations 43 43 44 // Subtraction 45 44 //  46 45 forall( subtract(T)) { 47 46 vec3(T) ??(vec3(T) u, vec3(T) v) { // TODO( can't make this const ref ) … … 60 59 } 61 60 62 // Addition 61 forall( { T ?(T&); }) { 62 vec3(T)& ?(vec3(T)& v) { 63 v.x; 64 v.y; 65 v.z; 66 return v; 67 } 68 vec3(T) ?(vec3(T)& v) { 69 vec3(T) copy = v; 70 v; 71 return copy; 72 } 73 } 74 75 // + 63 76 forall( add(T)) { 64 77 vec3(T) ?+?(vec3(T) u, vec3(T) v) { // TODO( can't make this const ref ) … … 71 84 } 72 85 73 // Multiplication 86 87 forall( { T ++?(T&); }) { 88 vec3(T)& ++?(vec3(T)& v) { 89 ++v.x; 90 ++v.y; 91 ++v.z; 92 return v; 93 } 94 vec3(T) ?++(vec3(T)& v) { 95 vec3(T) copy = v; 96 ++v; 97 return copy; 98 } 99 } 100 101 // * 74 102 forall( multiply(T)) { 75 103 vec3(T) ?*?(vec3(T) v, T scalar) with (v) { // TODO (can't make this const ref) … … 92 120 } 93 121 94 // Division122 // / 95 123 forall( divide(T)) { 96 124 vec3(T) ?/?(vec3(T) v, T scalar) with (v) { … … 110 138 } 111 139 112 // Relational Operators 140 // % 141 forall( { T ?%?(T,T); }) { 142 vec3(T) ?%?(vec3(T) v, T scalar) with (v) { 143 return [x % scalar, y % scalar, z % scalar]; 144 } 145 vec3(T)& ?%=?(vec3(T)& u, T scalar) { 146 u = u % scalar; 147 return u; 148 } 149 vec3(T) ?%?(vec3(T) u, vec3(T) v) { 150 return [u.x % v.x, u.y % v.y, u.z % v.z]; 151 } 152 vec3(T)& ?%=?(vec3(T)& u, vec3(T) v) { 153 u = u % v; 154 return u; 155 } 156 } 157 158 // & 159 forall( { T ?&?(T,T); }) { 160 vec3(T) ?&?(vec3(T) v, T scalar) with (v) { 161 return [x & scalar, y & scalar, z & scalar]; 162 } 163 vec3(T)& ?&=?(vec3(T)& u, T scalar) { 164 u = u & scalar; 165 return u; 166 } 167 vec3(T) ?&?(vec3(T) u, vec3(T) v) { 168 return [u.x & v.x, u.y & v.y, u.z & v.z]; 169 } 170 vec3(T)& ?&=?(vec3(T)& u, vec3(T) v) { 171 u = u & v; 172 return u; 173 } 174 } 175 176 //  177 forall( { T ??(T,T); }) { 178 vec3(T) ??(vec3(T) v, T scalar) with (v) { 179 return [x  scalar, y  scalar, z  scalar]; 180 } 181 vec3(T)& ?=?(vec3(T)& u, T scalar) { 182 u = u  scalar; 183 return u; 184 } 185 vec3(T) ??(vec3(T) u, vec3(T) v) { 186 return [u.x  v.x, u.y  v.y, u.z  v.z]; 187 } 188 vec3(T)& ?=?(vec3(T)& u, vec3(T) v) { 189 u = u  v; 190 return u; 191 } 192 } 193 194 // ^ 195 forall( { T ?^?(T,T); }) { 196 vec3(T) ?^?(vec3(T) v, T scalar) with (v) { 197 return [x ^ scalar, y ^ scalar, z ^ scalar]; 198 } 199 vec3(T)& ?^=?(vec3(T)& u, T scalar) { 200 u = u ^ scalar; 201 return u; 202 } 203 vec3(T) ?^?(vec3(T) u, vec3(T) v) { 204 return [u.x ^ v.x, u.y ^ v.y, u.z ^ v.z]; 205 } 206 vec3(T)& ?^=?(vec3(T)& u, vec3(T) v) { 207 u = u ^ v; 208 return u; 209 } 210 } 211 212 // << 213 forall( { T ?<<?(T,T); }) { 214 vec3(T) ?<<?(vec3(T) v, T scalar) with (v) { 215 return [x << scalar, y << scalar, z << scalar]; 216 } 217 vec3(T)& ?<<=?(vec3(T)& u, T scalar) { 218 u = u << scalar; 219 return u; 220 } 221 vec3(T) ?<<?(vec3(T) u, vec3(T) v) { 222 return [u.x << v.x, u.y << v.y, u.z << v.z]; 223 } 224 vec3(T)& ?<<=?(vec3(T)& u, vec3(T) v) { 225 u = u << v; 226 return u; 227 } 228 } 229 230 // >> 231 forall( { T ?>>?(T,T); }) { 232 vec3(T) ?>>?(vec3(T) v, T scalar) with (v) { 233 return [x >> scalar, y >> scalar, z >> scalar]; 234 } 235 vec3(T)& ?>>=?(vec3(T)& u, T scalar) { 236 u = u >> scalar; 237 return u; 238 } 239 vec3(T) ?>>?(vec3(T) u, vec3(T) v) { 240 return [u.x >> v.x, u.y >> v.y, u.z >> v.z]; 241 } 242 vec3(T)& ?>>=?(vec3(T)& u, vec3(T) v) { 243 u = u >> v; 244 return u; 245 } 246 } 247 248 // ~ 249 forall( { T ~?(T); }) 250 vec3(T) ~?(vec3(T) v) with (v) { 251 return [~v.x, ~v.y, ~v.z]; 252 } 253 254 // relational 113 255 forall( equality(T)) { 114 256 bool ?==?(vec3(T) u, vec3(T) v) with (u) { … … 144 286 } 145 287 } 146
Note: See TracChangeset
for help on using the changeset viewer.