# Rotation and Scale

#### Rotation

The rotation takes place around the warped center point of the bitmap area.   
  
If an uneven number of reference points in x/y direction is specified, the warped center point coincides with the middle reference grid point and the coordinates of the rotation axis are present. If an even number of reference grid points is use, the coordinates of the warped center point are calculated.   
  
An initial RotationValue and the RotationLimit are specified through the configuration parameter structure:

<div class="contents" id="bkmrk-initial-rotation-val"><div class="contents"><div class="textblock">- Initial Rotation value is represented in **grad\*100**. This is the default rotation value that is applied to the warp image prior to rendering.
- RotationLimit represents the maximum rotation angle in grad that the warped image will be rotated to. Both positive and negative values are accepted.

</div></div></div>Warp image rotation at run-time is achieved through the adjustments supported by the Warping Library. Subsequent calls of warp matrix adjustments result in incremental rotation of the warp image with an incremental step equal to the specified delta value.

<div class="contents" id="bkmrk-if-the-initial-rotat"><div class="contents"><div class="textblock"><dl class="note"><dd><p class="callout info">If the initial RotationValue exceeds the specified RotationLimit a WarpResultErrorConfigInvalidValue will be thrown and the calculation of the warp matrix will be aborted.  
Scaling of the warp image occurs when the RotationLimit value is chosen such that at maximum rotation point, the image will extend beyond the illuminated area. More details related to image scaling is presented in the next section.</p>

</dd></dl></div></div></div>##### Example

<table border="1" id="bkmrk-rotationvalue%3A-500-%7C" style="border-collapse: collapse; width: 100%;"><colgroup><col style="width: 50%;"></col><col style="width: 50%;"></col></colgroup><tbody><tr><td>****RotationValue: 500 | Rotate 5° to right**** <div drawio-diagram="2105"><img src="https://doc316en.candera.eu/uploads/images/drawio/2023-02/drawing-7-1676962027.png" alt=""/></div>

</td><td>****RotationValue: -1000 | Rotate 10° to left**** <div drawio-diagram="2106"><img src="https://doc316en.candera.eu/uploads/images/drawio/2023-02/drawing-7-1676962039.png" alt=""/></div>

</td></tr><tr><td>****RotationValue: 3000 | Rotate 30° to right**** <div drawio-diagram="2107"><img src="https://doc316en.candera.eu/uploads/images/drawio/2023-02/drawing-7-1676962049.png" alt=""/></div>

</td><td>****RotationValue: -4500 | Rotate 45° to left**** <div drawio-diagram="2108"><img src="https://doc316en.candera.eu/uploads/images/drawio/2023-02/drawing-7-1676962063.png" alt=""/></div>

</td></tr></tbody></table>

<span style="color: rgb(34, 34, 34); font-size: 1.666em; font-weight: 400;">Scaling</span>

The warping library performs automatic rescaling of the resulting warping matrix whenever it overlaps or exceeds the boundaries of the illuminated area. It is possible to identify two cases in which rescaling will be done:

<div class="contents" id="bkmrk-if-the-configured-il"><div class="contents"><div class="textblock">- If the configured illuminated area is smaller than the bitmap area, the resulting warp matrix will be rescaled to the specified illuminated area.
- If the RotationLimit value is chosen such that at maxim rotation point, the warp image will extend beyond illuminated area boundaries.

</div></div></div>  
The ScaleMode parameter influences the behavior of scaling by modifying the internal scale factor:

<div class="contents" id="bkmrk-0---scale-factor-is-"><div class="contents"><div class="textblock">- 0 - scale factor is 1. Scaling occurs only if the image does not fit inside illuminated area. Rotating the warp image at run-time will rescale the resulted rotated image if it falls outside illuminated area boundaries.
- 1 - scale factor is calculated based on RotationLimit value. The warp image will be scaled down to the size that fits inside the illuminated area when a rotation equal to RotationLimit is applied.

</div></div></div>##### Example

<table border="1" id="bkmrk-no-scaling-occursbit" style="border-collapse: collapse; width: 100%;"><colgroup><col style="width: 50.0618%;"></col><col style="width: 50.0618%;"></col></colgroup><tbody><tr><td>**No Scaling occurs**  
BitmapArea: 408x190 | Illuminated Area: 480x190  
  
<div drawio-diagram="2094"><img src="https://doc316en.candera.eu/uploads/images/drawio/2023-02/drawing-7-1676961634.png" alt=""/></div>

</td><td>**Scaling occurs because bitmap area exceeds illuminated area**  
BitmapArea: 408x190 | Illuminated Area: 375x190  
<div drawio-diagram="2093"><img src="https://doc316en.candera.eu/uploads/images/drawio/2023-02/drawing-7-1676961611.png" alt=""/></div>

</td></tr><tr><td style="width: 410px;">**No Scaling occurs since warp image does not exceed illuminated area**  
BitmapArea: 408x190 | Illuminated Area: 480x190  
RotationValue: 0° | RotationLimit: 45°  
ScaleMode: 0  
<div class="image"><div drawio-diagram="2095"><img src="https://doc316en.candera.eu/uploads/images/drawio/2023-02/drawing-7-1676961696.png" alt=""/></div>

</div></td><td style="width: 412px;">**Scaling occurs because of specified RotationLimit and ScaleMode**  
BitmapArea: 408x190 | Illuminated Area: 480x190  
RotationValue: 0° | RotationLimit: 45°  
ScaleMode: 1  
<div class="image"><div drawio-diagram="2096"><img src="https://doc316en.candera.eu/uploads/images/drawio/2023-02/drawing-7-1676961721.png" alt=""/></div>

</div></td></tr><tr><td style="width: 410px;">**Scaling down during incremental rotation**  
BitmapArea: 408x190 | Illuminated Area: 480x190  
ScaleMode: 0  
<div class="image"><div drawio-diagram="2097"><img src="https://doc316en.candera.eu/uploads/images/drawio/2023-02/drawing-7-1676961751.png" alt=""/></div>

</div></td><td style="width: 412px;">**Scaling down during incremental rotation**  
BitmapArea: 408x190 | Illuminated Area: 480x190  
ScaleMode: 0  
<div class="image"><div drawio-diagram="2098"><img src="https://doc316en.candera.eu/uploads/images/drawio/2023-02/drawing-7-1676961773.png" alt=""/></div>

</div></td></tr><tr><td style="width: 410px;">**Scaling down during incremental rotation**  
BitmapArea: 408x190 | Illuminated Area: 480x190  
ScaleMode: 0  
<div class="image"><div drawio-diagram="2099"><img src="https://doc316en.candera.eu/uploads/images/drawio/2023-02/drawing-7-1676961780.png" alt=""/></div>

</div></td><td style="width: 412px;">**Scaling down during incremental rotation**  
BitmapArea: 408x190 | Illuminated Area: 480x190  
ScaleMode: 0  
<div class="image"><div drawio-diagram="2100"><img src="https://doc316en.candera.eu/uploads/images/drawio/2023-02/drawing-7-1676961789.png" alt=""/></div>

</div></td></tr><tr><td style="width: 410px;">**No scaling during incremental rotation**  
BitmapArea: 408x190 | Illuminated Area: 480x190  
ScaleMode: 1  
<div class="image"><div drawio-diagram="2101"><img src="https://doc316en.candera.eu/uploads/images/drawio/2023-02/drawing-7-1676961799.png" alt=""/></div>

</div></td><td style="width: 412px;">**No scaling during incremental rotation**  
BitmapArea: 408x190 | Illuminated Area: 480x190  
ScaleMode: 1  
<div class="image"><div drawio-diagram="2102"><img src="https://doc316en.candera.eu/uploads/images/drawio/2023-02/drawing-7-1676961810.png" alt=""/></div>

</div></td></tr><tr><td style="width: 410px;">**No scaling during incremental rotation**  
BitmapArea: 408x190 | Illuminated Area: 480x190  
ScaleMode: 1  
<div class="image"><div drawio-diagram="2103"><img src="https://doc316en.candera.eu/uploads/images/drawio/2023-02/drawing-7-1676961820.png" alt=""/></div>

</div></td><td style="width: 412px;">**No scaling during incremental rotation**  
BitmapArea: 408x190 | Illuminated Area: 480x190  
ScaleMode: 1  
<div class="image"><div drawio-diagram="2104"><img src="https://doc316en.candera.eu/uploads/images/drawio/2023-02/drawing-7-1676961828.png" alt=""/></div>

</div></td></tr></tbody></table>

<div class="textblock" id="bkmrk-"></div>---

<div class="textblock" id="bkmrk--1"></div><div class="textblock" id="bkmrk--2"></div><div class="textblock" id="bkmrk--4"></div>