# Changeset 250dbae

Ignore:
Timestamp:
Dec 31, 2019, 12:19:53 PM (3 years ago)
Branches:
arm-eh, enum, forall-pointer-decay, jacob/cs343-translation, master, new-ast-unique-expr, pthread-emulation, qualifiedEnum
Children:
f8a8fb1
Parents:
94df8de
git-author:
Dmitry Kobets <dkobets@…> (12/31/19 12:13:34)
git-committer:
Dmitry Kobets <dkobets@…> (12/31/19 12:19:53)
Message:

Refactor vector library classes

Location:
libcfa/src/vec
Files:
4 edited

Unmodified
Removed
• ## libcfa/src/vec/vec.hfa

 r94df8de } forall(otype T, otype V | { T length(V); V ?/?(V, T); }) V normalize(V v) { // i is the incident vector // ng is the geometric normal of the surface /* forall(| add(T) | multiply(T) | lessthan(T) | fromint(T) | subtract(T)) */ forall(otype T | lessthan(T) | zeroinit(T), otype V | dottable(V, T) | negate(V)) V faceforward(V n, V i, V ng) {
• ## libcfa/src/vec/vec2.hfa

 r94df8de } forall (otype T) { static inline { } // Assignment void ?=?(vec2(T)& vec, vec2(T) other) with (vec) { [x,y] = other.[x,y]; // Primitive mathematical operations // - forall(| subtract(T)) { vec2(T) ?-?(vec2(T) u, vec2(T) v) { // TODO( can't make this const ref ) vec2(T) ?-?(vec2(T) u, vec2(T) v) { return [u.x - v.x, u.y - v.y]; } } // + forall(| add(T)) { vec2(T) ?+?(vec2(T) u, vec2(T) v) { // TODO( can't make this const ref ) vec2(T) ?+?(vec2(T) u, vec2(T) v) { return [u.x + v.x, u.y + v.y]; } } // * forall(| multiply(T)) { vec2(T) ?*?(vec2(T) v, T scalar) with (v) { // TODO (can't make this const ref) vec2(T) ?*?(vec2(T) v, T scalar) with (v) { return [x * scalar, y * scalar]; } vec2(T) ?*?(T scalar, vec2(T) v) { // TODO (can't make this const ref) vec2(T) ?*?(T scalar, vec2(T) v) { return v * scalar; } } // / forall(| divide(T)) { vec2(T) ?/?(vec2(T) v, T scalar) with (v) { return [u.x / v.x, u.y / v.y]; } vec2(T)& ?/=?(vec2(T)& v, T scalar) with (v) { vec2(T)& ?/=?(vec2(T)& v, T scalar) { v = v / scalar; return v; } // % forall(| { T ?%?(T,T); }) { vec2(T) ?%?(vec2(T) v, T scalar) with (v) { } // & forall(| { T ?&?(T,T); }) { vec2(T) ?&?(vec2(T) v, T scalar) with (v) { } // | forall(| { T ?|?(T,T); }) { vec2(T) ?|?(vec2(T) v, T scalar) with (v) { } // ^ forall(| { T ?^?(T,T); }) { vec2(T) ?^?(vec2(T) v, T scalar) with (v) { } // << forall(| { T ?<> forall(| { T ?>>?(T,T); }) { vec2(T) ?>>?(vec2(T) v, T scalar) with (v) { } // ~ forall(| { T ~?(T); }) vec2(T) ~?(vec2(T) v) with (v) { } // Relational Operators // relational forall(| equality(T)) { bool ?==?(vec2(T) u, vec2(T) v) with (u) {
• ## libcfa/src/vec/vec3.hfa

 r94df8de } forall (otype T) { static inline { } // Assignment void ?=?(vec3(T)& vec, vec3(T) other) with (vec) { [x,y,z] = other.[x,y,z]; // - forall(| subtract(T)) { vec3(T) ?-?(vec3(T) u, vec3(T) v) { // TODO( can't make this const ref ) vec3(T) ?-?(vec3(T) u, vec3(T) v) { return [u.x - v.x, u.y - v.y, u.z - v.z]; } } } forall(| negate(T)) { vec3(T) -?(vec3(T) v) with (v) { } } forall(| { T --?(T&); }) { vec3(T)& --?(vec3(T)& v) { // + forall(| add(T)) { vec3(T) ?+?(vec3(T) u, vec3(T) v) { // TODO( can't make this const ref ) vec3(T) ?+?(vec3(T) u, vec3(T) v) { return [u.x + v.x, u.y + v.y, u.z + v.z]; } } } forall(| { T ++?(T&); }) { // * forall(| multiply(T)) { vec3(T) ?*?(vec3(T) v, T scalar) with (v) { // TODO (can't make this const ref) vec3(T) ?*?(vec3(T) v, T scalar) with (v) { return [x * scalar, y * scalar, z * scalar]; } vec3(T) ?*?(T scalar, vec3(T) v) { // TODO (can't make this const ref) vec3(T) ?*?(T scalar, vec3(T) v) { return v * scalar; } return [u.x / v.x, u.y / v.y, u.z / v.z]; } vec3(T)& ?/=?(vec3(T)& v, T scalar) with (v) { vec3(T)& ?/=?(vec3(T)& v, T scalar) { v = v / scalar; return v;
• ## libcfa/src/vec/vec4.hfa

 r94df8de } forall (otype T) { static inline { } // Assignment void ?=?(vec4(T)& vec, vec4(T) other) with (vec) { [x,y,z,w] = other.[x,y,z,w]; // - forall(| subtract(T)) { vec4(T) ?-?(vec4(T) u, vec4(T) v) { // TODO( can't make this const ref ) vec4(T) ?-?(vec4(T) u, vec4(T) v) { return [u.x - v.x, u.y - v.y, u.z - v.z, u.w - v.w]; } } } forall(| negate(T)) { vec4(T) -?(vec4(T) v) with (v) { } } forall(| { T --?(T&); }) { vec4(T)& --?(vec4(T)& v) { // * forall(| multiply(T)) { vec4(T) ?*?(vec4(T) v, T scalar) with (v) { // TODO (can't make this const ref) vec4(T) ?*?(vec4(T) v, T scalar) with (v) { return [x * scalar, y * scalar, z * scalar, w * scalar]; } vec4(T) ?*?(T scalar, vec4(T) v) { // TODO (can't make this const ref) vec4(T) ?*?(T scalar, vec4(T) v) { return v * scalar; } } // Scalar Division // / forall(| divide(T)) { vec4(T) ?/?(vec4(T) v, T scalar) with (v) { return [u.x / v.x, u.y / v.y, u.z / v.z, u.w / v.w]; } vec4(T)& ?/=?(vec4(T)& v, T scalar) with (v) { vec4(T)& ?/=?(vec4(T)& v, T scalar) { v = v / scalar; return v; } // Relational Operators // relational forall(| equality(T)) { bool ?==?(vec4(T) u, vec4(T) v) with (u) {
Note: See TracChangeset for help on using the changeset viewer.