MathUtils.h revision e4aa95e3627226bcb0d8cc3e42dca6e4df8f421c
1/*
2 * Copyright (C) 2014 The Android Open Source Project
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 *      http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16#ifndef MATHUTILS_H
17#define MATHUTILS_H
18
19namespace android {
20namespace uirenderer {
21
22class MathUtils {
23private:
24    static const float gNonZeroEpsilon = 0.001f;
25public:
26    /**
27     * Check for floats that are close enough to zero.
28     */
29    inline static bool isZero(float value) {
30        return (value >= -gNonZeroEpsilon) && (value <= gNonZeroEpsilon);
31    }
32
33    inline static bool isPositive(float value) {
34        return value >= gNonZeroEpsilon;
35    }
36}; // class MathUtils
37
38} /* namespace uirenderer */
39} /* namespace android */
40
41#endif /* MATHUTILS_H */
42