/* * Copyright 2014 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_CONSTANTS_H #define MATHFU_CONSTANTS_H #include "mathfu/matrix.h" #include "mathfu/quaternion.h" #include "mathfu/vector.h" namespace mathfu { /// @file mathfu/constants.h /// @brief Vector constants for specific dimensions. /// @addtogroup mathfu_constants /// /// It is preferable to use these constants rather than constructing them /// when they're required. Construction most-likely slower than loading them /// from memory. ///

/// For example, the following:
/// /// lookat = mat4::LookAt(target, position, mathfu::kAxisY3f); /// ///
is preferable to:
/// /// lookat = mat4::LookAt(target, position, /// mathfu::Vector(0.0f, 1.0f, 0.0f)); /// ///
in terms of efficiency and in addition to resulting in more concise /// code. ///

/// /// Depending on your linker's sophistication and settings, these constants may /// be duplicated in every compilation unit in which they're used. However, /// most linkers should be able to detect and eliminate this duplication. /// @addtogroup mathfu_constants /// @{ /// 2-dimensional float Vector of zeros. static const Vector kZeros2f(0.0f, 0.0f); /// 2-dimensional float Vector of ones. static const Vector kOnes2f(1.0f, 1.0f); /// 2-dimensional float unit Vector pointing along the X axis. static const Vector kAxisX2f(1.0f, 0.0f); /// 2-dimensional float unit Vector pointing along the Y axis. static const Vector kAxisY2f(0.0f, 1.0f); /// 3-dimensional float Vector of zeros. static const Vector kZeros3f(0.0f, 0.0f, 0.0f); /// 3-dimensional float Vector of ones. static const Vector kOnes3f(1.0f, 1.0f, 1.0f); /// 3-dimensional float unit Vector pointing along the X axis. static const Vector kAxisX3f(1.0f, 0.0f, 0.0f); /// 3-dimensional float unit Vector pointing along the Y axis. static const Vector kAxisY3f(0.0f, 1.0f, 0.0f); /// 3-dimensional float unit Vector pointing along the Z axis. static const Vector kAxisZ3f(0.0f, 0.0f, 1.0f); /// 4-dimensional float Vector of zeros. static const Vector kZeros4f(0.0f, 0.0f, 0.0f, 0.0f); /// 4-dimensional float Vector of ones. static const Vector kOnes4f(1.0f, 1.0f, 1.0f, 1.0f); /// 4-dimensional float unit Vector pointing along the X axis. static const Vector kAxisX4f(1.0f, 0.0f, 0.0f, 0.0f); /// 4-dimensional float unit Vector pointing along the Y axis. static const Vector kAxisY4f(0.0f, 1.0f, 0.0f, 0.0f); /// 4-dimensional float unit Vector pointing along the Z axis. static const Vector kAxisZ4f(0.0f, 0.0f, 1.0f, 0.0f); /// 4-dimensional float unit Vector pointing along the W axis. static const Vector kAxisW4f(0.0f, 0.0f, 0.0f, 1.0f); /// 2-dimensional double Vector of zeros. static const Vector kZeros2d(0.0, 0.0); /// 2-dimensional double Vector of ones. static const Vector kOnes2d(1.0, 1.0); /// 2-dimensional double unit Vector pointing along the X axis. static const Vector kAxisX2d(1.0, 0.0); /// 2-dimensional double unit Vector pointing along the Y axis. static const Vector kAxisY2d(0.0, 1.0); /// 3-dimensional double Vector of zeros. static const Vector kZeros3d(0.0, 0.0, 0.0); /// 3-dimensional double Vector of ones. static const Vector kOnes3d(1.0, 1.0, 1.0); /// 3-dimensional double unit Vector pointing along the X axis. static const Vector kAxisX3d(1.0, 0.0, 0.0); /// 3-dimensional double unit Vector pointing along the Y axis. static const Vector kAxisY3d(0.0, 1.0, 0.0); /// 3-dimensional double unit Vector pointing along the Z axis. static const Vector kAxisZ3d(0.0, 0.0, 1.0); /// 4-dimensional double Vector of zeros. static const Vector kZeros4d(0.0, 0.0, 0.0, 0.0); /// 4-dimensional double Vector of ones. static const Vector kOnes4d(1.0, 1.0, 1.0, 1.0); /// 4-dimensional double unit Vector pointing along the X axis. static const Vector kAxisX4d(1.0, 0.0, 0.0, 0.0); /// 4-dimensional double unit Vector pointing along the Y axis. static const Vector kAxisY4d(0.0, 1.0, 0.0, 0.0); /// 4-dimensional double unit Vector pointing along the Z axis. static const Vector kAxisZ4d(0.0, 0.0, 1.0, 0.0); /// 4-dimensional double unit Vector pointing along the W axis. static const Vector kAxisW4d(0.0, 0.0, 0.0, 1.0); /// 2-dimensional int Vector of zeros. static const Vector kOnes2i(1, 1); /// 2-dimensional int Vector of ones. static const Vector kZeros2i(0, 0); /// 2-dimensional int unit Vector pointing along the X axis. static const Vector kAxisX2i(1, 0); /// 2-dimensional int unit Vector pointing along the Y axis. static const Vector kAxisY2i(0, 1); /// 3-dimensional int Vector of zeros. static const Vector kZeros3i(0, 0, 0); /// 3-dimensional int Vector of ones. static const Vector kOnes3i(1, 1, 1); /// 3-dimensional int unit Vector pointing along the X axis. static const Vector kAxisX3i(1, 0, 0); /// 3-dimensional int unit Vector pointing along the Y axis. static const Vector kAxisY3i(0, 1, 0); /// 3-dimensional int unit Vector pointing along the Z axis. static const Vector kAxisZ3i(0, 0, 1); /// 4-dimensional int Vector of zeros. static const Vector kZeros4i(0, 0, 0, 0); /// 4-dimensional int Vector of ones. static const Vector kOnes4i(1, 1, 1 ,1); /// 4-dimensional int unit Vector pointing along the X axis. static const Vector kAxisX4i(1, 0, 0, 0); /// 4-dimensional int unit Vector pointing along the Z axis. static const Vector kAxisY4i(0, 1, 0, 0); /// 4-dimensional int unit Vector pointing along the Y axis. static const Vector kAxisZ4i(0, 0, 1, 0); /// 4-dimensional int unit Vector pointing along the W axis. static const Vector kAxisW4i(0, 0, 0, 1); /// Quaternion Identity static const Quaternion kQuatIdentityf(1.0f, 0.0f, 0.0f, 0.0f); /// Quaternion Identity static const Quaternion kQuatIdentityd(1.0, 0.0, 0.0, 0.0); // An AffineTransform versoin of the mat4 Identity matrix. static const AffineTransform kAffineIdentity(1.0f, 0.0f, 0.0f, 0.0f, 0.0f, 1.0f, 0.0f, 0.0f, 0.0f, 0.0f, 1.0f, 0.0f); /// @} } // namespace mathfu #endif // MATHFU_CONSTANTS_H