diff options
author | Keuin <[email protected]> | 2022-04-12 11:13:12 +0800 |
---|---|---|
committer | Keuin <[email protected]> | 2022-04-12 11:13:12 +0800 |
commit | d167fbecb5bb3ad19e50c18b5fd09aadfbbceb87 (patch) | |
tree | 24b9438b7fc843edd63a14893832f5d6b776798b /vec.h | |
parent | 8b88692ea17885b9f191c08fbcb5dc1093269878 (diff) |
Inline util methods.
Diffstat (limited to 'vec.h')
-rw-r--r-- | vec.h | 12 |
1 files changed, 6 insertions, 6 deletions
@@ -78,37 +78,37 @@ struct vec3 { // print to ostream template<typename T> -std::ostream &operator<<(std::ostream &out, const vec3<T> &vec) { +inline std::ostream &operator<<(std::ostream &out, const vec3<T> &vec) { return out << "vec3[x=" << vec.x << ", y=" << vec.y << ", z=" << vec.z << ']'; } // product vec3 by a scalar template<typename T, typename S> -vec3<T> operator*(const vec3<T> &vec, const S &b) { +inline vec3<T> operator*(const vec3<T> &vec, const S &b) { return vec3<T>{.x=(T) (vec.x * b), .y=(T) (vec.y * b), .z=(T) (vec.z * b)}; } // product vec3 by a scalar template<typename T, typename S> -vec3<T> operator*(const S &b, const vec3<T> &vec) { +inline vec3<T> operator*(const S &b, const vec3<T> &vec) { return vec3<T>{.x=(T) (vec.x * b), .y=(T) (vec.y * b), .z=(T) (vec.z * b)}; } // product vec3 by the inversion of a scalar (div by a scalar) template<typename T, typename S> -vec3<T> operator/(const vec3<T> &vec, const S &b) { +inline vec3<T> operator/(const vec3<T> &vec, const S &b) { return vec3<T>{.x=(T) (vec.x / b), .y=(T) (vec.y / b), .z=(T) (vec.z / b)}; } // scalar product (inner product) template<typename T> -T dot(const vec3<T> &a, const vec3<T> &b) { +inline T dot(const vec3<T> &a, const vec3<T> &b) { return a.dot(b); } // vector product (outer product) template<typename T> -vec3<T> cross(const vec3<T> &a, const vec3<T> &b) { +inline vec3<T> cross(const vec3<T> &a, const vec3<T> &b) { return a.cross(b); } |