
// Copyright 2019 Shlomi Steinberg
// 

#pragma once

#include "glm.hpp"

template <typename T>
constexpr auto sqr(T t) noexcept { return t*t; }

template <typename T>
constexpr auto vec_angle(T theta, T phi) noexcept {
	return glm::vec<3,T>{ glm::cos(theta)*glm::sin(phi), glm::sin(theta)*glm::sin(phi), glm::cos(phi) };
}

template <typename T>
constexpr auto luminance(const glm::vec<3,T> &v) noexcept {
	return glm::dot(v, glm::vec<3,T>{ T(.3), T(.59), T(.11) });
}
template <typename T>
constexpr auto luminance(const glm::vec<4,T> &v) noexcept {
	return luminance(glm::vec<3,T>{ v.x,v.y,v.z });
}
