File: composite.rst

package info (click to toggle)
openstructure 2.9.3-2
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 205,228 kB
  • sloc: cpp: 188,129; python: 35,361; ansic: 34,298; fortran: 3,275; sh: 286; xml: 146; makefile: 29
file content (542 lines) | stat: -rw-r--r-- 13,236 bytes parent folder | download | duplicates (2)
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
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
Geometric Objects
================================================================================

.. currentmodule:: ost.geom

Geometrical Objects in Two Dimensions
--------------------------------------------------------------------------------

.. class:: Line2()
           Line2(from, to)
  
  Parametric line in two dimensions as defined by an origin and a normalized
  direction vector. The first constructor creates a line with origin (0,0) and 
  direction along the x axis. The second signature creates a line originating 
  from `from` and pointing towards `to`.
  
  .. method:: At(t)
    
    Returns the point on the line at (signed) distance t from origin.
    
    :param t: free parameter
    :type  t: float
    :rtype:   :class:`Vec2`
  

  .. method:: GetOrigin()
  
    Returns the origin of the line: Also available as :attr:`origin`.
    
    :rtype: :class:`Vec2`
    
  .. method:: GetDirection()
  
    Returns the normalized direction vector. Also available as
    :attr:`direction`.
    
    :rtype: :class:`Vec2`
    
  .. attribute:: direction
  
  .. attribute:: origin

    
.. class:: Rectangle2()
           Rectangle2(top_left, bottom_right)
  
  Axis aligned rectangle. The first signature creates a rectangle with top-left 
  corner (-1, -1) and bottom-right corner (1, 1), wheras the second method 
  allows to set the top-left and bottom-right corners directly.
  
  :type top_left: :class:`Vec2`
  :param top_left: The top-left corner
  :param bottom_right: The bottom-right corner  
  :type bottom_right: :class:`Vec2`  

  .. method:: GetWidth()
    
    Returns the width of the rectangle. Also available as :attr:`width`.  
  
  .. method:: GetHeight()
  
    Returns the height of the rectangle. Also available as :attr:`height`.  
    
  .. attribute:: width
  
    :type: float
    
  .. attribute:: height

    :type: float  
    
  .. method:: GetStart()
  
    Get top-left corner
    
    :rtype: :class:`Vec2`
    
  .. method:: GetEnd()

    Get bottom-right corner

    :rtype: :class:`Vec2`    
  
  .. method:: SetStart(top_left)
  
    Set top-left corner, leaving the bottom-right corner untouched.
    
  .. method:: SetEnd(bottom_right)
  
    Set the bottom-right corner, leaving the top-left corner untouched.

.. class:: Circle2()
           Circle2(circle)
           Circle2(center, radius)

  The first signature creates a circle centered at (0, 0) and radius 1.0. The 
  second signature creates a circle with the same paramters as `circle`. The 
  third signature creates a new circle with given center and radius.
     
  .. method:: SetCenter(center)
  
    Set center of circle
    
    :type center: :class:`Vec2`
    :param center: The new center
    
  .. method:: SetRadius(radius)
  
    Set radius of circle
  
    :type radius: float
    :param center: The new radius
    
  .. method:: GetCenter()
  
    Returns the center of the circle
    
  .. method:: GetRadius()
  
    Returns the radius of the circle
    
  .. method:: GetArea()
  
    Returns the area of the circle
    
  .. method:: GetCircumference()
  
    Returns the circumference of the circle


.. class:: Ellipse2()
           Ellipse2(center, a, b, gamma)

  An ellipse is defined by a center, two principal axis and gamma that 
  defines the angle between the first principal axis an the x-axis.
  
  .. method:: At(t)
  
    ?
  
  .. method:: AtAngle(angle)
  
    ?
  
  .. method:: GetBoundingBox()
  
    Returns the bounding rectangle (axis-aligned) of the ellipse
    
    :rtype: :class:`Rectangle2`
    

  .. method:: GetA()
  
    Returns the first principal-axis
  
  .. method:: GetB()
  
    Returns the second principal-axis
    
  .. method:: GetGamma()
    
    Returns the angle of the first principal axis to the x-axis
    
  .. method:: GetArea()
  
    Returns the area of the ellipse
    
  .. method:: GetOrigin()
  
    Returns the center of the ellipse
    
  .. method:: SetA(a)
  
    Set the length of the first principal axis
    
  .. method:: SetB(b)
  
    Set the length of the second principal axis
    
  .. method:: SetGamma(gamma)
  
    Set the angle of the first principal axis to the x-axis
    
  .. method:: SetOrigin(ori)
  
    Set the center of the ellipse
    
Geometrical Objects in Three Dimensions
-------------------------------------------------------------------------------

.. class:: Line3()
           Line3(from, to)
  
  Parametric line in three dimensions as defined by an origin and a normalized
  direction vector. The first constructor creates a line with origin (0,0) and 
  direction along the x axis. The second signature creates a line originating 
  from `from` and pointing towards `to`.
  
  .. method:: At(t)
    
    Returns the point on the line at (signed) distance t from origin.
    
    :param t: free parameter
    :type  t: float
    :rtype:   :class:`Vec3`
  

  .. method:: GetOrigin()
  
    Returns the origin of the line: Also available as :attr:`origin`.
    
    :rtype: :class:`Vec3`
    
  .. method:: GetDirection()
  
    Returns the normalized direction vector. Also available as
    :attr:`direction`.
    
    :rtype: :class:`Vec3`
    
  .. attribute:: direction
  
    :type: :class:`Vec3`
  
  .. attribute:: origin
    
    :type: :class:`Vec3`

.. class:: Plane()
           Plane(p1, p2, p3)
           Plane(x, y, z, p)
           Plane(line, point)
           Plane(point, normal)
  
  A plane in 3d-space. The plane can be constructed by either passing in 3 
  points (p1, p2, p3), a normal and a point, the four parameters that define the 
  implicit plane equation (`x`, `y`, `z`, `p`) or a line and a point.
  
  .. method:: GetNormal()
  
    Returns the normal of the plane. Also available as :attr:`normal`
    
    :rtype: :class:`Vec3`
    
  .. method:: GetP()
  
    Returns the plane offset, i.e. the projection of any point on the plane onto
    the normal. Also available as :attr:`p`.
    
    :rtype: float
    
  .. method:: GetOrigin()
  
    Get the origin of the plane. Also available as :attr:`origin`.
    
    :rtype: :class:`Vec3`

  .. attribute:: origin
  
    :type: :class:`Vec3`
  .. attribute:: normal
  
    :type: :class:`Vec3`
      
  .. attribute:: p
  
    :type: float
 

.. class:: Sphere()
           Sphere(center, radius)
           
  Represents a sphere in 3d space. The first constructor creates a sphere with 
  radius 1, centered at (0, 0, 0), the second allows you to set the radius and 
  center directly.
  
  :param center: The center
  :type  center: :class:`Vec3`
  :param radius: The radius
  :type  radius: float
  
  .. attribute:: radius
    
    The radius of the sphere. Read-write. Also available as :meth:`GetRadius`, 
    :meth:`SetRadius`.
    
    :type: float
    
  .. attribute:: origin
  
    The center of the sphere. Read-write. Also available as :meth:`GetOrigin`,
    :meth:`SetOrigin`.
    
    :type: :class:`Vec3`

  .. method:: GetOrigin()  
  
    See :attr:`origin`
    
  .. method:: SetOrigin(origin)
    
    See :attr:`origin`
    
  .. method:: GetRadius()
  
    See :attr:`radius`
     
  .. method:: SetRadius(radius)
    
    See :attr:`radius`

.. class:: AlignedCuboid(min, max)
  
  Axis aligned cuboid is a cuboid whose axes are aligned to the x-, y-, and z- 
  axes of the coordinate system. For arbitrarily oriented bounding cuboid 
  class, see :class:`Cuboid`.
  
  .. method:: GetMin()
  
    Get minimum coordinate, i.e. the lower bound of x-, y-, and z for 
    any point in the cuboid
    
    :rtype: :class:`Vec3`
    
  .. method:: GetMax()
  
    Get maximum coordinate, i.e. the upper bound of x-, y-, and z for
    any point in the cuboid.
    
    :rtype: :class:`Vec3`

.. class:: CuboidAxis()
           CuboidAxis(dir, half_extent)
  
  A cuboid axis is defined by a half-extent, and a direction vector. This class 
  is used in together with the :class:`Cuboid` class.
  
  :param dir: Direction vector, will be normalized
  :type  dir: :class:`Vec3`
  :param half_extent: The half extent
  :type half_extent: float
  
  .. attribute:: vector
  
    The normalized direction vector of the cuboid axis. Also available as 
    :meth:`GetVector`
    
    :type: :class:`Vec3`
  
  .. attribute:: half_extent
  
    The half extent of the cuboid axis is the magnitude of the cuboid 
    axis measured from the center to the corner. Also available as
    :meth:`GetHalfExtent`
    
    :type: float
  
  .. attribute:: extent
  
    The extent of the cuboid axis. This value is always twice the 
    :attr:`half_extent`. Read-only. Also available as 
    :meth:`GetExtent`.
    
    :type: float
    
  .. method:: GetHalfExtent()
  
    See :attr:`half_extent`
  .. method:: GetExtent()
  
    See :attr:`extent`
    
  .. method:: GetVector()
  
    See :attr:`vector`
    
.. class:: Cuboid(center, axis_a, axis_b, axis_c)
  
  An arbitrarily oriented cuboid defined by a center and 3 axis. The 3 cuboid 
  axis are stored in the order they are passed to the constructor. This means, 
  that there is no guarantee that the 3 axes form a right-handed coordinate 
  system. If a right-handed coordinate system is a requirement, you have to 
  ensure this on your own:
  
  .. code-block:: python
  
    center=...
    axis_a=geom.CuboidAxis(...)
    axis_b=geom.CuboidAxis(...)
    axis_c=geom.CuboidAxis(geom.Cross(axis_a.vector, axis_b.vector), ...)
    
    cuboid=geom.Cuboid(center, axis_a, axis_b, axis_c)
  
  :param center: The center
  :type  center: :class:`Vec3`
  :param axis_a: The first axis
  :type  axis_a: :class:`CuboidAxis`
  :param axis_b: The second axis
  :type  axis_b: :class:`CuboidAxis`
  :param axis_c: The third axis
  :type  axis_c: :class:`CuboidAxis`
  
  .. attribute:: center
  
    The center of the cuboid.
    
    :type: :class:`Vec3`
    
  .. attribute:: axis_a
  
    The first cuboid axis
    
    :type: :class:`CuboidAxis`
    
  .. attribute:: axis_b

    The second cuboid axis

    :type: :class:`CuboidAxis`
    
  .. attribute:: axis_c

    The third cuboid axis

    :type: :class:`CuboidAxis`    

Operations on Geometrical Objects
--------------------------------------------------------------------------------

.. function:: Angle(lhs, rhs)

  Calculate the angle (in radians) between `lhs` and `rhs`. 
  
  :param lhs: First object
  :type  lhs: :class:`Line2`, :class:`Line3`, :class:`Plane`
  
  :param rhs: Second object
  :type  rhs: :class:`Line2`, :class:`Line3`, :class:`Plane`
  
  :rtype: float

.. function:: IntersectionPoint(lhs, rhs)

  Calculates and returns the intersection point between `lhs` and `rhs`
  
  :param lhs: First object
  :type  lhs: :class:`Line2`, :class:`Line3`, :class:`Plane`
  
  :param rhs: Second object
  :type  rhs: :class:`Line2`, :class:`Line3`, :class:`Plane`
  
  :raises: :exc:`~exceptions.RuntimeError` when the two objects do not intersect
  :rtype: :class:`Vec3` (:class:`Vec2` in case of :class:`Line2`)

.. function:: IntersectionLine(plane1, plane2)

  Returns the intersection line between `plane1` and `plane2`.
  
  :param plane1: The first plane
  :type  plane1: :class:`Plane`
  :param plane2: The second plane
  :type  plane2: :class:`Plane`  
  
  :raises: :exc:`~exceptions.RuntimeError` if the two planes are parallel.
  
.. function:: Distance(lhs, rhs)

  Returns the minimal distance between `lhs` and `rhs`. 
  
  :param lhs: First object
  :type  lhs: :class:`Line2`, :class:`Line3`, :class:`Plane`
  
  :param rhs: Second object
  :type  rhs: :class:`Line2`, :class:`Line3`, :class:`Plane`
  
  :rtype: float

.. function:: IsOnLine(line, point, epsilon=geom.EPSILON)

  Check whether `point` lies on `line` and returns true if point i no further 
  away than `epsilon`.
  
  :rtype: bool

.. function:: IsInPlane(plane, object, epsilon=geom.EPSILON)
  
  Check whether `object` lies in `plane` and returns true if the difference is 
  no bigger than `epsilon`.
  
  :param plane: The plane
  :type  plane: :class:`Plane`
  :param object: The object
  :type  object: :class:`Vec3` or :class:`Line3`
  
  :rtype: bool

.. function:: AreParallel(lhs, rhs, epsilon=geom.EPSILON)

  Check whether `lhs` and `rhs` are parallel and returns true, if the difference 
  is below the given treshold `epsilon`.
  
  :param lhs: First object
  :type  lhs: :class:`Line2`, :class:`Line3`, :class:`Plane`
  
  :param rhs: Second object
  :type  rhs: :class:`Line2`, :class:`Line3`, :class:`Plane`
  
  :rtype: bool

.. function:: AreIntersecting(line1, line2, epsilon=geom.EPSILON)

  Check whether `line1` and `line2` are intersecting and returns true, if they 
  intersect below the given threshold `epsilon`.
  
  :param lhs: First line
  :type  lhs: :class:`Line2`, :class:`Line3`
  
  :param rhs: Second line
  :type  rhs: :class:`Line2`, :class:`Line3`
  
  :rtype: bool
  

  
.. function:: IsInSphere(sphere, point)

  Check whether the `sphere` contains `point`.
  
  :rtype: bool
  

.. function:: MinDistance(list1, list2)

  Calculate the minimal distance between two sets of points
  
  :param list1: the first set of points
  :type list1: :class:`~ost.geom.Vec3List`
  
  :param list2: the second set of points
  :type list2: :class:`~ost.geom.Vec3List`