File: cs_142.html

package info (click to toggle)
crystalspace 0.94-20020412-3
  • links: PTS
  • area: main
  • in suites: woody
  • size: 62,276 kB
  • ctags: 52,843
  • sloc: cpp: 274,783; ansic: 6,608; perl: 6,276; objc: 3,952; asm: 2,942; python: 2,354; php: 542; pascal: 530; sh: 430; makefile: 370; awk: 193
file content (195 lines) | stat: -rw-r--r-- 7,481 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<!-- Created by texi2html 1.64 -->
<!-- 
Written by: Lionel Cons <Lionel.Cons@cern.ch> (original author)
            Karl Berry  <karl@freefriends.org>
            Olaf Bachmann <obachman@mathematik.uni-kl.de>
            and many others.
Maintained by: Olaf Bachmann <obachman@mathematik.uni-kl.de>
Send bugs and suggestions to <texi2html@mathematik.uni-kl.de>
 
-->
<HTML>
<HEAD>
<TITLE>Crystal Space: csGeom</TITLE>

<META NAME="description" CONTENT="Crystal Space: csGeom">
<META NAME="keywords" CONTENT="Crystal Space: csGeom">
<META NAME="resource-type" CONTENT="document">
<META NAME="distribution" CONTENT="global">
<META NAME="Generator" CONTENT="texi2html 1.64">

</HEAD>

<BODY LANG="" BGCOLOR="#FFFFFF" TEXT="#000000" LINK="#0000FF" VLINK="#800080" ALINK="#FF0000">

<A NAME="SEC310"></A>
<TABLE CELLPADDING=1 CELLSPACING=1 BORDER=0>
<TR><TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="cs_141.html#SEC306"> &lt; </A>]</TD>
<TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="cs_143.html#SEC311"> &gt; </A>]</TD>
<TD VALIGN="MIDDLE" ALIGN="LEFT"> &nbsp; <TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="cs_134.html#SEC297"> &lt;&lt; </A>]</TD>
<TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="cs_128.html#SEC290"> Up </A>]</TD>
<TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="cs_159.html#SEC338"> &gt;&gt; </A>]</TD>
<TD VALIGN="MIDDLE" ALIGN="LEFT"> &nbsp; <TD VALIGN="MIDDLE" ALIGN="LEFT"> &nbsp; <TD VALIGN="MIDDLE" ALIGN="LEFT"> &nbsp; <TD VALIGN="MIDDLE" ALIGN="LEFT"> &nbsp; <TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="index.html#SEC_Top">Top</A>]</TD>
<TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="cs_toc.html#SEC_Contents">Contents</A>]</TD>
<TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="cs_285.html#SEC711">Index</A>]</TD>
<TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="cs_abt.html#SEC_About"> ? </A>]</TD>
</TR></TABLE>
<HR SIZE=1>
<H2> 6.5 Geometry Library (<CODE>csGeom</CODE>) </H2>
<!--docid::SEC310::-->
<P>

This library is used to perform any calculations dealing with 2D or 3D
geometry. It contains several more or less independent classes. The most
important classes are:
</P><P>

<UL>
<LI>
<EM>Geometric Functionality</EM>
<P>

These are functions that do not fit in one of the following classes, for
example to calculate intersections. They are grouped as static member
functions of one class. (It does not make sense to create objects of this
class, as it only contains these static member functions).
</P><P>

<LI>
<EM>Vectors</EM>
<P>

These classes represent 2D and 3D vectors.  There is also a variant of the 3D
vector class which uses double precision numbers to represent its elements,
rather than the single precision numbers used by the standard 3D vector class.
These classes supply specially overloaded operators so you can use them in
calculations as you can use integer or float values.  The possible operators
are:
</P><P>

<UL>
<LI>
Add two vectors
<LI>
Subtract two vectors
<LI>
Multiply a vector and a scalar
<LI>
Divide a vector by a scalar
<LI>
Dot product (uses `<SAMP>*</SAMP>' operator)
<LI>
Cross product (uses `<SAMP>%</SAMP>' operator)
<LI>
Comparison of two vectors (`<SAMP>==</SAMP>' and `<SAMP>!=</SAMP>')
<LI>
Projecting one vector on another (`<SAMP>&#60;&#60;</SAMP>' and `<SAMP>&#62;&#62;</SAMP>')
<LI>
Inverting a vector (`<SAMP>-</SAMP>' operator)
<LI>
Comparing all components with a small epsilon value (`<SAMP>&#60;</SAMP>' and `<SAMP>&#62;</SAMP>')
</UL>
<P>

They also contain some functions to normalize the vector or return its length.
Single and double precision vectors can be mixed in calculations.
</P><P>

<LI>
<EM>Matrices</EM>
<P>

These are 2D and 3D matrices. They are used to transform (rotate, scale etc.)
vectors. They also use their own operators for easier usage (for example to
multiply a matrix and a vector).
</P><P>

<LI>
<EM>Transforms</EM>
<P>

A transformation consists of a matrix and a vector. In contrast to just a
matrix you can also include movement in a transform. It also uses its own
operators.
</P><P>

<LI>
<EM>Quaternions</EM>
<P>

Encapsulation of quternion functionality.
</P><P>

<LI>
<EM>Planes</EM>
<P>

These classes represent 2D and 3D planes. They can, for example, be used to
split polygons or to calculate the distance of a point from a polygon (or
line segments instead of polygons for 2D planes).
</P><P>

<LI>
<EM>Line Segments</EM>
<P>

A line segment is a straight line between two points, which ends at these
points. It could for example be used to define start and finish point of
straight movement. There are 2D and 3D segments.
</P><P>

<LI>
<EM>Polygons</EM>
<P>

Polygons are an important class used heavily in the 3D engine. A polygon is
built from at least three points, called <EM>vertices</EM>. All vertices must
be on the same plane in space. The polygons outline consists of all line
segments from one vertex to the next one, including the segment from the last
vertex to the first one. These segments may not cross. Also, the polygon
must be convex, which means that if you take two arbitrary points inside the
polygon and draw a straight line between them, it may not cross any of the
polygon's edges.  A polygon has two faces, defined by the order of the
vertices: If you count through all vertices, and from your position they appear
in clockwise order, then you are viewing the front face, otherwise you are
viewing the back face.  The <EM>normal</EM> vector of the polygon always points
out perpendicular from the front face.
</P><P>

There are different types of polygons concerning management of the vertices
and how they can be used. First, there are the basic 2D and 3D polygons that
store their vertices as 3D vectors. The clippers are similar to this but
they are spcialized on clipping other polygons (you lay the clipper somewhere
on a polygon and cut everything away of the polygon that is outside the
clipper, resulting in a new, smaller polygon). Then there is a 2D polygon
that stores its sides as line segments, not its vertices as vectors.
The most important type for the engine is the indexed polygon, which does not
store its vertices as 3D vectors but only as indices in a table.
</UL>
<P>

There are also other classes that are mostly used inside the engine, such as
bounding boxes, frustums, polygon pools, etc.
<A NAME="CSWS"></A>
<HR SIZE=1>
<TABLE CELLPADDING=1 CELLSPACING=1 BORDER=0>
<TR><TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="cs_141.html#SEC306"> &lt; </A>]</TD>
<TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="cs_143.html#SEC311"> &gt; </A>]</TD>
<TD VALIGN="MIDDLE" ALIGN="LEFT"> &nbsp; <TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="cs_134.html#SEC297"> &lt;&lt; </A>]</TD>
<TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="cs_128.html#SEC290"> Up </A>]</TD>
<TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="cs_159.html#SEC338"> &gt;&gt; </A>]</TD>
<TD VALIGN="MIDDLE" ALIGN="LEFT"> &nbsp; <TD VALIGN="MIDDLE" ALIGN="LEFT"> &nbsp; <TD VALIGN="MIDDLE" ALIGN="LEFT"> &nbsp; <TD VALIGN="MIDDLE" ALIGN="LEFT"> &nbsp; <TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="index.html#SEC_Top">Top</A>]</TD>
<TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="cs_toc.html#SEC_Contents">Contents</A>]</TD>
<TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="cs_285.html#SEC711">Index</A>]</TD>
<TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="cs_abt.html#SEC_About"> ? </A>]</TD>
</TR></TABLE>
<BR>  
<FONT SIZE="-1">
This document was generated

using <A HREF="http://www.mathematik.uni-kl.de/~obachman/Texi2html
"><I>texi2html</I></A>

</BODY>
</HTML>