Difference between revisions of "Object Scale"

From Flowcode Help
Jump to navigationJump to search
Line 5: Line 5:
 
Flowcode represents an objects [[Object position|position]] in terms of [[Object coordinates|coordinates]], '''scale''' and [[Object rotation|rotation]].
 
Flowcode represents an objects [[Object position|position]] in terms of [[Object coordinates|coordinates]], '''scale''' and [[Object rotation|rotation]].
  
Internally an objects scale is kept as a ''scale factor'' in the X, Y and Z axis. When accessing the [[API overview|SIM API]] this is the value that is altered, and relates to the diagonal of a transform matrix:
+
Internally an objects scale is kept as a ''scale factor'' in the X, Y and Z axis of the object. When accessing the [[API overview|SIM API]] this is the value that is altered, and relates to the diagonal of a transform matrix:
  
 
::[[File:scale_matrix.png]]
 
::[[File:scale_matrix.png]]
  
This is a multiplier applied to the object which alters the size of all its child objects. All API functions deal with this scale - this is mainly because the calculations involved in converting to other representations and back every time scale needs to be set would slow the programs down, but also because conversion to other representations can result in rounding errors and inaccuracies when combined with rotation.
+
This is a transformation applied to the object which alters the size of it, and when rendered on the panel of all its child objects.
  
=== Other representations ===
+
All API functions deal with this scale - this is mainly because the calculations involved in converting to other representations and back every time scale needs to be set would slow the programs down, but also because conversion to other representations can result in rounding errors and inaccuracies when combined with rotation.
Two additional values can be derived from the scale factor:
 
  
* The ''absolute size'' of an object can be thought of as the product of its scale multiplied by all its child scales.
 
: This can be thought of as the size of the bounding box of the object. This can be read through the API call [[API Panel.Position.GetBox|GetBox]].
 
  
: For leaf objects - those with no child objects of their own - this means the scale factor and the size equate to the same value, e.g. the scale factor and size of a sphere are the same thing.
+
== Scale vs Size==
 +
The scale factors of an object describes its dimensions without considering any child objects, and as such will not be affected if any other object on the panel changes its location, size or orientation.
  
 +
The ''absolute size'' of an object can be thought of as the product of its scale multiplied by all its child scales.
  
* The ''relative scale'' can be thought of as the scale factor divided by the objects original scale factor.
+
This can be thought of as the size of the bounding box of the object. This can be read through the API call [[API Panel.Position.GetBox|GetBox]].
: Relative scale is the scale of one object in proportion to another. If a house is 10 times bigger than a shed, then the relative scale is 10:1.
+
 
 +
Unlike scale, the ''size'' of an object depends on the children of that object. Though it may be more intuitive to think of size instead of scale, and therefore size is used in the properties pane, internally and in the exposed [[API Panel.Position|API]] Flowcode uses scale, as this is much quicker to calculate and easier to control.
  
: For objects that have no original scale - objects are dragged on to the panel with an arbitrary scale factor - relative scale does not make sense, as this would always be relative to some 'magic' number chosen out of the authors control.
 
  
  

Revision as of 22:02, 8 May 2013

This article refers to the representation of an object drawn on either the System panel or the Dashboard panel.

Flowcodes representation of scale

Flowcode represents an objects position in terms of coordinates, scale and rotation.

Internally an objects scale is kept as a scale factor in the X, Y and Z axis of the object. When accessing the SIM API this is the value that is altered, and relates to the diagonal of a transform matrix:

File:Scale matrix.png

This is a transformation applied to the object which alters the size of it, and when rendered on the panel of all its child objects.

All API functions deal with this scale - this is mainly because the calculations involved in converting to other representations and back every time scale needs to be set would slow the programs down, but also because conversion to other representations can result in rounding errors and inaccuracies when combined with rotation.


Scale vs Size

The scale factors of an object describes its dimensions without considering any child objects, and as such will not be affected if any other object on the panel changes its location, size or orientation.

The absolute size of an object can be thought of as the product of its scale multiplied by all its child scales.

This can be thought of as the size of the bounding box of the object. This can be read through the API call GetBox.

Unlike scale, the size of an object depends on the children of that object. Though it may be more intuitive to think of size instead of scale, and therefore size is used in the properties pane, internally and in the exposed API Flowcode uses scale, as this is much quicker to calculate and easier to control.


Local and world space

Main article: Local and world space

When working with objects in the flowchart, local coordinates are always preferred over world coordinates. This is so that scaling an objects parent does not affect the 'coordinate space' of the program - moving to coordinates (1, 2, 3) will always move to the same point in the component, despite the users scaling of the component, which is out of the component authors control.

It is very difficult to program an object to behave as expected in all circumstances using the world position.

To calculate the world size from an objects local scale, this must be multiplied by the scales of all the objects children and parents in the Component tree.