10
|
1 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
|
|
2
|
|
3
|
|
4
|
|
5
|
|
6
|
|
7
|
|
8
|
|
9
|
|
10
|
|
11
|
|
12
|
|
13 <html xmlns="http://www.w3.org/1999/xhtml">
|
|
14 <head>
|
|
15 <title>Math - The Commons Math User Guide - Geometry</title>
|
|
16 <style type="text/css" media="all">
|
|
17 @import url("../css/maven-base.css");
|
|
18 @import url("../css/maven-theme.css");
|
|
19 @import url("../css/site.css");
|
|
20 </style>
|
|
21 <link rel="stylesheet" href="../css/print.css" type="text/css" media="print" />
|
|
22 <meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1" />
|
|
23 </head>
|
|
24 <body class="composite">
|
|
25 <div id="banner">
|
|
26 <span id="bannerLeft">
|
|
27
|
|
28 Commons Math User Guide
|
|
29
|
|
30 </span>
|
|
31 <div class="clear">
|
|
32 <hr/>
|
|
33 </div>
|
|
34 </div>
|
|
35 <div id="breadcrumbs">
|
|
36
|
|
37
|
|
38
|
|
39
|
|
40
|
|
41
|
|
42
|
|
43
|
|
44 <div class="xright">
|
|
45
|
|
46
|
|
47
|
|
48
|
|
49
|
|
50
|
|
51
|
|
52 </div>
|
|
53 <div class="clear">
|
|
54 <hr/>
|
|
55 </div>
|
|
56 </div>
|
|
57 <div id="leftColumn">
|
|
58 <div id="navcolumn">
|
|
59
|
|
60
|
|
61
|
|
62
|
|
63
|
|
64
|
|
65
|
|
66
|
|
67 <h5>User Guide</h5>
|
|
68 <ul>
|
|
69
|
|
70 <li class="none">
|
|
71 <a href="../userguide/index.html">Contents</a>
|
|
72 </li>
|
|
73
|
|
74 <li class="none">
|
|
75 <a href="../userguide/overview.html">Overview</a>
|
|
76 </li>
|
|
77
|
|
78 <li class="none">
|
|
79 <a href="../userguide/stat.html">Statistics</a>
|
|
80 </li>
|
|
81
|
|
82 <li class="none">
|
|
83 <a href="../userguide/random.html">Data Generation</a>
|
|
84 </li>
|
|
85
|
|
86 <li class="none">
|
|
87 <a href="../userguide/linear.html">Linear Algebra</a>
|
|
88 </li>
|
|
89
|
|
90 <li class="none">
|
|
91 <a href="../userguide/analysis.html">Numerical Analysis</a>
|
|
92 </li>
|
|
93
|
|
94 <li class="none">
|
|
95 <a href="../userguide/special.html">Special Functions</a>
|
|
96 </li>
|
|
97
|
|
98 <li class="none">
|
|
99 <a href="../userguide/utilities.html">Utilities</a>
|
|
100 </li>
|
|
101
|
|
102 <li class="none">
|
|
103 <a href="../userguide/complex.html">Complex Numbers</a>
|
|
104 </li>
|
|
105
|
|
106 <li class="none">
|
|
107 <a href="../userguide/distribution.html">Distributions</a>
|
|
108 </li>
|
|
109
|
|
110 <li class="none">
|
|
111 <a href="../userguide/fraction.html">Fractions</a>
|
|
112 </li>
|
|
113
|
|
114 <li class="none">
|
|
115 <a href="../userguide/transform.html">Transform Methods</a>
|
|
116 </li>
|
|
117
|
|
118 <li class="none">
|
|
119 <strong>3D Geometry</strong>
|
|
120 </li>
|
|
121
|
|
122 <li class="none">
|
|
123 <a href="../userguide/optimization.html">Optimization</a>
|
|
124 </li>
|
|
125
|
|
126 <li class="none">
|
|
127 <a href="../userguide/ode.html">Ordinary Differential Equations</a>
|
|
128 </li>
|
|
129
|
|
130 <li class="none">
|
|
131 <a href="../userguide/genetics.html">Genetic Algorithms</a>
|
|
132 </li>
|
|
133 </ul>
|
|
134 <a href="http://maven.apache.org/" title="Built by Maven" class="poweredBy">
|
|
135 <img alt="Built by Maven" src="../images/logos/maven-feather.png"></img>
|
|
136 </a>
|
|
137
|
|
138
|
|
139
|
|
140
|
|
141
|
|
142
|
|
143
|
|
144
|
|
145 </div>
|
|
146 </div>
|
|
147 <div id="bodyColumn">
|
|
148 <div id="contentBox">
|
|
149 <div class="section"><h2><a name="a11_Geometry"></a>11 Geometry</h2>
|
|
150 <div class="section"><h3><a name="a11.1_Overview"></a>11.1 Overview</h3>
|
|
151 <p>
|
|
152 The geometry package provides classes useful for many physical simulations
|
|
153 in the real 3D space, namely vectors and rotations.
|
|
154 </p>
|
|
155 </div>
|
|
156 <div class="section"><h3><a name="a11.2_Vectors"></a>11.2 Vectors</h3>
|
|
157 <p><a href="../apidocs/org/apache/commons/math/geometry/Vector3D.html">
|
|
158 org.apache.commons.math.geometry.Vector3D</a> provides a simple vector
|
|
159 type. One important feature is that instances of this class are guaranteed
|
|
160 to be immutable, this greatly simplifies modelling dynamical systems
|
|
161 with changing states: once a vector has been computed, a reference to it
|
|
162 is known to preserve its state as long as the reference itself is preserved.
|
|
163 </p>
|
|
164 <p>
|
|
165 Numerous constructors are available to create vectors. In addition to the
|
|
166 straightforward cartesian coordinates constructor, a constructor using
|
|
167 azimuthal coordinates can build normalized vectors and linear constructors
|
|
168 from one, two, three or four base vectors are also available. Constants have
|
|
169 been defined for the most commons vectors (plus and minus canonical axes,
|
|
170 null vector, and special vectors with infinite or NaN coordinates).
|
|
171 </p>
|
|
172 <p>
|
|
173 The generic vectorial space operations are available including dot product,
|
|
174 normalization, orthogonal vector finding and angular separation computation
|
|
175 which have a specific meaning in 3D. The 3D geometry specific cross product
|
|
176 is of course also implemented.
|
|
177 </p>
|
|
178 <p><a href="../apidocs/org/apache/commons/math/geometry/Vector3DFormat.html">
|
|
179 org.apache.commons.math.geometry.Vector3DFormat</a> is a specialized format
|
|
180 for formatting output or parsing input with text representation of 3D vectors.
|
|
181 </p>
|
|
182 </div>
|
|
183 <div class="section"><h3><a name="a11.3_Rotations"></a>11.3 Rotations</h3>
|
|
184 <p><a href="../apidocs/org/apache/commons/math/geometry/Rotation.html">
|
|
185 org.apache.commons.math.geometry.Rotation</a> represents 3D rotations.
|
|
186 Rotation instances are also immutable objects, as Vector3D instances.
|
|
187 </p>
|
|
188 <p>
|
|
189 Rotations can be represented by several different mathematical
|
|
190 entities (matrices, axe and angle, Cardan or Euler angles,
|
|
191 quaternions). This class presents a higher level abstraction, more
|
|
192 user-oriented and hiding implementation details. Well, for the
|
|
193 curious, we use quaternions for the internal representation. The user
|
|
194 can build a rotation from any of these representations, and any of
|
|
195 these representations can be retrieved from a <code>Rotation</code>
|
|
196 instance (see the various constructors and getters). In addition, a
|
|
197 rotation can also be built implicitely from a set of vectors and their
|
|
198 image.
|
|
199 </p>
|
|
200 <p>
|
|
201 This implies that this class can be used to convert from one
|
|
202 representation to another one. For example, converting a rotation
|
|
203 matrix into a set of Cardan angles can be done using the
|
|
204 following single line of code:
|
|
205 </p>
|
|
206 <div class="source"><pre>double[] angles = new Rotation(matrix, 1.0e-10).getAngles(RotationOrder.XYZ);</pre>
|
|
207 </div>
|
|
208 <p>
|
|
209 Focus is oriented on what a rotation <em>does</em> rather than on its
|
|
210 underlying representation. Once it has been built, and regardless of
|
|
211 its internal representation, a rotation is an <em>operator</em> which
|
|
212 basically transforms three dimensional vectors into other three
|
|
213 dimensional vectors. Depending on the application, the meaning of
|
|
214 these vectors may vary as well as the semantics of the rotation.
|
|
215 </p>
|
|
216 <p>
|
|
217 For example in a spacecraft attitude simulation tool, users will
|
|
218 often consider the vectors are fixed (say the Earth direction for
|
|
219 example) and the rotation transforms the coordinates coordinates of
|
|
220 this vector in inertial frame into the coordinates of the same vector
|
|
221 in satellite frame. In this case, the rotation implicitly defines the
|
|
222 relation between the two frames (we have fixed vectors and moving frame).
|
|
223 Another example could be a telescope control application, where the
|
|
224 rotation would transform the sighting direction at rest into the desired
|
|
225 observing direction when the telescope is pointed towards an object of
|
|
226 interest. In this case the rotation transforms the direction at rest in
|
|
227 a topocentric frame into the sighting direction in the same topocentric
|
|
228 frame (we have moving vectors in fixed frame). In many case, both
|
|
229 approaches will be combined, in our telescope example, we will probably
|
|
230 also need to transform the observing direction in the topocentric frame
|
|
231 into the observing direction in inertial frame taking into account the
|
|
232 observatory location and the Earth rotation.
|
|
233 </p>
|
|
234 <p>
|
|
235 These examples show that a rotation means what the user wants it to
|
|
236 mean, so this class does not push the user towards one specific
|
|
237 definition and hence does not provide methods like
|
|
238 <code>projectVectorIntoDestinationFrame</code> or
|
|
239 <code>computeTransformedDirection</code>. It provides simpler and more
|
|
240 generic methods: <code>applyTo(Vector3D)</code> and
|
|
241 <code>applyInverseTo(Vector3D)</code>.
|
|
242 </p>
|
|
243 <p>
|
|
244 Since a rotation is basically a vectorial operator, several
|
|
245 rotations can be composed together and the composite operation
|
|
246 <code>r = r<sub>1</sub> o r<sub>2</sub></code> (which means that for each
|
|
247 vector <code>u</code>, <code>r(u) = r<sub>1</sub>(r<sub>2</sub>(u))</code>)
|
|
248 is also a rotation. Hence we can consider that in addition to vectors, a
|
|
249 rotation can be applied to other rotations as well (or to itself). With our
|
|
250 previous notations, we would say we can apply <code>r<sub>1</sub></code> to
|
|
251 <code>r<sub>2</sub></code> and the result we get is <code>r =
|
|
252 r<sub>1</sub> o r<sub>2</sub></code>. For this purpose, the class
|
|
253 provides the methods: <code>applyTo(Rotation)</code> and
|
|
254 <code>applyInverseTo(Rotation)</code>.
|
|
255 </p>
|
|
256 </div>
|
|
257 </div>
|
|
258
|
|
259 </div>
|
|
260 </div>
|
|
261 <div class="clear">
|
|
262 <hr/>
|
|
263 </div>
|
|
264 <div id="footer">
|
|
265 <div class="xright">©
|
|
266 2003-2010
|
|
267
|
|
268
|
|
269
|
|
270
|
|
271
|
|
272
|
|
273
|
|
274
|
|
275
|
|
276 </div>
|
|
277 <div class="clear">
|
|
278 <hr/>
|
|
279 </div>
|
|
280 </div>
|
|
281 </body>
|
|
282 </html>
|