For version 0.7.0.
To top.  Up: ..Shapes

..Shapes..Geometry3D


Core bindings
Schur_decomp affinetransform coords emptypath @eyez immerse inverse orthogonal rotate scale shift view

Summary of extensions
..Shapes..Geometry3D / circle
ccw_arc3D cw_arc3D generic_arc3D

The geometric objects in Shapes are coordinates and paths. This namespace is for operations within this class of objects. Once the geometric objects are painted (typically stroked or filled), they become graphical objects and are no longer under the topic of this namespace. Compare ..Shapes..Graphics3D. This namespace is also used for the border between the 2d and 3d geometry worlds, so that ..Shapes..Geometry doesn't get disturbed by the things that only concern those that think in 3d.
Separation of 2d and 3d concerns in its current form was initiated with the introduction of namespaces in Shapes, and this separation is still work in progress. This means that even when working purely in 3d, it is still necessary to use contents of the ..Shapes..Geometry namespace from time to time. The function is a typical such example; it still follows the old design where a single function is used for both 2d and 3d.
Sections:    From 3d to 2d and back    Syntax equivalents    Functions of points    Functions of paths    Affine transforms

From 3d to 2d and back

view
::§Geometric3D §Geometric
Dynamic references:none
Apply pin-hole camera projection. The geometry of the projection is documented under @eyez.
Exactly how 3d objects, if they can at all, behave when being projected, depend on the exact object type. §Drawable3D objects will result in §Drawable objects, the operation is generally very complicated if occlusions are to be taken into account. (What makes it difficult is that Shapes deals with scalable graphics, and cannot resort to a pixel z-buffer.) There are three 3d graphics container types with different behaviors. First, §Group3D takes no consideration of occlusions, and just puts the projections of its part on top of each other in the order in which they appear in the data structure. The two remaining types tries to respect occlusions, and the reader is referred to the documentation of these types to find out more about their algorithms, see §ZBuffer and §ZSorter.
See also:immerse
@eyez
Used by:
Type:§Length
Default binding:50 cm
Constraint:@eyez > 0 bp or @eyez =
When a 3d world is viewed through a pin-hole camera to obtain 2d image, the pin-hole camera (the eye) is located at ( 0, 0, zeye ), and the image plane is z = 0. The special float value can be used to place the eye at infinity, which will make the projection independent of z coordinates.
immerse
::§Geometric §Geometric3D
Dynamic references:none
Move object from 2d to 3d by equipping it with a z = 0 coordinate. The operation is reversed by view.

Syntax equivalents

coords
::§Float ::§Float ::§Float §FloatTriple
Dynamic references:none
Implements float-triple.
::§LengthLike ::§LengthLike ::§LengthLike §Coords3D
Dynamic references:none
Implements coords-3D.
Note that all arguments must be §LengthLike, with no exception.

Functions of points

orthogonal
::§FloatTriple §FloatTriple
Dynamic references:none
Produces vector which is orthogonal to the given one. The funciton preserves norm, but the argument must not have zero length.
The direction of the result is computed as a cross product with either the x or the y basis vector, depending on which one is less parallel to the argument.

Functions of paths

emptypath
Type:§Path3D
The analogue of ..Shapes..Geometry..emptypath, but in 3d instead of 2d.

Affine transforms

affinetransform
::§FloatTriple ::§FloatTriple ::§FloatTriple ::§Coords3D §Transform3D
Dynamic references:none
Construct transform from multiplier for x, y, and z coordinates, followed by a shift.
shift
::§Coords3D §Transform3D
Dynamic references:none
Construct transform.
rotate
dir::§FloatTriple angle::§Float §Transform3D
Dynamic references:none
Construct rotation transform about given direction.
scale
r:1::§Float x:1::§Float y:1::§Float z:1::§Float §Transform3D
Dynamic references:none
Construct transform that scales x by r*x, and similarly with y and z.
inverse
::§Transform3D §Transform3D
Dynamic references:none
Constructs the inverse of a transform. This is only possible if the linear part of the transform is non-singular.
Schur_decomp
tf::§Transform3D rank::§Integer canonical:false::§Boolean (> Q::§Transform3D U::§Transform3D <)
Computes a rigid body coordinate transform that brings the transform tf into a simple form. The linear part of the coordinate transform is given by the real Schur decomposition, ensuring that a real eigenvalue is associated with the third basis vector. (Hence, if there is a 2 by 2 block in the Schur form, it will be in the upper left part.) The translational part of the coordinate transform is computed to make the translational part in the new coordinates small. The rank parameter determines how many equation to use when the translational part is computed. If rank is not provided, it is determined automatically from singular values. A rank of zero means that the translational part of the coordinate transform shall not be used at all. If canonical is set, the coordinate transform is made special (that is, it preserves orientation), and if there is an extra degree of freedom in the coodinate transform due to complex eigenvalues in the linear part of tf, it is used to minimize the angle of rotation in the coordinate transform.
Note that the rank shall not be selected full (that is, 3) if tf is a rigid body transformation; use 2 if the rotation is not close to zero, and 0 otherwise (or use the automatic selection). Compare Chasles' theorem, which says that the new transform will in general have a non-trivial translational part.
This function may be used to find a rotation's eigenvector (that is, the direction of the rotation), as the eigenvector will be in the third column of the linear part of the change of coordinates.
tf: [rotate angle:25° dir:(1,2,3)]
•stdout << [Schur_decomp tf].Q.Lz
Schur decomposition
The generalization of real Schur decomposition to also include a translation. It can be seen that rank 2 is selected for a rigid body transform with non-trivial rotation. It is also seen that, whithout setting the canonical flag, the coordinate transform may not preserve orientation.

Source: show/hide visit

stdout: show/hide
Get Shapes at SourceForge.net. Fast, secure and Free Open Source software downloads