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

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

Filename: kern/kern_scm/pattern_scm.cxx

APIs: api_alternating_scale_pattern

Syntax: (pattern:alternating-scale pat scale1 scale2


which-dim root [merge=#t])

Arg Types: pat pattern

scale1 real | gvector

scale2 real | gvector

which-dim integer

root position

merge boolean

Returns: pattern

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


pat specifies a pattern.


scale1 and scale2 specifies the alternating scales. The scale values must be greater than zero. They may be given as vectors when non-uniform scaling is desired.


which-dim specifies the dimension in which the scale is applied.


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 false (#f), the existing pattern is replaced.

Example: ; pattern:alternating-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 scale1 0.8)

;; scale1

(define scale2 1.2)

;; scale2

(define dim 1)

;; dim

(define root origin)

;; root

(set! pat (pattern:alternating-scale


pat scale1 scale2 dim 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/0052.HTM