Changeset ae09808 for libcfa


Ignore:
Timestamp:
Dec 13, 2019, 7:54:05 PM (4 years ago)
Author:
Dmitry Kobets <dkobets@…>
Branches:
ADT, arm-eh, ast-experimental, enum, forall-pointer-decay, jacob/cs343-translation, master, new-ast-unique-expr, pthread-emulation, qualifiedEnum
Children:
0f4527d
Parents:
7799f79
Message:

Add vector division and multiplication to vec3 + tests

File:
1 edited

Legend:

Unmodified
Added
Removed
  • libcfa/src/vec/vec3.hfa

    r7799f79 rae09808  
    7171    }
    7272
    73     // Scalar Multiplication
     73    // Multiplication
    7474    forall(| multiply(T)) {
    7575    vec3(T) ?*?(vec3(T) v, T scalar) with (v) { // TODO (can't make this const ref)
     
    7979        return v * scalar;
    8080    }
     81    vec3(T) ?*?(vec3(T) u, vec3(T) v) {
     82        return [u.x * v.x, u.y * v.y, u.z * v.z];
     83    }
    8184    vec3(T)& ?*=?(vec3(T)& v, T scalar) {
    8285        v = v * scalar;
    8386        return v;
    8487    }
     88    vec3(T)& ?*=?(vec3(T)& u, vec3(T) v) {
     89        u = u * v;
     90        return u;
     91    }
    8592    }
    8693
    87     // Scalar Division
     94    // Division
    8895    forall(| divide(T)) {
    8996    vec3(T) ?/?(vec3(T) v, T scalar) with (v) {
    9097        return [x / scalar, y / scalar, z / scalar];
    9198    }
     99    vec3(T) ?/?(vec3(T) u, vec3(T) v) {
     100        return [u.x / v.x, u.y / v.y, u.z / v.z];
     101    }
    92102    vec3(T)& ?/=?(vec3(T)& v, T scalar) with (v) {
    93103        v = v / scalar;
    94104        return v;
     105    }
     106    vec3(T)& ?/=?(vec3(T)& u, vec3(T) v) {
     107        u = u / v;
     108        return u;
    95109    }
    96110    }
Note: See TracChangeset for help on using the changeset viewer.