pattern:random
List of: Scheme Extensions
Subjects: Patterns
Contents: Kernel

Action: Creates a random pattern within the indicated region.

Filename: kern/kern_scm/pattern_scm.cxx

APIs: api_random_pattern

Syntax: (pattern:random extents number [dimension=3]


[ellipsoidal=#f] [x-vec=(1 0 0)] [y-vec=(0 1 0)])

Arg Types: extents gvector

number integer

dimension integer

ellipsoidal boolean

x-vec gvector

y-vec gvector

Returns: pattern

Description: Creates a random pattern of number elements, centered at the location of the pattern seed entity and extending distances given by the components of extents in dimension dimensions.


extents specifies the extension distance.


number specifies the number of elements.


dimension specifies the extension dimension.


If ellipsoidal is set to true (#t), the number of pattern elements actually generated may differ somewhat from number.


x-vec and y-vec arguments specify the orientation of the pattern, and are the directions associated with the first two components of extents. (The third component is associated with the cross product of these arguments).

Example: ; pattern:random

; make a prism

(define height 1)

;; height

(define maj_rad 1)

;; maj_rad

(define min_rad 0.5)

;; min_rad

(define num_sides 3)

;; num_sides

(define prism


(solid:prism height maj_rad min_rad num_sides))

;; prism

; position the prism

(define origin (position 1 2 3))

;; origin

(define transform (entity:transform prism


(transform:axes


origin (gvector 1 0 0) (gvector 0 1 0))))

;; transform

; make a pattern

(define extents (gvector 50 25 10))

;; extents

(define num 100)

;; num

(define dim 3)

;; dim

(define pat (pattern:random extents num dim))

;; pat

; apply the pattern to the prism

(define body (entity:pattern prism pat))

;; body
PDF/KERN/14SCI.PDF
HTM/DATA/KERN/KERN/14SCI/0080.HTM