/* * Copyright 2017 Google Inc. All rights reserved. * * 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. */ #ifndef MATHFU_HLSL_MAPPINGS_H_ #define MATHFU_HLSL_MAPPINGS_H_ #include "mathfu/matrix.h" #include "mathfu/quaternion.h" #include "mathfu/vector.h" /// @file mathfu/hlsl_mappings.h /// @brief HLSL compatible data types. /// @addtogroup mathfu_hlsl /// /// To simplify the use of MathFu template classes and make it possible to /// write code that looks similar to /// HLSL data types in C++, /// MathFu provides a set of data types that are similar in style to /// HLSL Vector and Matrix data types. /// @brief Namespace for MathFu library. namespace mathfu { /// @addtogroup mathfu_hlsl /// @{ /// Scalar unsigned integer typedef unsigned int uint; typedef unsigned int dword; typedef unsigned short half; /// 2-dimensional float Vector. typedef Vector float2; /// 3-dimensional float Vector. typedef Vector float3; /// 4-dimensional float Vector. typedef Vector float4; /// 2-dimensional int Vector. typedef Vector int2; /// 3-dimensional int Vector. typedef Vector int3; /// 4-dimensional int Vector. typedef Vector int4; /// 2-dimensional uint Vector. typedef Vector uint2; /// 3-dimensional uint Vector. typedef Vector uint3; /// 4-dimensional uint Vector. typedef Vector uint4; /// 1x1 float Matrix. typedef Matrix float1x1; /// 2x2 float Matrix. typedef Matrix float2x2; /// 3x3 float Matrix. typedef Matrix float3x3; /// 3x3 float Matrix. typedef Matrix float4x4; /// 1x1 double Matrix. typedef Matrix double1x1; /// 2x2 double Matrix. typedef Matrix double2x2; /// 3x3 double Matrix. typedef Matrix double3x3; /// 3x3 double Matrix. typedef Matrix double4x4; /// 1x1 int Matrix. typedef Matrix int1x1; /// 2x2 int Matrix. typedef Matrix int2x2; /// 3x3 int Matrix. typedef Matrix int3x3; /// 3x3 int Matrix. typedef Matrix int4x4; /// 1x1 int Matrix. typedef Matrix uint1x1; /// 2x2 int Matrix. typedef Matrix uint2x2; /// 3x3 int Matrix. typedef Matrix uint3x3; /// 3x3 int Matrix. typedef Matrix uint4x4; /// @brief Calculate the cross product of two 3-dimensional Vectors. /// /// @param v1 Vector to multiply /// @param v2 Vector to multiply /// @return 3-dimensional vector that contains the result. template inline Vector cross(const Vector& v1, const Vector& v2) { return Vector::CrossProduct(v1,v2); } /// @brief Calculate the dot product of two N-dimensional Vectors of any type. /// /// @param v1 Vector to multiply /// @param v2 Vector to multiply /// @return Scalar dot product result. template inline typename TV::Scalar dot(const TV& v1, const TV& v2) { return TV::DotProduct(v1,v2); } /// @brief Normalize an N-dimensional Vector of an arbitrary type. /// /// @param v1 Vector to normalize. /// @return Normalized vector. template inline TV normalize(const TV& v1) { return v1.Normalized(); } /// @} } // namespace mathfu #endif // MATHFU_HLSL_MAPPINGS_H_