Frames / Orientation / Transforms Blog

Technical discussions
Post Reply
nickz
Site Admin
Posts: 236
Joined: Fri Jul 26, 2013 3:58 am

Frames / Orientation / Transforms Blog

Post by nickz »

Hello everyone
This is another key topic, which sometimes looks murky for newcomers. Similar to the other blogs here this discussion in large extent relevant to any 3D software.

It is about location and orientation of objects (sections and other types of 3D entities). To clarify (or actually to muddy a little :D) quite often orientation word is used in generalised sense and included location and location term can also include orientation

Why bother about it at all? Why not define everything in a single coordinate axes and make everything very clear? This is because objects can be moved in space as a single entity. So normally definition of 3D objects include orientation (and location) attribute

In KernelCAD it is the notion of local frame, which is a set of axes which can be located anywhere in 3D and arbitrary oriented. A frame is defined by position of its origin (the basic, non-generalised location) and directions of its three axes (the basic, non-generalised orientation)

Geometry (coordinates of any items defining surface/curve/point set) of any KC object is defined and internally stored relative to this local frame. When the object is moved in space only the small information about location and orientation of the local frame is modified. The geometry remains the same. Remember that some objects can have huge geometry with millions of vertices in case of a mesh. Without the local frame any movement would need to recalculate coordinates of all of them

More shortly...

nickz
Site Admin
Posts: 236
Joined: Fri Jul 26, 2013 3:58 am

Frames

Post by nickz »

Frame is another word for axes of coordinates thought of as a 3D geometric object. A frame has origin and three perpendicular vectors of length one

There is one privileged frame called global axes or global frame or identity frame (a bit later why). On top level all other objects in 3D are defined relative to this frame. One can talk about geometric object without talking about global axes, but it must be defined when you mention coordinates. Coordinates are always relative to some frame. If not frame is specified it means all coordinates are in the global frame

Any other frame defined relative to the global frame. It has three coordinates of its origin and 9 numbers defining direction of the three axes

By default any frame created in KC coincides with the global frame. So its origin has (0,0,0) coordinates and directions of the axes are: (1,0,0),(0,10),(0,0,1)

Frames are manipulated in KC using IFrame* interfaces: http://www.dynoinsight.com/Help/Interfa ... rview.aspx. In v4.3 we have merged most of the operations into IFrame3. So IFrame3 is probably the most useful

Many KC objects like sections have a frame attribute, which define its orientation (including location). Its can be accessed via querying the required IFrame* object from the relevant ISection or similar interface.

You can also construct a new frame to do any calcualtions/manipulations with it using IDIObjGenerator.Create*(): http://www.dynoinsight.com/Help/Geom/Objects/Frame.aspx

When you have defined another (different from global) frame, coordinates of points or vectors can be defined relative to this new frame. They are called local coordinates. To convert coordinates of a point from local to global use IFrame3.ToGlobal() http://www.dynoinsight.com/Help/Interfa ... x#ToGlobal. IFrame3.ToLocal() does the opposite. To do the same operation for vectors use IFrame3.ToGlobalVector()/ToLocalVector()

When you have two local frames, say f1 and f2, to convert coordinates from one to another use sequence: f1.ToGlobal(point); f2.ToLocal(point); Same for vectors

A frame is a point and three vectors. So by the same token one can define a frame relative to another non-global (local) frame. Its conversion can be performed with IFrame3.ToGlobalFrame()/ToLocalFrame() http://www.dynoinsight.com/Help/Interfa ... lobalFrame

nickz
Site Admin
Posts: 236
Joined: Fri Jul 26, 2013 3:58 am

Orientation

Post by nickz »

Orientation in its basic meaning is an abstract notion, a pure geometric thing. It does not have to be related to any particular object. In plain English orientation is what remains from a frame if we ignore location. Two frames have save orientation if their correspondent axes have same direction (coincide up to a translation)

Notice that Orientation is different form direction. Direction is related to a single vector or ray. Orientation involves three axes in space

Most often in software orientation is defined with quaternions https://en.wikipedia.org/wiki/Quaternion, which are general rotations about some arbitrary axis, but with KC you do not need to know what they are. We are trying our best to avoid practically any math and stick to intuitive definitions similar to the above. So general orientation is an orientation of global axes after some general rotation, which can be defined with quaternions

KC frame is same thing as a quaternion plus a location point

General three orthogonal axes can define two different types of orientation: positive (right hand) and negative (left hand) https://en.wikipedia.org/wiki/Right-hand_rule. Two frames have same type of orientation if the can be made coinciding with translations and rotations. KC deals only with positively oriented frames (positive orientations). This is mainly for simplicity. There are situations where negative orientation is useful

nickz
Site Admin
Posts: 236
Joined: Fri Jul 26, 2013 3:58 am

Transforms

Post by nickz »

Few basics: Transforms are mappings 3D space into itself. So it is a rule which maps any point into another one. Transform which maps any point to itself is called identity transform

Any frame f defines a transform which maps any point (defined by its global coordinates) to the point which has same coordinates relative to f. if f is the global frame the transform will be the identity

Transforms defined with a frame have two special properties: They preserve straight lines and they preserve distances. More exactly if you have three points on a straight line, their images will lie on (generally another) straight line. This means that whole straight line as set of points is mapped into a straight line. Also distances between any two points remain the same after applying the transform

Transform like that are exactly affine transforms: https://en.wikipedia.org/wiki/Affine_transformation. On the other hand if you have an affine transform there is exactly one frame which defines it. So frames are practically the same thing as an affine transform

For completeness: Linear transforms is a subset of affine ones. Linear transforms are the ones which map the global origin point into itself. In terms of frames these are the frames located at the global origin (generally with a different orientation)

Transforms can be multiplied (chained): if F and G are transforms (F*G)(point) = (F(G((point))). If I is the identity transform, then F*I = F and I*F = F. So identity acts like a unit in this arithmetic. Any affine transform F has an inverse, so that F*inverseof(F) = I. Remember that F*G and G*F are generally different

Because frames are the same thing as transforms they have multiplication, identity (the global axes) and inverse frames. if f and g are two frames f*g is obtained by f.ToGlobalFrame(g); ( http://www.dynoinsight.com/Help/Interfa ... lobalFrame. I have skipped the difference between frame and its IFrame3 interface here). Inverse frame can be obtained with IFrame3.Invert(); http://www.dynoinsight.com/Help/Interfa ... spx#Invert

This is not math - this is common sense, right :)

nickz
Site Admin
Posts: 236
Joined: Fri Jul 26, 2013 3:58 am

Frames vs Matrices

Post by nickz »

For those used to handling matrices this describes how they are related to frames:
http://www.dynoinsight.com/Help/Geom/Fr ... trices.pdf
KC interface does not deal with matrices directly

Post Reply