Skip to content
Snippets Groups Projects
vector.hpp 1.74 KiB
/*
 * This file is part of FGGL.
 *
 * FGGL is free software: you can redistribute it and/or modify it under the terms of the GNU Lesser General Public
 * License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any
 * later version.
 *
 * FGGL is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty
 * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.
 *
 * You should have received a copy of the GNU Lesser General Public License along with FGGL.
 * If not, see <https://www.gnu.org/licenses/>.
 */

//
// Created by webpigeon on 20/08/22.
//

#ifndef FGGL_MATH_VECTOR_HPP
#define FGGL_MATH_VECTOR_HPP

#include <ostream>
#include <tuple>

#define GLM_ENABLE_EXPERIMENTAL
#include <glm/glm.hpp>

namespace glm {
	inline bool operator<(const vec2 &lhs, const vec2 &rhs) {
		return std::tie(lhs.x, lhs.y)
			< std::tie(rhs.x, rhs.y);
	}

	inline bool operator<(const vec3 &lhs, const vec3 &rhs) {
		return std::tie(lhs.x, lhs.y, lhs.z)
			< std::tie(rhs.x, rhs.y, rhs.z);
	}

	inline bool operator<(const vec4 &lhs, const vec4 &rhs) {
		return std::tie(lhs.x, lhs.y, lhs.z, lhs.w)
			< std::tie(rhs.x, rhs.y, rhs.z, rhs.w);
	}

	// output stream operators
	inline std::ostream &operator<<(std::ostream &os, const vec2 &v) {
		os << "(" << v.x << ", " << v.y << ")";
		return os;
	}

	inline std::ostream &operator<<(std::ostream &os, const vec3 &v) {
		os << "(" << v.x << ", " << v.y << "," << v.z << ")";
		return os;
	}

	inline std::ostream &operator<<(std::ostream &os, const vec4 &v) {
		os << "(" << v.x << ", " << v.y << "," << v.z << "," << v.w << ")";
		return os;
	}
}

#endif //FGGL_MATH_VECTOR_HPP