High level fluxus commands written in Scheme.

**Returns** void

Removes the parent for the current primitive, and fixes up the transform so the primitive doesn't move. Use (parent 1) to avoid this fix up.

**Example**

; builds and animates a random heirarchical structure, ; click on the objects to detach them from their parents (define (build-heir depth) (with-state (let ((p (with-state (translate (vector 2 0 0)) (scale 0.9) (build-cube)))) (when (> depth 0) (parent p) (for ((i (in-range 0 5))) (when (zero? (random 3)) (rotate (vector 0 0 (* 45 (crndf)))) (build-heir (- depth 1)))))))) (define (animate-heir children depth) (for-each (lambda (child) (with-primitive child (rotate (vector 0 0 (sin (+ depth (time))))) (animate-heir (get-children) (+ depth 1)))) children)) (define (animate) (animate-heir (get-children) 0) (when (mouse-button 1) (let ((s (select (mouse-x) (mouse-y) 2))) (when (not (zero? s)) (with-primitive s (detach-parent)))))) (clear) (build-heir 5) (every-frame (animate))

**Returns** result of last expression

Encapsulates local state changes, and removes the need for push and pop.

**Example**

; state hierachy, by nesting with-state: (with-state (hint-vertcols) (colour (vector 0 0 1)) (with-state (translate (vector 1 0 0)) (build-sphere 10 10)) (build-torus 1 2 30 30)) ; making primitives: (define my-torus (with-state (hint-vertcols) (colour (vector 0 0 1)) (build-torus 1 2 30 30)))

**Returns** result of last expression

Encapsulates primitive state changes, and removes the need for grab and ungrab.

**Example**

(define my-torus (with-state (colour (vector 0 0 1)) (build-torus 1 2 30 30))) ; change the torus colour: (with-primitive my-torus (colour (vector 0 1 0)))

**Returns** result of last expression

Allows you to render into a pixel primitive.

**Example**

**Returns** result of last expression

Allows you to work with the specified FFGL plugin.

**Example**

(clear) (define plugin (ffgl-load "FFGLTile.dylib" 256 256)) (with-ffgl plugin (for ([i (ffgl-get-info)]) (printf "~a~n" i)))

**Returns** void

A high level control structure for simplifying passing over pdata arrays for primitive deformation. Should be easier and less error prone than looping manually. Writes to the first pdata array.

**Example**

(clear) (define my-torus (build-torus 1 2 30 30)) (with-primitive my-torus (pdata-map! (lambda (position) (vadd position (vector (flxrnd) 0 0))) ; jitter the vertex in x "p")) ; read/write the position pdata array (with-primitive my-torus (pdata-map! (lambda (position normal) (vadd position normal)) ; add the normal to the position (expand the object) "p" "n")) ; read/write the position pdata array, read the normals array

**Returns** void

A high level control structure for simplifying passing over pdata arrays for primitive deformation. Same as pdata-map! except pdata-index-map! supplies the index of the current pdata element as the first argument to 'procedure'.

**Example**

(clear) (define my-torus (build-torus 1 2 30 30)) (with-primitive my-torus (pdata-index-map! (lambda (index position) (vadd position (vector (gh index) 0 0))) ; jitter the vertex in x "p")) ; read/write the position pdata array

**Returns** result of folding procedure over pdata array

A high level control structure for doing calculations on pdata arrays. Runs the procedure over each pdata element accumulating the result. Should be easier and less error prone than looping manually.

**Example**

(define my-torus (build-torus 1 2 30 30)) ; find the centre of the primitive by averaging ; the points position's together (let ((centre (with-primitive my-torus (vdiv (pdata-fold vadd (vector 0 0 0) "p") (pdata-size))))) (display centre)(newline))

**Returns** result of folding procedure over pdata array

Same as pdata-fold except it passes the index of the current pdata element as the first parameter of 'procedure'.

**Example**

(define my-torus (build-torus 1 2 30 30)) ; can't think of a good example for this yet... (let ((something (with-primitive my-torus (vdiv (pdata-index-fold (lambda (index position ret) (vadd ret (vmul position index))) (vector 0 0 0) "p") (pdata-size))))) (display something)(newline))

**Returns** result-vector

Adds vectors together

**Example**

(vadd (vector 1 2 3) (vector 5 2 7)) (vadd (vector 1 2 3 4) (vector 7 1 1 4)) (vadd (vector 1 2) (vector 3 3) (vector 5 5))

**Returns** result-vector

Subtracts a vector or multiple vectors from each other

**Example**

(vsub (vector 1 2 3) (vector 5 2 7)) (vsub (vector 1 2 3 4) (vector 7 1 1 4)) (vsub (vector 1 2) (vector 3 3) (vector 5 5))

**Returns** result-vector

Multiplies a vector by a number

**Example**

(vmul (vector 1 2 3) 2) (vmul (vector 1 2 3 4 5) 3)

**Returns** result-vector

Divides a vector by a number

**Example**

(vdiv (vector 1 2 3) 2) (vdiv (vector 1 2 3 4 5) 3)

**Returns** void

Loads a collada scene file and returns a scene description list. Files need to contain triangulated model data - this is usually an option on the export. Note: this is slow for heavy models

**Example**

;(collada-import "test.dae")

**Returns** void

Removes the parent for the current primitive, and fixes up the transform so the primitive doesn't move. Use (parent 1) to avoid this fix up.

**Example**

; builds and animates a random heirarchical structure, ; click on the objects to detach them from their parents (define (build-heir depth) (with-state (let ((p (with-state (translate (vector 2 0 0)) (scale 0.9) (build-cube)))) (when (> depth 0) (parent p) (for ((i (in-range 0 5))) (when (zero? (random 3)) (rotate (vector 0 0 (* 45 (crndf)))) (build-heir (- depth 1)))))))) (define (animate-heir children depth) (for-each (lambda (child) (with-primitive child (rotate (vector 0 0 (sin (+ depth (time))))) (animate-heir (get-children) (+ depth 1)))) children)) (define (animate) (animate-heir (get-children) 0) (when (mouse-button 1) (let ((s (select (mouse-x) (mouse-y) 2))) (when (not (zero? s)) (with-primitive s (detach-parent)))))) (clear) (build-heir 5) (every-frame (animate))

**Returns** result of last expression

Encapsulates local state changes, and removes the need for push and pop.

**Example**

; state hierachy, by nesting with-state: (with-state (hint-vertcols) (colour (vector 0 0 1)) (with-state (translate (vector 1 0 0)) (build-sphere 10 10)) (build-torus 1 2 30 30)) ; making primitives: (define my-torus (with-state (hint-vertcols) (colour (vector 0 0 1)) (build-torus 1 2 30 30)))

**Returns** result of last expression

Encapsulates primitive state changes, and removes the need for grab and ungrab.

**Example**

(define my-torus (with-state (colour (vector 0 0 1)) (build-torus 1 2 30 30))) ; change the torus colour: (with-primitive my-torus (colour (vector 0 1 0)))

**Returns** result of last expression

Allows you to render into a pixel primitive.

**Example**

**Returns** result of last expression

Allows you to work with the specified FFGL plugin.

**Example**

(clear) (define plugin (ffgl-load "FFGLTile.dylib" 256 256)) (with-ffgl plugin (for ([i (ffgl-get-info)]) (printf "~a~n" i)))

**Returns** void

A high level control structure for simplifying passing over pdata arrays for primitive deformation. Should be easier and less error prone than looping manually. Writes to the first pdata array.

**Example**

(clear) (define my-torus (build-torus 1 2 30 30)) (with-primitive my-torus (pdata-map! (lambda (position) (vadd position (vector (flxrnd) 0 0))) ; jitter the vertex in x "p")) ; read/write the position pdata array (with-primitive my-torus (pdata-map! (lambda (position normal) (vadd position normal)) ; add the normal to the position (expand the object) "p" "n")) ; read/write the position pdata array, read the normals array

**Returns** void

A high level control structure for simplifying passing over pdata arrays for primitive deformation. Same as pdata-map! except pdata-index-map! supplies the index of the current pdata element as the first argument to 'procedure'.

**Example**

(clear) (define my-torus (build-torus 1 2 30 30)) (with-primitive my-torus (pdata-index-map! (lambda (index position) (vadd position (vector (gh index) 0 0))) ; jitter the vertex in x "p")) ; read/write the position pdata array

**Returns** result of folding procedure over pdata array

A high level control structure for doing calculations on pdata arrays. Runs the procedure over each pdata element accumulating the result. Should be easier and less error prone than looping manually.

**Example**

(define my-torus (build-torus 1 2 30 30)) ; find the centre of the primitive by averaging ; the points position's together (let ((centre (with-primitive my-torus (vdiv (pdata-fold vadd (vector 0 0 0) "p") (pdata-size))))) (display centre)(newline))

**Returns** result of folding procedure over pdata array

Same as pdata-fold except it passes the index of the current pdata element as the first parameter of 'procedure'.

**Example**

(define my-torus (build-torus 1 2 30 30)) ; can't think of a good example for this yet... (let ((something (with-primitive my-torus (vdiv (pdata-index-fold (lambda (index position ret) (vadd ret (vmul position index))) (vector 0 0 0) "p") (pdata-size))))) (display something)(newline))

**Returns** result-vector

Adds vectors together

**Example**

(vadd (vector 1 2 3) (vector 5 2 7)) (vadd (vector 1 2 3 4) (vector 7 1 1 4)) (vadd (vector 1 2) (vector 3 3) (vector 5 5))

**Returns** result-vector

Subtracts a vector or multiple vectors from each other

**Example**

(vsub (vector 1 2 3) (vector 5 2 7)) (vsub (vector 1 2 3 4) (vector 7 1 1 4)) (vsub (vector 1 2) (vector 3 3) (vector 5 5))

**Returns** result-vector

Multiplies a vector by a number

**Example**

(vmul (vector 1 2 3) 2) (vmul (vector 1 2 3 4 5) 3)

**Returns** result-vector

Divides a vector by a number

**Example**

(vdiv (vector 1 2 3) 2) (vdiv (vector 1 2 3 4 5) 3)

**Returns** void

Loads a collada scene file and returns a scene description list. Files need to contain triangulated model data - this is usually an option on the export. Note: this is slow for heavy models

**Example**

;(collada-import "test.dae")

**Returns** void

Linearly interpolates the two vectors together by t

**Example**

; mix red and blue together (colour (vmix (vector 1 0 0) (vector 0 0 1) 0.5))

**Returns** void

Clamp the vector so the elements are all between 0 and 1

**Example**

; make a valid colour from any old vector (colour (vclamp (vector 2 400 -123)))

**Returns** void

Normalise the vector so all the elements are between 0 and 1 but maintain the same ratio between them.

**Example**

; make a valid colour from any old vector (colour (vsquash (vector 2 400 -123)))

**Returns** void

Draws a circle into a pixels primitive

**Example**

(with-primitive (build-pixels 100 100) (pixels-circle (vector 50 50 0) 30 (vector 1 0 0 1)) (pixels-upload))

**Returns** void

Draws a blended circle into a pixels primitive

**Example**

(with-primitive (build-pixels 100 100) (pixels-blend-circle (vector 50 50 0) 30 (vector 1 0 0 1)) (pixels-upload))

**Returns** void

Lightens a circular area of a pixels primitive

**Example**

(with-primitive (build-pixels 100 100) (pixels-dodge (vector 50 50 0) 30 (vector 1 0 0 1)) (pixels-upload))

**Returns** void

Darkens a circular area of a pixels primitive

**Example**

(with-primitive (build-pixels 100 100) (pixels-burn (vector 50 50 0) 30 (vector 1 0 0 1)) (pixels-upload))

**Returns** void

Sets all of the pixels to the supplied colour

**Example**

(with-primitive (build-pixels 100 100) (pixels-clear (vector 1 0 0)) (pixels-upload))

**Returns** index-number

Returns the pdata index for the given texture coordinate

**Example**

(with-primitive (build-pixels 10 10) (display (pixels-index (vector 0.5 0.5 0)))(newline))

**Returns** position-vector

Returns the texture coordinate for the given pdata index

**Example**

(with-primitive (build-pixels 10 10) (display (pixels-texcoord 25))(newline))

**Returns** void

Returns a symbol representing the type of the current polygon primitive. primitive.

**Example**

(define p (build-polygons 3 'triangle-strip)) (with-primitive p (display (poly-type))(newline))

**Returns** list of pdata values

Calls proc with the indices for each face in a polygon primitive

**Example**

**Returns** list of pdata values

Calls proc with the pdata for each triangle in a face - assumes all faces are convex.

**Example**

**Returns** primitive-id

A new poly primitive of type triangle-list representing the supplied poly primitive.

**Example**

(define triangulated-plane (poly-build-triangulate (build-seg-plane 20 20)))

**Returns** void

Calls proc with the triangle indices and a random barycentric coord.

**Example**

**Returns** primitive-id

Returns an indexed polygon primitive made by extruding the profile along path and scaling using values in width. The path and width lists need to be the same size. tex-vscale allows you to scale the texture coordinates along the length of the extrusion. An up vector is needed for aiming the profile along the path.

**Example**

(clear) (build-extrusion (build-circle-points 20 0.3) (list (vector 0 0 0) (vector 0 1 2) (vector 0 -1 4) (vector 0 0 6)) (list 0 1 1 0) 1 (vector 0 1 0))

**Returns** primitive-id

Builds a primitive ready to be used with partial-extrusion. Use this is for animating growth along extrusions.

**Example**

(clear) (define profile (build-circle-points 10 0.3)) (define path (build-list 20 (lambda (i) (vector (crndf) (crndf) i)))) (define width (build-list 20 (lambda (_) 1))) (hint-wire) (define p (build-partial-extrusion profile path 1)) (every-frame (with-primitive p (partial-extrude (* (length path) 0.5 (+ (sin (time)) 1)) profile path width (vector 0 1 0) 0.1)))

**Returns** primitive-id

Animates growth along extrusions. t is a value between 0 and the length of the path, and controls how far along the extrusion to calculate. Grow value is a scale to control how much the profile is scaled to change it's width as it grows.

**Example**

(clear) (define profile (build-circle-points 10 0.3)) (define path (build-list 20 (lambda (i) (vector (crndf) (crndf) i)))) (define width (build-list 20 (lambda (_) 1))) (hint-wire) (define p (build-partial-extrusion profile path 100)) (every-frame (with-primitive p (partial-extrude (* (length path) 0.5 (+ (sin (time)) 1)) profile path width (vector 0 1 0) 0.1)))

**Returns** primitive-id

Builds a disk shaped poly primitive

**Example**

(clear) (build-disk 10)

**Returns** number

Returns a random number in the range 0->1

**Example**

(display (rndf))(newline)

**Returns** number

Returns a random number in the range -1->1 (centred on zero)

**Example**

(display (crndf))(newline)

**Returns** vector

Returns a random 3 element vector with each element in the range 0->1. If you visualise a lot of these as points, they will fill the unit cube (see the example).

**Example**

(clear) (hint-none) (hint-points) (point-width 4) (define p (build-particles 1000)) (show-axis 1) (with-primitive p (pdata-map! (lambda (p) (vector 1 1 1)) "c") (pdata-map! (lambda (p) (rndvec)) "p"))

**Returns** vector

Returns a random 3 element vector with each element in the range -1->1. If you visualise a lot of these as points, they will fill a cube centred on the origin (see the example).

**Example**

(clear) (hint-none) (hint-points) (point-width 4) (define p (build-particles 1000)) (show-axis 1) (with-primitive p (pdata-map! (lambda (p) (vector 1 1 1)) "c") (pdata-map! (lambda (p) (crndvec)) "p"))

**Returns** vector

Returns a random 3 element vector. If you visualise a lot of these as points, they will fill a sphere centred on the origin (see the example).

**Example**

(clear) (hint-none) (hint-points) (point-width 4) (define p (build-particles 1000)) (show-axis 1) (with-primitive p (pdata-map! (lambda (p) (vector 1 1 1)) "c") (pdata-map! (lambda (p) (srndvec)) "p"))

**Returns** vector

Returns a random 3 element vector. If you visualise a lot of these as points, they will cover the surface of a sphere centred on the origin (see the example). The name stands for "hollow sphere".

**Example**

(clear) (hint-none) (hint-points) (point-width 4) (define p (build-particles 1000)) (show-axis 1) (with-primitive p (pdata-map! (lambda (p) (vector 1 1 1)) "c") (pdata-map! (lambda (p) (hsrndvec)) "p"))

**Returns** number

Returns a gaussian random number in the range centred on zero, with a variance of 1

**Example**

(display (grndf))(newline)

**Returns** vector

Returns a gaussian random 3 element vector. If you visualise a lot of these as points, you will see a normal distribution centred on the origin. (see the example).

**Example**

(clear) (hint-none) (hint-points) (point-width 4) (define p (build-particles 1000)) (show-axis 1) (with-primitive p (pdata-map! (lambda (p) (vector 1 1 1)) "c") (pdata-map! (lambda (p) (grndvec)) "p"))

**Returns** vector

Returns a vector representing a uniformly distributed triangular barycentric coordinate (wip - doesn't seem to be very uniform to me...)

**Example**

(rndbary)

**Returns** vector

Returns a vector representing a random point on a hemisphere, defined by normal.

**Example**

(clear) (hint-none) (hint-points) (point-width 4) (define p (build-particles 1000)) (show-axis 1) (with-primitive p (pdata-map! (lambda (p) (vector 1 1 1)) "c") (pdata-map! (lambda (p) (rndhemi (vector 0 1 0))) "p"))

**Returns** vector

Returns a vector representing a random point on a hollow hemisphere, defined by normal.

**Example**

(clear) (hint-none) (hint-points) (point-width 4) (define p (build-particles 1000)) (show-axis 1) (with-primitive p (pdata-map! (lambda (p) (vector 1 1 1)) "c") (pdata-map! (lambda (p) (hrndhemi (vector 0 1 0))) "p"))

**Returns** primitive-id

Returns a list of vectors describing a circle. Useful for generating circles for the extrusion generator.

**Example**

(clear) (build-extrusion (build-circle-points 20 0.3) (list (vector 0 0 0) (vector 0 1 2) (vector 0 -1 4) (vector 0 0 6)) (list 0 1 1 0) 1 (vector 0 1 0))

**Returns** void

Calls proc with the triangle indices and a random barycentric coord?

**Example**

**Returns** void

Expand object along the normals

**Example**

(with-primitive (build-cube) (expand 5))

**Returns** void

Bakes ambient occlusion textures. See ambient-occlusion.scm for more info.

**Example**

**Returns** vector

Linearly interpolates the two vectors together by t

**Example**

; mix red and blue together (colour (vmix (vector 1 0 0) (vector 0 0 1) 0.5))

**Returns** vector

Clamp the vector so the elements are all between 0 and 1

**Example**

; make a valid colour from any old vector (colour (vclamp (vector 2 400 -123)))

**Returns** vector

Normalise the vector so all the elements are between 0 and 1 but maintain the same ratio between them.

**Example**

; make a valid colour from any old vector (colour (vsquash (vector 2 400 -123)))

**Returns** number

Linearly interpolates the two numbers together by t

**Example**

(lerp 1 2 .3)

**Returns** vector

Linearly interpolates the two vectors together by t

**Example**

; mix red and blue together (colour (vlerp (vector 1 0 0) (vector 0 0 1) 0.3))

**Returns** vector

Linearly interpolates the two matrices together by t

**Example**

(mlerp (mtranslate (vector 1 0 0)) (mtranslate (vector 0 1 0)) .3)

**Returns** list of 2 vectors (start position, end position)

Gets a line representing a segment of the projection of the x,y points into 3D space. at depth z from the camera

**Example**

**Returns** vector

Gets the world position of a point in 3D world space.

**Example**

**Returns** vector

Gets the mouse position in 3D world space.

**Example**

**Returns** vector

Gets the mouse position in 3D world space at depth z.

**Example**

**Returns** float

Converts a 2D vector into an angle, with some dodgy Dave maths

**Example**

**Returns** void

Draws a circle into a pixels primitive

**Example**

(with-primitive (build-pixels 100 100) (pixels-circle (vector 50 50 0) 30 (vector 1 0 0 1)) (pixels-upload))

**Returns** void

Draws a blended circle into a pixels primitive

**Example**

(with-primitive (build-pixels 100 100) (pixels-blend-circle (vector 50 50 0) 30 (vector 1 0 0 1)) (pixels-upload))

**Returns** void

Lightens a circular area of a pixels primitive

**Example**

(with-primitive (build-pixels 100 100) (pixels-dodge (vector 50 50 0) 30 (vector 1 0 0 1)) (pixels-upload))

**Returns** void

Darkens a circular area of a pixels primitive

**Example**

(with-primitive (build-pixels 100 100) (pixels-burn (vector 50 50 0) 30 (vector 1 0 0 1)) (pixels-upload))

**Returns** void

Sets all of the pixels to the supplied colour

**Example**

(with-primitive (build-pixels 100 100) (pixels-clear (vector 1 0 0)) (pixels-upload))

**Returns** index-number

Returns the pdata index for the given texture coordinate

**Example**

(with-primitive (build-pixels 10 10) (display (pixels-index (vector 0.5 0.5 0)))(newline))

**Returns** position-vector

Returns the texture coordinate for the given pdata index

**Example**

(with-primitive (build-pixels 10 10) (display (pixels-texcoord 25))(newline))

**Returns** void

Returns a symbol representing the type of the current polygon primitive. primitive.

**Example**

(define p (build-polygons 3 'triangle-strip)) (with-primitive p (display (poly-type))(newline))

**Returns** list of pdata values

Calls proc with the indices for each face in a polygon primitive

**Example**

**Returns** list of pdata values

Calls proc with the pdata for each triangle in a face - assumes all faces are convex.

**Example**

**Returns** primitive-id

A new poly primitive of type triangle-list representing the supplied poly primitive.

**Example**

(define triangulated-plane (poly-build-triangulate (build-seg-plane 20 20)))

**Returns** void

Calls proc with the triangle indices and a random barycentric coord.

**Example**

**Returns** primitive-id

Returns an indexed polygon primitive made by extruding the profile along path and scaling using values in width. The path and width lists need to be the same size. tex-vscale allows you to scale the texture coordinates along the length of the extrusion. An up vector is needed for aiming the profile along the path.

**Example**

(clear) (build-extrusion (build-circle-points 20 0.3) (list (vector 0 0 0) (vector 0 1 2) (vector 0 -1 4) (vector 0 0 6)) (list 0 1 1 0) 1 (vector 0 1 0))

**Returns** primitive-id

Builds a primitive ready to be used with partial-extrusion. Use this is for animating growth along extrusions.

**Example**

(clear) (define profile (build-circle-points 10 0.3)) (define path (build-list 20 (lambda (i) (vector (crndf) (crndf) i)))) (define width (build-list 20 (lambda (_) 1))) (hint-wire) (define p (build-partial-extrusion profile path 1)) (every-frame (with-primitive p (partial-extrude (* (length path) 0.5 (+ (sin (time)) 1)) profile path width (vector 0 1 0) 0.1)))

**Returns** primitive-id

Animates growth along extrusions. t is a value between 0 and the length of the path, and controls how far along the extrusion to calculate. Grow value is a scale to control how much the profile is scaled to change it's width as it grows.

**Example**

(clear) (define profile (build-circle-points 10 0.3)) (define path (build-list 20 (lambda (i) (vector (crndf) (crndf) i)))) (define width (build-list 20 (lambda (_) 1))) (hint-wire) (define p (build-partial-extrusion profile path 100)) (every-frame (with-primitive p (partial-extrude (* (length path) 0.5 (+ (sin (time)) 1)) profile path width (vector 0 1 0) 0.1)))

**Returns** primitive-id

Builds a disk shaped poly primitive

**Example**

(clear) (build-disk 10)

**Returns** number

Returns a random number in the range 0->1

**Example**

(display (rndf))(newline)

**Returns** number

Returns a random number in the range -1->1 (centred on zero)

**Example**

(display (crndf))(newline)

**Returns** vector

Returns a random 3 element vector with each element in the range 0->1. If you visualise a lot of these as points, they will fill the unit cube (see the example).

**Example**

(clear) (hint-none) (hint-points) (point-width 4) (define p (build-particles 1000)) (show-axis 1) (with-primitive p (pdata-map! (lambda (p) (vector 1 1 1)) "c") (pdata-map! (lambda (p) (rndvec)) "p"))

**Returns** vector

Returns a random 3 element vector with each element in the range -1->1. If you visualise a lot of these as points, they will fill a cube centred on the origin (see the example).

**Example**

(clear) (hint-none) (hint-points) (point-width 4) (define p (build-particles 1000)) (show-axis 1) (with-primitive p (pdata-map! (lambda (p) (vector 1 1 1)) "c") (pdata-map! (lambda (p) (crndvec)) "p"))

**Returns** vector

Returns a random 3 element vector. If you visualise a lot of these as points, they will fill a sphere centred on the origin (see the example).

**Example**

(clear) (hint-none) (hint-points) (point-width 4) (define p (build-particles 1000)) (show-axis 1) (with-primitive p (pdata-map! (lambda (p) (vector 1 1 1)) "c") (pdata-map! (lambda (p) (srndvec)) "p"))

**Returns** vector

Returns a random 3 element vector. If you visualise a lot of these as points, they will cover the surface of a sphere centred on the origin (see the example). The name stands for "hollow sphere".

**Example**

(clear) (hint-none) (hint-points) (point-width 4) (define p (build-particles 1000)) (show-axis 1) (with-primitive p (pdata-map! (lambda (p) (vector 1 1 1)) "c") (pdata-map! (lambda (p) (hsrndvec)) "p"))

**Returns** number

Returns a gaussian random number in the range centred on zero, with a variance of 1

**Example**

(display (grndf))(newline)

**Returns** vector

Returns a gaussian random 3 element vector. If you visualise a lot of these as points, you will see a normal distribution centred on the origin. (see the example).

**Example**

(clear) (hint-none) (hint-points) (point-width 4) (define p (build-particles 1000)) (show-axis 1) (with-primitive p (pdata-map! (lambda (p) (vector 1 1 1)) "c") (pdata-map! (lambda (p) (grndvec)) "p"))

**Returns** vector

Returns a vector representing a uniformly distributed triangular barycentric coordinate (wip - doesn't seem to be very uniform to me...)

**Example**

(rndbary)

**Returns** vector

Returns a vector representing a random point on a hemisphere, defined by normal.

**Example**

(clear) (hint-none) (hint-points) (point-width 4) (define p (build-particles 1000)) (show-axis 1) (with-primitive p (pdata-map! (lambda (p) (vector 1 1 1)) "c") (pdata-map! (lambda (p) (rndhemi (vector 0 1 0))) "p"))

**Returns** vector

Returns a vector representing a random point on a hollow hemisphere, defined by normal.

**Example**

(clear) (hint-none) (hint-points) (point-width 4) (define p (build-particles 1000)) (show-axis 1) (with-primitive p (pdata-map! (lambda (p) (vector 1 1 1)) "c") (pdata-map! (lambda (p) (hrndhemi (vector 0 1 0))) "p"))

**Returns** primitive-id

Returns a list of vectors describing a circle. Useful for generating circles for the extrusion generator.

**Example**

**Returns** void

Calls proc with the triangle indices and a random barycentric coord?

**Example**

**Returns** void

Expand object along the normals

**Example**

(with-primitive (build-cube) (expand 5))

**Returns** void

Bakes ambient occlusion textures. See ambient-occlusion.scm for more info.

**Example**