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

Action: Creates a new pattern by applying a random scale to an existing pattern.

Filename: kern/kern_scm/pattern_scm.cxx

APIs: api_random_scale_pattern

Syntax: (pattern:random-scale pat min_scale max_scale


root [merge=#t])

Arg Types: pat pattern

min_scale real | gvector

max_scale real | gvector

root position

merge boolean

Returns: pattern

Description: Applies a random scale to an existing pattern, merging with any existing scaling or, optionally (with merge=#f), replacing it.


pat specifies a pattern.


min_scale and max_scale arguments specify limits for the scale values. Both min_scale and max_scale must be greater than zero. They may be given as gvectors when non-uniform scaling is required.


root specifies the neutral point about which the scaling takes place (i.e., the point on the seed entity that remains fixed while the entity's dimensions are altered).


If merge is specified as false (#f), the existing pattern is replaced. The default vaule is true (#t).

Example: ; pattern:random-scale

; 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 x-vec (gvector 4 0 0))

;; x-vec

(define num_x 8)

;; num_x

(define y-vec (gvector 0 2 0))

;; y-vec

(define num_y 10)

;; num_y

(define pat (pattern:linear x-vec num_x y-vec num_y))

;; pat

; modify the pattern

(define min_scale 0.5)

;; min_scale

(define max_scale 2.0)

;; max_scale

(define root origin)

;; root

(set! pat (pattern:random-scale


pat min_scale max_scale root))

;; #[pattern

;; trans-vec: "DOMAIN(X*VEC(4,0,0)+X2*VEC

;; (0,2,0),0,7,0,9)"

;; x-vec: "null_law"

;; y-vec: "null_law"

;; z-vec: "null_law"

;; scale: "null_law"

;; keep: "null_law"

;; no list]]

; apply the pattern to the prism

(define body (entity:pattern prism pat))

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