... | ... | @@ -548,3 +548,55 @@ emit( translate(0,-100,0) * mirror(v(0,1,0)) * mesh ) |
|
|
|
|
|
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.
|
|
|
|
|
|
## Magnets
|
|
|
Magnets are volumeless shapes that help building objects by way of assembling parts. Think of a magnet as a fastener that eventually couples with other magnets from different shapes.
|
|
|
|
|
|
```magnet('name')```
|
|
|
|
|
|
* ```name```: magnet name
|
|
|
|
|
|
<table>
|
|
|
<tr>
|
|
|
<td>
|
|
|
|
|
|
```lua
|
|
|
case = union( cylinder(5,10), translate(0,0,10) * magnet('m1') )
|
|
|
head = union( cone(5,1,10), translate(0,0,0) * rotate(180,X) * magnet('m2') )
|
|
|
emit(case)
|
|
|
emit(translate(-20,0,0) * head)
|
|
|
```
|
|
|
|
|
|
</td>
|
|
|
<td>
|
|
|
<img src="uploads/afaab141ada4970939e6adc2f10d215f/Example_magnet.png" width="200">
|
|
|
</td>
|
|
|
</tr>
|
|
|
</table>
|
|
|
|
|
|
Magnets have orientation (the coupling orientation). To couple the magnets, the function ```snap``` returns a transformation matrix that assembles one shape's magnet (i.e. ```shape1```) to another (i.e. ```shape0```). The example below builds upon the previous one with the last two ```emit``` statements removed.
|
|
|
|
|
|
```snap(shape0, magnet0, shape1, magnet1)```
|
|
|
|
|
|
* ```shape0```: base shape
|
|
|
* ```magnet0```: the base shape's magnet name
|
|
|
* ```shape1```: shape to be coupled
|
|
|
* ```magnet1```: coupling shape's magnet name
|
|
|
|
|
|
<table>
|
|
|
<tr>
|
|
|
<td>
|
|
|
|
|
|
```lua
|
|
|
smatrix = snap(case, 'm1', head, 'm2')
|
|
|
emit(union(smatrix * head, case))
|
|
|
```
|
|
|
|
|
|
</td>
|
|
|
<td>
|
|
|
<img src="uploads/b55ddd1afdae5a1945bd3e26e7ca872e/Example_snap.png" width="200">
|
|
|
</td>
|
|
|
</tr>
|
|
|
</table>
|
|
|
|
|
|
Snap matrices are not commutative with respect to their connecting magnets. Notice in the previous example that multiplying ```smatrix``` with ```case``` does not yield the same result. |
|
|
\ No newline at end of file |