... | ... | @@ -26,16 +26,76 @@ Creating a shape in IceSL does not automatically render it in the final scene. I |
|
|
|
|
|
Brushes are an internalized concept of IceSL, there are a total of 128 indexes starting from 0. Their use is meant to group shapes under a set of parameters (usally printing parameters like _infill percentage_). In case of overlapping, the group with the lower index takes priority. The next code exemplifies the use of <code>emit</code>:
|
|
|
|
|
|
<table>
|
|
|
<tr>
|
|
|
<td>
|
|
|
|
|
|
```lua
|
|
|
b = box(10)
|
|
|
emit( b, 0 )
|
|
|
c = sphere(5)
|
|
|
emit( translate(0,0,5) * c, 1 )
|
|
|
```
|
|
|
|
|
|
</td>
|
|
|
<td>
|
|
|
<img src="uploads/3ca402a5562e1b73efad21373bd1adcc/Example_emit.png" width="200">
|
|
|
</td>
|
|
|
</tr>
|
|
|
</table>
|
|
|
|
|
|
Finally, a unit in the scripting language corresponds to 1mm in the printing world. IceSL always renders a scene with a virtual _printing bed_; a grid that represents the 3d printer bed (see image below). Each square of IceSL's printing bed corresponds to 1cm<sup>2</sup>.
|
|
|
|
|
|
Notice that, in order to have a visual aid on view orientation, axes are drown in the bottom-left corner. The red, green and blue lines correspond to the positive X, Y, and Z axes respectively.
|
|
|
|
|
|
<img src="uploads/b4e0712ea9a780482db48e616e486370/Printing_bed.png" width="200">
|
|
|
|
|
|
# Vectors, Matrices, Constants and Trigonometric Functions
|
|
|
|
|
|
## Vectors
|
|
|
Construction
|
|
|
* ```v(x,y,z)``` or ```v{x,y,z}```: creates the vector $`\begin{bmatrix} x \\ y \\ z
|
|
|
\end{bmatrix}`$.
|
|
|
* ```v(x,y)``` or ```v{x,y}```: creates the vector $`\begin{bmatrix} x \\ y \\ 0 \end{bmatrix}`$.
|
|
|
|
|
|
Members:
|
|
|
* ```v.x```: $`x`$ coordinate
|
|
|
* ```v.y```: $`y`$ coordinate
|
|
|
* ```v.z```: $z$ coordinate
|
|
|
|
|
|
Operations:
|
|
|
Let ```v``` and ```u``` be vectors and ```n``` a number.
|
|
|
* ```v + u```: vector addition.
|
|
|
* ```v - u```: vector subtraction.
|
|
|
* ```v * u```: vector component-wise multiplication.
|
|
|
* ```v / u```: vector component-wise division
|
|
|
* ```v * n``` or ```n * v```: vector scalar multiplication.
|
|
|
* ```v / n```: vector scalar division.
|
|
|
* ```-v```: syntatic sugar for ```-1 * v```.
|
|
|
* ```dot(v, u)```: dot product.
|
|
|
* ```cross(v, u)```: cross product.
|
|
|
* ```normalize(v)```: returns the unit vector $`\hat{v}`$.
|
|
|
* ```length(v)```: return the norm of ```v``` (i.e. $`||v||`$).
|
|
|
|
|
|
=== Matrices ===
|
|
|
Construction:
|
|
|
<syntaxhighlight lang="lua"> m( m11, m12, m13, m14,
|
|
|
m21, m22, m23, m24,
|
|
|
m31, m32, m33, m34,
|
|
|
m41, m42, m43, m44 ) </syntaxhighlight> or
|
|
|
<syntaxhighlight lang="lua"> m{ m11, m12, m13, m14,
|
|
|
m21, m22, m23, m24,
|
|
|
m31, m32, m33, m34,
|
|
|
m41, m42, m43, m44 } </syntaxhighlight>
|
|
|
Creates the matrix <math> \begin{bmatrix} m_{11} & m_{12} & m_{13} & m_{14} \\ m_{21} & m_{22} & m_{23} & m_{24} \\ m_{31} & m_{32} & m_{33} & m_{34}\\ m_{41} & m_{42} & m_{43} & m_{44}\end{bmatrix} </math>.
|
|
|
|
|
|
|
|
|
: Members:
|
|
|
* <code> m:at(c,r) </code>: element at column <code>c</code> and row <code>r</code>
|
|
|
|
|
|
|
|
|
: Operations: Let <code>M</code> and <code>Q</code> be matrices, let <code>v</code> be a vector and let <code>s</code> be a shape.
|
|
|
* <code> M * Q </code>: matrix multiplication. Returns a matrix
|
|
|
* <code> M * v </code>: matrix-vector multiplication. Returns a vector
|
|
|
* <code> M * s </code>: shape transformation. Returns the shape transformed by <code>M </code>.
|
|
|
* <code> inverse(M) </code>: matrix inversion. Returns the inverse of matrix <code>M</code>. |