Vegastrike 0.5.1 rc1
1.0
Original sources for Vegastrike Evolved
Main Page
Related Pages
Modules
Namespaces
Classes
Files
File List
File Members
All
Classes
Namespaces
Files
Functions
Variables
Typedefs
Enumerations
Enumerator
Friends
Macros
Groups
Pages
IceHPoint.h
Go to the documentation of this file.
1
8
11
// Include Guard
12
#ifndef __ICEHPOINT_H__
13
#define __ICEHPOINT_H__
14
15
class
ICEMATHS_API
HPoint
:
public
Point
16
{
17
public
:
18
20
inline_
HPoint
() {}
22
inline_
HPoint
(
float
_x,
float
_y,
float
_z,
float
_w=0.0f) :
Point
(_x, _y, _z), w(_w) {}
24
inline_
HPoint
(
const
float
f[4]) :
Point
(f), w(f[3]) {}
26
inline_
HPoint
(
const
Point
& p,
float
_w=0.0f) :
Point
(p), w(_w) {}
28
inline_
~HPoint
() {}
29
31
inline_
HPoint
&
Zero
() {
x
=
y
=
z
= w = 0.0f;
return
*
this
; }
32
34
inline_
HPoint
&
Set
(
float
_x,
float
_y,
float
_z,
float
_w ) {
x
= _x;
y
= _y;
z
= _z; w = _w;
return
*
this
; }
36
inline_
HPoint
&
Set
(
const
float
f[4]) {
x
= f[
_X
];
y
= f[
_Y
];
z
= f[
_Z
]; w = f[
_W
];
return
*
this
; }
38
inline_
HPoint
&
Set
(
const
HPoint
& src) {
x
= src.
x
;
y
= src.
y
;
z
= src.
z
; w = src.
w
;
return
*
this
; }
39
41
inline_
HPoint
&
Add
(
float
_x,
float
_y,
float
_z,
float
_w ) {
x
+= _x;
y
+= _y;
z
+= _z; w += _w;
return
*
this
; }
43
inline_
HPoint
&
Add
(
const
float
f[4]) {
x
+= f[
_X
];
y
+= f[
_Y
];
z
+= f[
_Z
]; w += f[
_W
];
return
*
this
; }
44
46
inline_
HPoint
&
Sub
(
float
_x,
float
_y,
float
_z,
float
_w ) {
x
-= _x;
y
-= _y;
z
-= _z; w -= _w;
return
*
this
; }
48
inline_
HPoint
&
Sub
(
const
float
f[4]) {
x
-= f[
_X
];
y
-= f[
_Y
];
z
-= f[
_Z
]; w -= f[
_W
];
return
*
this
; }
49
51
inline_
HPoint
&
Mul
(
float
s) {
x
*= s;
y
*= s;
z
*= s; w *= s;
return
*
this
; }
52
54
float
Min
()
const
{
return
MIN
(
x
,
MIN
(
y
,
MIN
(
z
, w))); }
56
float
Max
()
const
{
return
MAX
(
x
,
MAX
(
y
,
MAX
(
z
, w))); }
58
HPoint
&
Min
(
const
HPoint
& p) {
x
=
MIN
(
x
, p.
x
);
y
=
MIN
(
y
, p.
y
);
z
=
MIN
(
z
, p.
z
); w =
MIN
(w, p.
w
);
return
*
this
; }
60
HPoint
&
Max
(
const
HPoint
& p) {
x
=
MAX
(
x
, p.
x
);
y
=
MAX
(
y
, p.
y
);
z
=
MAX
(
z
, p.
z
); w =
MAX
(w, p.
w
);
return
*
this
; }
61
63
inline_
float
SquareMagnitude
()
const
{
return
x
*
x
+
y
*
y
+
z
*
z
+ w*w; }
65
inline_
float
Magnitude
()
const
{
return
sqrtf(
x
*
x
+
y
*
y
+
z
*
z
+ w*w); }
66
68
inline_
HPoint
&
Normalize
()
69
{
70
float
M
=
Magnitude
();
71
if
(M)
72
{
73
M = 1.0f / M;
74
x
*= M;
75
y
*= M;
76
z
*= M;
77
w *= M;
78
}
79
return
*
this
;
80
}
81
82
// Arithmetic operators
84
inline_
HPoint
operator-
()
const
{
return
HPoint
(-
x
, -
y
, -
z
, -w); }
85
87
inline_
HPoint
operator+
(
const
HPoint
& p)
const
{
return
HPoint
(
x
+ p.
x
,
y
+ p.
y
,
z
+ p.
z
, w + p.
w
); }
89
inline_
HPoint
operator-
(
const
HPoint
& p)
const
{
return
HPoint
(
x
- p.
x
,
y
- p.
y
,
z
- p.
z
, w - p.
w
); }
90
92
inline_
HPoint
operator*
(
const
HPoint
& p)
const
{
return
HPoint
(
x
* p.
x
,
y
* p.
y
,
z
* p.
z
, w * p.
w
); }
94
inline_
HPoint
operator*
(
float
s)
const
{
return
HPoint
(
x
* s,
y
* s,
z
* s, w * s); }
96
inline_
friend
HPoint
operator*
(
float
s,
const
HPoint
& p) {
return
HPoint
(s * p.
x
, s * p.
y
, s * p.
z
, s * p.
w
); }
97
99
inline_
HPoint
operator/
(
const
HPoint
& p)
const
{
return
HPoint
(
x
/ p.
x
,
y
/ p.
y
,
z
/ p.
z
, w / p.
w
); }
101
inline_
HPoint
operator/
(
float
s)
const
{ s = 1.0f / s;
return
HPoint
(
x
* s,
y
* s,
z
* s, w * s); }
103
inline_
friend
HPoint
operator/
(
float
s,
const
HPoint
& p) {
return
HPoint
(s / p.
x
, s / p.
y
, s / p.
z
, s / p.
w
); }
104
106
inline_
float
operator|
(
const
HPoint
& p)
const
{
return
x
*p.
x
+
y
*p.
y
+
z
*p.
z
+ w*p.
w
; }
107
// No cross-product in 4D
108
110
inline_
HPoint
&
operator+=
(
const
HPoint
& p) {
x
+= p.
x
;
y
+= p.
y
;
z
+= p.
z
; w += p.
w
;
return
*
this
; }
112
inline_
HPoint
&
operator+=
(
float
s) {
x
+= s;
y
+= s;
z
+= s; w += s;
return
*
this
; }
113
115
inline_
HPoint
&
operator-=
(
const
HPoint
& p) {
x
-= p.
x
;
y
-= p.
y
;
z
-= p.
z
; w -= p.
w
;
return
*
this
; }
117
inline_
HPoint
&
operator-=
(
float
s) {
x
-= s;
y
-= s;
z
-= s; w -= s;
return
*
this
; }
118
120
inline_
HPoint
&
operator*=
(
const
HPoint
& p) {
x
*= p.
x
;
y
*= p.
y
;
z
*= p.
z
; w *= p.
w
;
return
*
this
; }
122
inline_
HPoint
&
operator*=
(
float
s) {
x
*=s;
y
*=s;
z
*=s; w*=s;
return
*
this
; }
123
125
inline_
HPoint
&
operator/=
(
const
HPoint
& p) {
x
/= p.
x
;
y
/= p.
y
;
z
/= p.
z
; w /= p.
w
;
return
*
this
; }
127
inline_
HPoint
&
operator/=
(
float
s) { s = 1.0f / s;
x
*=s;
y
*=s;
z
*=s; w*=s;
return
*
this
; }
128
129
// Arithmetic operators
130
132
Point
operator*
(
const
Matrix3x3
& mat)
const
;
134
HPoint
operator*
(
const
Matrix4x4
& mat)
const
;
135
136
// HPoint *= Matrix3x3 doesn't exist, the matrix is first casted to a 4x4
138
HPoint
&
operator*=
(
const
Matrix4x4
& mat);
139
140
// Logical operators
141
143
inline_
bool
operator==
(
const
HPoint
& p)
const
{
return
( (
x
==p.
x
)&&(
y
==p.
y
)&&(
z
==p.
z
)&&(w==p.
w
)); }
145
inline_
bool
operator!=
(
const
HPoint
& p)
const
{
return
( (
x
!=p.
x
)||(
y
!=p.
y
)||(
z
!=p.
z
)||(w!=p.
w
)); }
146
147
// Cast operators
148
150
//inline_ operator Point() const { return Point(x, y, z); }
151
152
public
:
153
float
w
;
154
};
155
156
#endif // __ICEHPOINT_H__
157
src
cmd
collide2
Ice
IceHPoint.h
Generated on Fri May 29 2015 23:07:11 for Vegastrike 0.5.1 rc1 by
1.8.4