Changeset ae09808
- Timestamp:
- Dec 13, 2019, 7:54:05 PM (5 years ago)
- 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
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
libcfa/src/vec/vec3.hfa
r7799f79 rae09808 71 71 } 72 72 73 // ScalarMultiplication73 // Multiplication 74 74 forall(| multiply(T)) { 75 75 vec3(T) ?*?(vec3(T) v, T scalar) with (v) { // TODO (can't make this const ref) … … 79 79 return v * scalar; 80 80 } 81 vec3(T) ?*?(vec3(T) u, vec3(T) v) { 82 return [u.x * v.x, u.y * v.y, u.z * v.z]; 83 } 81 84 vec3(T)& ?*=?(vec3(T)& v, T scalar) { 82 85 v = v * scalar; 83 86 return v; 84 87 } 88 vec3(T)& ?*=?(vec3(T)& u, vec3(T) v) { 89 u = u * v; 90 return u; 91 } 85 92 } 86 93 87 // ScalarDivision94 // Division 88 95 forall(| divide(T)) { 89 96 vec3(T) ?/?(vec3(T) v, T scalar) with (v) { 90 97 return [x / scalar, y / scalar, z / scalar]; 91 98 } 99 vec3(T) ?/?(vec3(T) u, vec3(T) v) { 100 return [u.x / v.x, u.y / v.y, u.z / v.z]; 101 } 92 102 vec3(T)& ?/=?(vec3(T)& v, T scalar) with (v) { 93 103 v = v / scalar; 94 104 return v; 105 } 106 vec3(T)& ?/=?(vec3(T)& u, vec3(T) v) { 107 u = u / v; 108 return u; 95 109 } 96 110 } -
tests/vector/.expect/vec3_float.txt
r7799f79 rae09808 14 14 s*v:<4.5,8.25,300.9> 15 15 ?*=?:<4.5,8.25,300.9> 16 ?*?(vec):<2.,6.,13.5> 17 ?*=?(vec):<2.,6.,13.5> 16 18 ?/?:<0.666667,-0.0333333,15.> 17 19 ?/=?:<0.666667,-0.0333333,15.> 20 ?/?(vec):<1.,-0.0333333,0.666667> 21 ?/=?(vec):<1.,-0.0333333,0.666667> 18 22 dot_1:0. 19 23 dot_2:37.8 -
tests/vector/vec3_float.cfa
r7799f79 rae09808 47 47 sout | "?*=?:" | v1; 48 48 49 { 50 vec3(float) u = {1, 2, 3}; 51 vec3(float) v = {2, 3, 4.5f}; 52 sout | "?*?(vec):" | (u * v); 53 sout | "?*=?(vec):" | (u *= v); 54 } 55 49 56 v1 = (vec3(float)){2, -0.1f, 45}; 50 57 sout | "?/?:" | (v1 / 3.f); … … 52 59 v1 /= 3.f; 53 60 sout | "?/=?:" | v1; 61 62 { 63 vec3(float) u = {2, -0.1f, 3}; 64 vec3(float) v = {2, 3, 4.5f}; 65 sout | "?/?(vec):" | (u / v); 66 sout | "?/=?(vec):" | (u /= v); 67 } 54 68 55 69 v1 = (vec3(float)){4,2,3};
Note: See TracChangeset
for help on using the changeset viewer.