### with-rotation

Arguments
`[rotation & body]`
Docstring

Performs body with rotation, restores current transformation on exit. Accepts a vector `[angle]` or `[angle x y z]`.

When 4 arguments provides it produces a rotation of angle degrees around the vector x y z. Check examples to better understand. This rotation follows the right-hand rule, so if the vector x y z points toward the user, the rotation will be counterclockwise.

Example:

``````  (with-rotation [angle]
(vertex 1 2))
``````
Works only inside sketch functions?
Yes
Original Processing method
None.
Original p5js method
None.
Example
clojure specific
• ```(q/background 255)
(q/stroke 0)
; set camera and draw XYZ axis
(q/camera 200 200 200 0 0 0 0 0 -1)
(q/line 0 0 0 100 0 0)
(q/line 0 0 0 0 100 0)
(q/line 0 0 0 0 0 100)
(q/fill 0)
(q/text "x" 100 0 0)
(q/text "y" 0 100 0)
(q/text "z" 0 0 100)
(q/no-fill)
(q/stroke 255 0 0)
; draw box without rotation
(q/box 50)
; draw box with 45° rotation around
; [1, 1, 0] vector.
(q/with-translation [100 0 0]
(q/with-rotation [(/ q/PI 4) 1 1 0]
(q/box 50)))```
• ```(q/background 255)
(q/stroke 0)
; set camera and draw XYZ axis
(q/camera 200 200 200 0 0 0 0 0 -1)
(q/line 0 0 0 100 0 0)
(q/line 0 0 0 0 100 0)
(q/line 0 0 0 0 0 100)
(q/fill 0)
(q/text "x" 100 0 0)
(q/text "y" 0 100 0)
(q/text "z" 0 0 100)
(q/no-fill)
(q/stroke 255 0 0)
; draw box without rotation
(q/box 50)
; draw box with 45° rotation around
; [1, 0, 0] vector.
(q/with-translation [100 0 0]
(q/with-rotation [(/ q/PI 4) 1 0 0]
(q/box 50)))```
• ```(q/background 255)
; draw rectangle without rotation
(q/with-translation [50 50]
(q/rect 0 0 100 200))
; draw rectangle with 45° rotation
(q/with-translation [300 50]
(q/with-rotation [(/ q/PI 4)]
(q/rect 0 0 100 200)))```
clojurescript specific
• ```(q/background 255)
(q/stroke 0)
; set camera and draw XYZ axis
(q/camera 200 200 200 0 0 0 0 0 -1)
(q/line 0 0 0 100 0 0)
(q/line 0 0 0 0 100 0)
(q/line 0 0 0 0 0 100)
(q/fill 0)
(q/no-fill)
(q/stroke 255 0 0)
; draw box without rotation
(q/box 50)
; draw box with 45° rotation around
; [1, 1, 0] vector.
(q/with-translation [100 0 0]
(q/with-rotation [(/ q/PI 4) 1 1 0]
(q/box 50)))```
• ```(q/background 255)
(q/stroke 0)
; set camera and draw XYZ axis
(q/camera 200 200 200 0 0 0 0 0 -1)
(q/line 0 0 0 100 0 0)
(q/line 0 0 0 0 100 0)
(q/line 0 0 0 0 0 100)
(q/fill 0)
(q/no-fill)
(q/stroke 255 0 0)
; draw box without rotation
(q/box 50)
; draw box with 45° rotation around
; [1, 0, 0] vector.
(q/with-translation [100 0 0]
(q/with-rotation [(/ q/PI 4) 1 0 0]
(q/box 50)))```
• ```(q/background 255)
; draw rectangle without rotation
(q/with-translation [50 50]
(q/rect 0 0 100 200))
; draw rectangle with 45° rotation
(q/with-translation [300 50]
(q/with-rotation [(/ q/PI 4)]
(q/rect 0 0 100 200)))```

### with-translation

Arguments
`[translation-vector & body]`
Docstring

Performs body with translation, restores current transformation on exit.

Works only inside sketch functions?
Yes
Original Processing method
None.
Original p5js method
None.
Example
clojure specific
• ```(q/background 255)
(q/stroke 0)
; set camera and draw XYZ axis
(q/camera 200 200 200 0 0 0 0 0 -1)
(q/line 0 0 0 100 0 0)
(q/line 0 0 0 0 100 0)
(q/line 0 0 0 0 0 100)
(q/fill 0)
(q/text "x" 100 0 0)
(q/text "y" 0 100 0)
(q/text "z" 0 0 100)
(q/no-fill)
(q/stroke 255 0 0)
; draw 3 boxes using with-translation
(q/box 50)
(q/with-translation [100 0 0]
(q/box 50))
(q/with-translation [100 0 100]
(q/box 50))```
• ```(q/background 255)
(q/rect 0 0 50 50)
(q/with-translation [150 0]
(q/rect 0 0 50 50))
(q/with-translation [150 150]
(q/rect 0 0 50 50))```
clojurescript specific
• ```(q/background 255)
(q/stroke 0)
; set camera and draw XYZ axis
(q/camera 200 200 200 0 0 0 0 0 -1)
(q/line 0 0 0 100 0 0)
(q/line 0 0 0 0 100 0)
(q/line 0 0 0 0 0 100)
(q/fill 0)
(q/no-fill)
(q/stroke 255 0 0)
; draw 3 boxes using with-translation
(q/box 50)
(q/with-translation [100 0 0]
(q/box 50))
(q/with-translation [100 0 100]
(q/box 50))```
• ```(q/background 255)
(q/rect 0 0 50 50)
(q/with-translation [150 0]
(q/rect 0 0 50 50))
(q/with-translation [150 150]
(q/rect 0 0 50 50))```