nomlib
Toggle main menu visibility
Loading...
Searching...
No Matches
include
nomlib
math
Point3.hpp
1
/******************************************************************************
2
3
nomlib - C++11 cross-platform game engine
4
5
Copyright (c) 2013, 2014 Jeffrey Carpenter <i8degrees@gmail.com>
6
All rights reserved.
7
8
Redistribution and use in source and binary forms, with or without
9
modification, are permitted provided that the following conditions are met:
10
11
1. Redistributions of source code must retain the above copyright notice, this
12
list of conditions and the following disclaimer.
13
2. Redistributions in binary form must reproduce the above copyright notice,
14
this list of conditions and the following disclaimer in the documentation
15
and/or other materials provided with the distribution.
16
17
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
18
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
19
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
20
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
21
ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
22
(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
23
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
24
ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
25
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
26
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
27
28
******************************************************************************/
29
#ifndef NOMLIB_MATH_POINT3_HEADERS
30
#define NOMLIB_MATH_POINT3_HEADERS
31
32
#include "export.hpp"
33
#include "nomlib/config.hpp"
34
35
namespace
nom {
36
38
const
std::string POINT3_DELIMITER =
", "
;
39
41
template
<
typename
T>
42
struct
NOM_EXPORT
Point3
43
{
45
Point3
() :
46
x(-1),
47
y(-1),
48
z(-1)
49
{
50
//NOM_LOG_TRACE(NOM);
51
}
52
54
~Point3
()
55
{
56
//NOM_LOG_TRACE(NOM);
57
}
58
60
Point3
(T x, T y, T z) :
61
x(x),
62
y(y),
63
z(z)
64
{
65
//NOM_LOG_TRACE(NOM);
66
}
67
73
template
<
typename
U>
74
explicit
Point3<T>
(
const
Point3<U>
& copy) :
75
x( NOM_SCAST(T, copy.x) ),
76
y( NOM_SCAST(T, copy.y) ),
77
z( NOM_SCAST(T, copy.z) )
78
{
79
//NOM_LOG_TRACE(NOM);
80
}
81
83
NOM_EXPORT
inline
const
Point3<T>
&
get
()
const
84
{
85
return
*
this
;
86
}
87
91
NOM_EXPORT
static
const
Point3
null
;
92
94
NOM_EXPORT
static
const
Point3
zero
;
95
96
NOM_EXPORT T x;
97
NOM_EXPORT T y;
98
NOM_EXPORT T z;
99
};
100
108
template
<
typename
T>
109
NOM_EXPORT
110
inline
std::ostream& operator << ( std::ostream& os,
const
Point3<T>
& pos )
111
{
112
os
113
<< pos.x
114
<< POINT3_DELIMITER
115
<< pos.y
116
<< POINT3_DELIMITER
117
<< pos.z;
118
119
return
os;
120
}
121
122
template
<
typename
T>
123
NOM_EXPORT
124
inline
bool
operator == (
const
Point3<T>& lhs,
const
Point3<T>& rhs )
125
{
126
return
( lhs.x == rhs.x ) && ( lhs.y == rhs.y ) && ( lhs.z == rhs.z );
127
}
128
129
template
<
typename
T>
130
NOM_EXPORT
131
inline
bool
operator != (
const
Point3<T>
& lhs,
const
Point3<T>
& rhs )
132
{
133
return
! ( lhs == rhs );
134
}
135
137
typedef
Point3<int>
Point3i;
138
140
typedef
Point3<real32>
Point3f;
141
143
typedef
Point3<real64>
Point3d;
144
146
template
<> NOM_EXPORT
const
Point3i
Point3i::null
;
147
149
template
<> NOM_EXPORT
const
Point3f
Point3f::null
;
150
152
template
<> NOM_EXPORT
const
Point3d
Point3d::null
;
153
155
template
<> NOM_EXPORT
const
Point3i
Point3i::zero
;
156
158
template
<> NOM_EXPORT
const
Point3f
Point3f::zero
;
159
162
template
<> NOM_EXPORT
const
Point3d
Point3d::zero
;
163
164
}
// namespace nom
165
166
#endif
// include guard defined
nom::Point3
3D Point class
Definition
Point3.hpp:43
nom::Point3::get
NOM_EXPORT const Point3< T > & get() const
Obtain a reference of the object.
Definition
Point3.hpp:83
nom::Point3::~Point3
~Point3()
Destructor.
Definition
Point3.hpp:54
nom::Point3::Point3
Point3()
Default constructor; initialize values to Point3<T>::null.
Definition
Point3.hpp:45
nom::Point3< int >::null
static NOM_EXPORT const Point3 null
Definition
Point3.hpp:91
nom::Point3::Point3
Point3(T x, T y, T z)
Constructor variant for initializing x, y, z at construction.
Definition
Point3.hpp:60
nom::Point3< int >::zero
static NOM_EXPORT const Point3 zero
Definition
Point3.hpp:94
Generated on
for nomlib by
1.18.0