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

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

Filename: kern/kern_scm/pattern_scm.cxx

APIs: api_periodic_scale_pattern

Syntax: (pattern:periodic-scale pat scales which-dim root


[merge=#t])

Arg Types: pat pattern

scales (real ...) | (gvector ...)

which-dim integer

root position

merge boolean

Returns: pattern

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


pat specifies a pattern.


scales is the list of successive scale values, so that the size of the list is the periodicity of the scaling. All scale values in the list must be greater than zero. They may be given as real (for uniform scaling) or as gvectors (for non-uniform scaling).


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 specified as #f, the existing pattern is replaced. The default value is #t.

Example: ; pattern:periodic-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.5)

;; scale1

(define scale2 1.5)

;; scale2

(define scale3 1.0)

;; scale3

(define scale4 2.0)

;; scale4

(define dim 0)

;; dim

(define root origin)

;; root

(set! pat (pattern:periodic-scale pat


(list scale1 scale2 scale3 scale4) 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/0075.HTM