zenilib: zenilib/jni/external/zenilib/zeni/Zeni/Vector3f.h Source File

zenilib 0.5.3.0

- Main Page
- Modules
- Namespaces
- Classes
- Files

- File List
- File Members

All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
Vector3f.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
34 #ifndef ZENI_VECTOR3F_H
35 #define ZENI_VECTOR3F_H
36
37 #include <Zeni/Serialization.h>
38
39 namespace Zeni {
40
41 struct Point3f;
42 struct Vector2f;
43 struct Vector3f;
44
45 namespace Global {
46 ZENI_DLL extern const float pi;
47 ZENI_DLL extern const float pi_over_two;
48 ZENI_DLL extern const float three_pi_over_two;
49 ZENI_DLL extern const float over_three;
50 ZENI_DLL extern const float sqrt_two;
51 ZENI_DLL extern const float sqrt_three;
52
53 ZENI_DLL extern const Vector3f vector_i;
54 ZENI_DLL extern const Vector3f vector_j;
55 ZENI_DLL extern const Vector3f vector_k;
56 }
57
58 struct ZENI_DLL Vector3f {
60 inline explicit Vector3f(const bool &degenerate_ = false);
61 inline Vector3f(const float &i_, const float &j_, const float &k_, const bool &degenerate_ = false);
62 inline Vector3f(const Vector3f &rhs, const bool &degenerate_ = false);
63 inline Vector3f(const Point3f &rhs);
64 inline explicit Vector3f(const Vector2f &rhs);
65
66 // Vector addition/subtraction
67 inline Vector3f operator+(const Vector3f &rhs) const;
68 inline Vector3f operator-(const Vector3f &rhs) const;
69 inline Vector3f & operator+=(const Vector3f &rhs);
70 inline Vector3f & operator-=(const Vector3f &rhs);
71
72 // Vector Dot-Product and Cross-Product
73 inline float operator*(const Vector3f &rhs) const;
74 inline Vector3f operator%(const Vector3f &rhs) const;
75 inline Vector3f & operator%=(const Vector3f &rhs);
76
77 // Vector Scalar Multiplication I of II
78 inline Vector3f operator*(const float &rhs) const;
79 inline Vector3f operator/(const float &rhs) const;
80 inline Vector3f & operator*=(const float &rhs);
81 inline Vector3f & operator/=(const float &rhs);
82 inline Vector3f operator-() const;
83
84 // Other Standard Functions
85 Vector3f & normalize();
86 Vector3f normalized() const;
87 inline float magnitude2() const;
88 inline float magnitude() const;
89
90 // Other helpful functions
91 inline Vector3f get_i() const;
92 inline Vector3f get_j() const;
93 inline Vector3f get_k() const;
94 inline Vector3f get_ij() const;
95 inline Vector3f get_ik() const;
96 inline Vector3f get_jk() const;
97 inline Vector3f multiply_by(const Vector3f &rhs) const;
98 inline Vector3f divide_by(const Vector3f &rhs) const;
99 inline float angle_between(const Vector3f &rhs) const;
100
101 // Indexing
102 inline const float & operator[](const int &index) const;
103 inline float & operator[](const int &index);
104
105 // Spherical Accessors and Modifiers
106 float theta() const;
107 float phi() const;
108 void set_spherical(const float &theta, const float &phi, const float &magnitude = 1);
109
110 union {
111 float i;
112 float x;
113 };
114 union {
115 float j;
116 float y;
117 };
118 union {
119 float k;
120 float z;
121 };
122
123 bool degenerate;
124 };
125
126 // Vector Scalar Multiplication Part II of II
127 inline Vector3f operator*(const float &lhs, const Vector3f &rhs);
128
129 ZENI_DLL std::ostream & serialize(std::ostream &os, const Vector3f &value);
130 ZENI_DLL std::istream & unserialize(std::istream &is, Vector3f &value);
131 }
132
133 #endif
normalized
GLint GLenum GLboolean normalized
Definition: glew.h:1891
Zeni::Global::sqrt_three
const float sqrt_three
sqrt(3.0f)
Definition: Vector3f.cpp:32
operator+
TiXmlString operator+(const TiXmlString &a, const TiXmlString &b)
Definition: tinystr.cpp:86
Zeni::operator/
Quaternion operator/(const float &lhs, const Quaternion &rhs)
Definition: Quaternion.h:114
Zeni::unserialize
std::istream & unserialize(std::istream &is, Color &value)
Definition: Color.cpp:72
Zeni::serialize
std::ostream & serialize(std::ostream &os, const Color &value)
Definition: Color.cpp:68
Zeni::Point3f
A 3D Point represented with floats.
Definition: Coordinate.h:133
Zeni::Global::vector_k
const Vector3f vector_k(0, 0, 1)
k == Vector3f(0, 0, 1)
Definition: Vector3f.h:55
Zeni::Global::sqrt_two
const float sqrt_two
sqrt(2.0f)
Definition: Vector3f.cpp:31
Zeni::Vector3f
A Featureful 3-Space Vector Class.
Definition: Vector3f.h:58
Zeni::Vector3f::degenerate
bool degenerate
Definition: Vector3f.h:123
Zeni::Global::pi
const float pi
pi == 3.1415926...
Definition: Vector3f.cpp:27
Serialization.h
index
GLuint index
Definition: glew.h:1800
Zeni::operator*
Quaternion operator*(const float &lhs, const Quaternion &rhs)
Definition: Quaternion.h:110
Zeni::Vector3f::x
float x
Definition: Vector3f.h:112
Zeni::Vector3f::k
float k
Definition: Vector3f.h:119
Zeni::Vector3f::y
float y
Definition: Vector3f.h:116
Zeni::Global::pi_over_two
const float pi_over_two
pi/23
Definition: Vector3f.cpp:28
Zeni::Vector3f::j
float j
Definition: Vector3f.h:115
value
EGLSurface EGLint void ** value
Definition: eglext.h:301
Zeni::Global::vector_i
const Vector3f vector_i(1, 0, 0)
i == Vector3f(1, 0, 0)
Definition: Vector3f.h:53
Zeni::Global::three_pi_over_two
const float three_pi_over_two
3*pi/2
Definition: Vector3f.cpp:29
Zeni::Global::vector_j
const Vector3f vector_j(0, 1, 0)
j == Vector3f(0, 1, 0)
Definition: Vector3f.h:54
Zeni::Vector3f::z
float z
Definition: Vector3f.h:120
Zeni::Vector3f::i
float i
Definition: Vector3f.h:111
Zeni::Global::over_three
const float over_three
1/3
Definition: Vector3f.cpp:30
Zeni::Vector2f
A 2-Space Vector Class.
Definition: Vector2f.h:41