zenilib  0.5.3.0
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
Vector2f.h
Go to the documentation of this file.
1 /* This file is part of the Zenipex Library (zenilib).
2  * Copyright (C) 2011 Mitchell Keith Bloch (bazald).
3  *
4  * zenilib is free software: you can redistribute it and/or modify
5  * it under the terms of the GNU Lesser General Public License as published by
6  * the Free Software Foundation, either version 3 of the License, or
7  * (at your option) any later version.
8  *
9  * zenilib is distributed in the hope that it will be useful,
10  * but WITHOUT ANY WARRANTY; without even the implied warranty of
11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12  * GNU Lesser General Public License for more details.
13  *
14  * You should have received a copy of the GNU Lesser General Public License
15  * along with zenilib. If not, see <http://www.gnu.org/licenses/>.
16  */
17 
30 #ifndef ZENI_VECTOR2F_H
31 #define ZENI_VECTOR2F_H
32 
33 #include <Zeni/Serialization.h>
34 
35 namespace Zeni {
36 
37  struct Point2f;
38  struct Vector2f;
39  struct Vector3f;
40 
41  struct ZENI_DLL Vector2f {
43  inline explicit Vector2f(const bool &degenerate_ = false);
44  inline Vector2f(const float &i_, const float &j_, const bool &degenerate_ = false);
45  inline Vector2f(const Vector2f &rhs, const bool &degenerate_ = false);
46  inline Vector2f(const Point2f &rhs);
47  inline explicit Vector2f(const Vector3f &rhs);
48 
49  // Vector addition/subtraction
50  inline Vector2f operator+(const Vector2f &rhs) const;
51  inline Vector2f operator-(const Vector2f &rhs) const;
52  inline Vector2f & operator+=(const Vector2f &rhs);
53  inline Vector2f & operator-=(const Vector2f &rhs);
54 
55  // Vector Dot-Product and Cross-Product
56  inline float operator*(const Vector2f &rhs) const;
57 
58  // Vector Scalar Multiplication I of II
59  inline Vector2f operator*(const float &rhs) const;
60  inline Vector2f operator/(const float &rhs) const;
61  inline Vector2f & operator*=(const float &rhs);
62  inline Vector2f & operator/=(const float &rhs);
63  inline Vector2f operator-() const;
64 
65  // Other Standard Functions
66  Vector2f & normalize();
67  Vector2f normalized() const;
68  inline float magnitude2() const;
69  inline float magnitude() const;
70 
71  // Other helpful functions
72  inline Vector2f get_i() const;
73  inline Vector2f get_j() const;
74  inline Vector2f multiply_by(const Vector2f &rhs) const;
75  inline Vector2f divide_by(const Vector2f &rhs) const;
76  inline float angle_between(const Vector2f &rhs) const;
77 
78  // Indexing
79  inline const float & operator[](const int &index) const;
80  inline float & operator[](const int &index);
81 
82  // Spherical Accessors and Modifiers
83  float theta() const;
84  void set_spherical(const float &theta, const float &magnitude = 1);
85 
86  union {
87  float i;
88  float x;
89  };
90  union {
91  float j;
92  float y;
93  };
94 
95  bool degenerate;
96  };
97 
98  // Vector Scalar Multiplication Part II of II
99  inline Vector2f operator*(const float &lhs, const Vector2f &rhs);
100 
101  ZENI_DLL std::ostream & serialize(std::ostream &os, const Vector2f &value);
102  ZENI_DLL std::istream & unserialize(std::istream &is, Vector2f &value);
103 }
104 
105 #endif
GLint GLenum GLboolean normalized
Definition: glew.h:1891
TiXmlString operator+(const TiXmlString &a, const TiXmlString &b)
Definition: tinystr.cpp:86
Quaternion operator/(const float &lhs, const Quaternion &rhs)
Definition: Quaternion.h:114
std::istream & unserialize(std::istream &is, Color &value)
Definition: Color.cpp:72
std::ostream & serialize(std::ostream &os, const Color &value)
Definition: Color.cpp:68
bool degenerate
Definition: Vector2f.h:95
A Featureful 3-Space Vector Class.
Definition: Vector3f.h:58
GLuint index
Definition: glew.h:1800
Quaternion operator*(const float &lhs, const Quaternion &rhs)
Definition: Quaternion.h:110
EGLSurface EGLint void ** value
Definition: eglext.h:301
A 2D Point represented with floats.
Definition: Coordinate.h:98
A 2-Space Vector Class.
Definition: Vector2f.h:41