~mir-team/mir/in-process-egl+input-conglomeration

« back to all changes in this revision

Viewing changes to 3rd_party/glm/glm/gtx/vector_angle.inl

Merged trunk and fixed issues

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
///////////////////////////////////////////////////////////////////////////////////////////////////
2
 
// OpenGL Mathematics Copyright (c) 2005 - 2012 G-Truc Creation (www.g-truc.net)
3
 
///////////////////////////////////////////////////////////////////////////////////////////////////
4
 
// Created : 2005-12-30
5
 
// Updated : 2008-09-29
6
 
// Licence : This source is under MIT License
7
 
// File    : glm/gtx/vector_angle.inl
8
 
///////////////////////////////////////////////////////////////////////////////////////////////////
9
 
 
10
 
namespace glm
11
 
{
12
 
        template <typename genType> 
13
 
        GLM_FUNC_QUALIFIER typename genType::value_type angle
14
 
        (
15
 
                genType const & x, 
16
 
                genType const & y
17
 
        )
18
 
        {
19
 
                return degrees(acos(dot(x, y)));
20
 
        }
21
 
 
22
 
        //! \todo epsilon is hard coded to 0.01
23
 
        template <typename valType> 
24
 
        GLM_FUNC_QUALIFIER valType orientedAngle
25
 
        (
26
 
                detail::tvec2<valType> const & x, 
27
 
                detail::tvec2<valType> const & y
28
 
        )
29
 
        {
30
 
                valType Angle = glm::degrees(acos(dot(x, y)));
31
 
                detail::tvec2<valType> TransformedVector = glm::rotate(x, Angle);
32
 
                if(all(equalEpsilon(y, TransformedVector, valType(0.01))))
33
 
                        return Angle;
34
 
                else
35
 
                        return -Angle;
36
 
        }
37
 
 
38
 
        template <typename valType>
39
 
        GLM_FUNC_QUALIFIER valType orientedAngle
40
 
        (
41
 
                detail::tvec3<valType> const & x,
42
 
                detail::tvec3<valType> const & y,
43
 
                detail::tvec3<valType> const & ref
44
 
        )
45
 
        {
46
 
                valType Angle = glm::degrees(glm::acos(glm::dot(x, y)));
47
 
 
48
 
                if(glm::dot(ref, glm::cross(x, y)) < valType(0))
49
 
                        return -Angle;
50
 
                else
51
 
                        return Angle;
52
 
        }
53
 
}//namespace glm