fixed copying of library links in install target
[gph-math] / src / vector2.inl
1 /*
2 gph-math - math library for graphics programs
3 Copyright (C) 2016 John Tsiombikas <nuclear@member.fsf.org>
4
5 This program is free software. Feel free to use, modify, and/or redistribute
6 it under the terms of the MIT/X11 license. See LICENSE for details.
7 If you intend to redistribute parts of the code without the LICENSE file
8 replace this paragraph with the full contents of the LICENSE file.
9 */
10 inline void Vector2::normalize()
11 {
12         float len = (float)sqrt(x * x + y * y);
13         if(len != 0.0f) {
14                 x /= len;
15                 y /= len;
16         }
17 }
18
19 inline float &Vector2::operator[] (int idx)
20 {
21         return idx == 0 ? x : y;
22 }
23
24 inline const float &Vector2::operator[] (int idx) const
25 {
26         return idx == 0 ? x : y;
27 }