/* * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * * Copyright 2011-2017 Danny Robson */ #ifndef CRUFT_UTIL_VECTOR_HPP #define CRUFT_UTIL_VECTOR_HPP #include "./coord/fwd.hpp" #include "./coord.hpp" #include "json/fwd.hpp" #include /////////////////////////////////////////////////////////////////////////////// namespace util { template struct vector : public coord::base> { using coord::base>::base; // representations template vector homog (void) const; // constants static constexpr vector ones (void); static constexpr vector zeros (void); void sanity (void) const; }; template constexpr vector<3,T> cross (vector<3,T>, vector<3,T>); template constexpr T cross (vector<2,T>, vector<2,T>); // polar/cartesian conversions; assumes (mag, angle) form. template vector<2,T> polar_to_cartesian (vector<2,T>); template vector<2,T> cartesian_to_polar (vector<2,T>); template vector<3,T> spherical_to_cartesian (vector<3,T>); template vector<3,T> cartesian_to_spherical (vector<3,T>); template vector<2,T> to_euler (vector<3,T>); template vector<3,T> from_euler (vector<2,T>); // output and serialisation operators template const json::tree::node& operator>> (const json::tree::node&, vector&); template using vector2 = vector<2,T>; template using vector3 = vector<3,T>; template using vector4 = vector<4,T>; template using vectoru = vector; template using vectori = vector; template using vectorf = vector; template using vectorb = vector; using vector2u = vector2; using vector3u = vector3; using vector4u = vector4; using vector2i = vector2; using vector3i = vector3; using vector4i = vector4; using vector2f = vector2; using vector3f = vector3; using vector4f = vector4; using vector2d = vector2; using vector3d = vector3; using vector4d = vector4; using vector2b = vector2; using vector3b = vector3; using vector4b = vector4; } #include "vector.ipp" #endif