VR-Forces Development_Version Class Documentation
Home
Modules
Namespaces
Classes
Files
Examples
Behavior Models
File List
File Members
All
Classes
Namespaces
Files
Functions
Variables
Typedefs
Enumerations
Enumerator
Friends
Macros
Groups
Pages
include
geometry
point.h
Go to the documentation of this file.
1
/*******************************************************************************
2
** Copyright (c) 2003 MAK Technologies, Inc.
3
** All rights reserved.
4
*******************************************************************************/
5
/*******************************************************************************
6
** $RCSfile: point.h,v $ $Revision: 1.27 $ $State: Exp $
7
*******************************************************************************/
8
9
#ifndef point_H_
10
#define point_H_
11
12
#ifndef NO_VRLINK
13
#include <vlutil/vlConfig.h>
14
#include <vlutil/vlString.h>
15
#include <vlutil/vlUtil.h>
16
#include <matrix/vlVector.h>
17
#endif
18
19
#include <stdio.h>
20
#include <iostream>
21
#include "
geometry/geometryDefines.h
"
22
23
class
Dt4dPoint;
24
class
DtPoint
;
25
26
typedef
DtPoint
DtVertex
;
27
28
// DtPoint represents points in 3-space.
29
// DtPoint may rely on vrlink (for things like DtString and DtVector).
30
// This class has no virtual functions, in order to minimize its run-time
31
// size. (A terrain database can have millions of DtPoints, so the
32
// vtable ptr can matter).
33
34
class
DT_DLL_geometry
DtPoint
35
{
36
37
public
:
38
// friend std::ostream& operator<<(std::ostream& os, const DtPoint& point);
39
// friend std::istream& operator>>(std::istream& is, DtPoint& point);
40
41
42
DtPoint
(
43
const
double
& x = 0.0,
44
const
double
& y = 0.0,
45
const
double
& z = 0.0);
46
47
enum
DtPointIndex
{
48
DtPX = 0,
49
DtPY = 1,
50
DtPZ = 2,
51
DtMAXPointIndex
52
};
53
54
DtPoint
(
const
DtPoint
& orig);
55
DtPoint
(
const
DtVector
& orig);
56
DtPoint
(
const
Dt4dPoint& orig);
57
58
virtual
~
DtPoint
();
59
60
DtPoint
& operator=(
const
DtPoint
& rhs);
61
DtPoint
& operator=(
const
DtVector
& rhs);
62
DtPoint
& operator=(
const
Dt4dPoint& rhs);
63
64
const
double
& operator[](
const
int
& index)
const
;
65
double
& operator[](
const
int
& index);
66
67
const
double
& operator[](
const
DtPointIndex& index)
const
;
68
double
& operator[](
const
DtPointIndex& index);
69
70
bool
operator==
(
const
DtPoint
& rhs)
const
;
71
bool
operator!=
(
const
DtPoint
& rhs)
const
;
72
73
DtPoint
operator*(
const
double
& rhs)
const
;
74
DtPoint
& operator*=(
const
double
& rhs);
75
76
DtPoint
operator/(
const
double
& rhs)
const
;
77
DtPoint
& operator/=(
const
double
& rhs);
78
79
DtPoint
operator+(
const
DtPoint
& rhs)
const
;
80
DtPoint
& operator+=(
const
DtPoint
& rhs);
81
82
DtPoint
operator+(
const
DtVector
& rhs)
const
;
83
DtPoint
& operator+=(
const
DtVector
& rhs);
84
85
DtPoint
operator-(
const
DtPoint
& rhs)
const
;
86
DtPoint
& operator-=(
const
DtPoint
& rhs);
87
88
DtPoint
operator-(
const
DtVector
& rhs)
const
;
89
DtPoint
& operator-=(
const
DtVector
& rhs);
90
91
// compares two points and returns true if the distance between them
92
// is within the tolerance value.
93
bool
approxEq(
const
DtPoint
& p,
const
double
& tolerance)
const
;
94
95
const
double
& x()
const
;
96
const
double
& y()
const
;
97
const
double
& z()
const
;
98
99
void
set
(
const
double
& x,
const
double
& y,
const
double
& z);
100
void
setX(
const
double
& x);
101
void
setY(
const
double
& y);
102
void
setZ(
const
double
& z);
103
104
// Distance from this point to end point.
105
double
distanceTo(
const
DtPoint
& end)
const
;
106
double
distanceSquaredTo(
const
DtPoint
& end)
const
;
107
108
// Distance from this point to end point. Ignores Z values.
109
double
xyDistanceTo(
const
DtPoint
& end)
const
;
110
double
xyDistanceSquaredTo(
const
DtPoint
& end)
const
;
111
112
// Distance from this point to line defined by points A and B. Ignores Z.
113
double
xyDistanceToLine(
const
DtPoint
& pointA,
const
DtPoint
& pointB)
const
;
114
double
xyDistanceToLineSquared(
const
DtPoint
& pointA,
const
DtPoint
& pointB)
const
;
115
116
// Assuming that this point is the end point of a vector
117
// starting at (0,0,0), This function normalizes that
118
// vector and sets this point to the normalized end point.
119
void
normalize();
120
121
// Distance from this point to the origin (0,0,0) point.
122
double
magnitudeSquared()
const
;
123
124
DtVector
difference(
const
DtPoint
& p)
const
;
125
126
#ifndef NO_VRLINK
127
DtString
string()
const
;
128
#endif
129
130
bool
readFrom(FILE* fp);
131
bool
writeTo(FILE* fp);
132
133
void
dump(
const
char
* label)
const
;
134
135
protected
:
136
double
myRep[3];
137
};
138
139
DT_DLL_geometry
std::ostream&
operator<<
(std::ostream& os,
const
DtPoint
& point);
140
DT_DLL_geometry
std::istream&
operator>>
(std::istream& is,
DtPoint
& point);
141
142
inline
DtPoint::DtPoint
(
const
double
& x,
const
double
& y,
const
double
& z)
143
{
144
myRep
[
DtPX
] =
x
;
145
myRep
[
DtPY
] =
y
;
146
myRep
[
DtPZ
] =
z
;
147
}
148
149
inline
DtPoint::~DtPoint
()
150
{
151
}
152
153
inline
const
double
&
DtPoint::operator[]
(
const
int
& index)
const
154
{
155
return
myRep
[index];
156
}
157
158
inline
double
&
DtPoint::operator[]
(
const
int
& index)
159
{
160
return
myRep
[index];
161
}
162
163
inline
const
double
&
DtPoint::operator[]
(
const
DtPointIndex
& index)
const
164
{
165
return
myRep
[index];
166
}
167
168
inline
double
&
DtPoint::operator[]
(
const
DtPointIndex
& index)
169
{
170
return
myRep
[index];
171
}
172
173
inline
void
DtPoint::set
(
const
double
& x,
const
double
& y,
const
double
& z)
174
{
175
myRep
[
DtPX
] =
x
;
176
myRep
[
DtPY
] =
y
;
177
myRep
[
DtPZ
] =
z
;
178
}
179
180
inline
const
double
&
DtPoint::x
()
const
181
{
182
return
myRep
[
DtPX
];
183
}
184
185
inline
void
DtPoint::setX
(
const
double
& x)
186
{
187
myRep
[
DtPX
] =
x
;
188
}
189
190
inline
const
double
&
DtPoint::y
()
const
191
{
192
return
myRep
[
DtPY
];
193
}
194
195
inline
void
DtPoint::setY
(
const
double
& y)
196
{
197
myRep
[
DtPY
] =
y
;
198
}
199
200
inline
const
double
&
DtPoint::z
()
const
201
{
202
return
myRep
[
DtPZ
];
203
}
204
205
inline
void
DtPoint::setZ
(
const
double
& z)
206
{
207
myRep
[
DtPZ
] =
z
;
208
}
209
210
#endif
Document ID: Generated on Tue Mar 8 22:13:38 EST 2016 from SVN revision 162938
Copyright © 2005-2015 VT MÄK. All Rights Reserved (
www.mak.com
)