From d167fbecb5bb3ad19e50c18b5fd09aadfbbceb87 Mon Sep 17 00:00:00 2001 From: Keuin Date: Tue, 12 Apr 2022 11:13:12 +0800 Subject: Inline util methods. --- vec.h | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) (limited to 'vec.h') diff --git a/vec.h b/vec.h index 0e0b62d..017b0a9 100644 --- a/vec.h +++ b/vec.h @@ -78,37 +78,37 @@ struct vec3 { // print to ostream template -std::ostream &operator<<(std::ostream &out, const vec3 &vec) { +inline std::ostream &operator<<(std::ostream &out, const vec3 &vec) { return out << "vec3[x=" << vec.x << ", y=" << vec.y << ", z=" << vec.z << ']'; } // product vec3 by a scalar template -vec3 operator*(const vec3 &vec, const S &b) { +inline vec3 operator*(const vec3 &vec, const S &b) { return vec3{.x=(T) (vec.x * b), .y=(T) (vec.y * b), .z=(T) (vec.z * b)}; } // product vec3 by a scalar template -vec3 operator*(const S &b, const vec3 &vec) { +inline vec3 operator*(const S &b, const vec3 &vec) { return vec3{.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 -vec3 operator/(const vec3 &vec, const S &b) { +inline vec3 operator/(const vec3 &vec, const S &b) { return vec3{.x=(T) (vec.x / b), .y=(T) (vec.y / b), .z=(T) (vec.z / b)}; } // scalar product (inner product) template -T dot(const vec3 &a, const vec3 &b) { +inline T dot(const vec3 &a, const vec3 &b) { return a.dot(b); } // vector product (outer product) template -vec3 cross(const vec3 &a, const vec3 &b) { +inline vec3 cross(const vec3 &a, const vec3 &b) { return a.cross(b); } -- cgit v1.2.3