... | ... | @@ -473,4 +473,78 @@ emit(imp) |
|
|
<img src="uploads/ad5c9dcb1ccff2a925dc5061f1e4cbd4/Example_3dtex.png" width="200">
|
|
|
</td>
|
|
|
</tr>
|
|
|
</table> |
|
|
\ No newline at end of file |
|
|
</table>
|
|
|
|
|
|
# Transformations
|
|
|
This section deals with linear transformations. IceSL offers functions to calculate matrices of transformations. To apply a transformation, a transformation matrix is multiplied with a shape. In order to combine more than one transformation, the result of successive multiplications of transformation matrices may also be multiplied with a shape. All applications of transformations should be consistent with a [http://mathworld.wolfram.com/Right-HandedCoordinateSystem.html right-handed coordinate system]. This means the '''rightmost transformation''' in a combination '''takes precedence'''.
|
|
|
|
|
|
```translate(dx,dy,dz)```
|
|
|
|
|
|
Returns a transformation matrix that translates a shape by ```dx,dy,dz``` units in the X-axis, Y-axis and Z-axis respectively.
|
|
|
* ```dx```: number of units to translate in the X-axis
|
|
|
* ```dy```: number of units to translate in the Y-axis
|
|
|
* ```dz```: number of units to translate in the Z-axis
|
|
|
|
|
|
```translate(v)```
|
|
|
|
|
|
Syntactic sugar for ```translate(v.x,v.y,v.z)```.
|
|
|
|
|
|
```rotate(angle,axis)```
|
|
|
|
|
|
Returns a transformation matrix that rotates a shape by ```angle``` degrees around the vector ```axis```.
|
|
|
* ```angle```: angle of rotation. In degrees
|
|
|
* ```axis```: a vector specifying the axis of rotation
|
|
|
|
|
|
```rotate(rx,ry,rz)```
|
|
|
|
|
|
```rotate(v)```
|
|
|
|
|
|
Syntactic sugar for ```rotate(rz,Z) * rotate(ry,Y) * rotate(rx,X)``` and ```rotate(v.z,Z) * rotate(v.y,Y) * rotate(v.x,X)``` respectively.
|
|
|
|
|
|
```scale(sx, sy, sz)```
|
|
|
Returns a transformation matrix that scales a shape by ```sx,sy,sz``` factors in the X-axis, Y-axis and Z-axis respectively.
|
|
|
* ```sx```: scale factor in the X-axis
|
|
|
* ```sy```: scale factor in the Y-axis
|
|
|
* ```sz```: scale factor in the Z-axis
|
|
|
|
|
|
```scale(s)```
|
|
|
|
|
|
```scale(v)```
|
|
|
|
|
|
Syntactic sugar for ```scale(s,s,s)``` and ```scale(v.x,v.y,v.z)``` respectively.
|
|
|
|
|
|
The above transformations have alternative names (mainly for compatibility purposes). The next table summarizes them:
|
|
|
|
|
|
| Transformation | Alternative |
|
|
|
| -------------- | ----------- |
|
|
|
| translate | translation |
|
|
|
| rotate | rotation |
|
|
|
| scale | scaling |
|
|
|
|
|
|
```mirror(normal)```
|
|
|
|
|
|
Returns a transformation matrix that mirrors a shape along the vector ```normal```.
|
|
|
* ```normal```: vector specifying the direction to mirror
|
|
|
|
|
|
<table>
|
|
|
<tr>
|
|
|
<td>
|
|
|
|
|
|
```lua
|
|
|
mesh = load_centered('fox.stl')
|
|
|
emit( mesh )
|
|
|
emit( translate(0,-100,0) * mirror(v(0,1,0)) * mesh )
|
|
|
|
|
|
```
|
|
|
|
|
|
</td>
|
|
|
<td>
|
|
|
<img src="uploads/011d458a111f9a042915c0437acc3de4/Example_mirror.png" width="200">
|
|
|
</td>
|
|
|
</tr>
|
|
|
</table>
|
|
|
|
|
|
```frame(v)```
|
|
|
|
|
|
Returns a transformation matrix that orients (i.e. aligns) a shape's [up vector](http://autodeskmaya.wikia.com/wiki/Up_Vector) to the direction ```v```.
|
|
|
* ```v```: a vector specifying the direction to orientate in the transformation. |