Action:
|
Moves a single element within an existing pattern.
|
|
Filename:
|
kern/kern_scm/pattern_scm.cxx
|
|
Syntax:
|
(pattern:move-element pat coords transf)
|
|
Arg Types:
|
pat
|
pattern
|
|
coords
|
pair
|
|
transf
|
transform
|
|
Returns:
|
pattern
|
|
Description:
|
Moves the element specified by
coords according to the transformation
transf.
|
|
|
pat specifies a pattern.
|
|
|
coords specifies the element to be transformed.
|
|
|
transf specifies the transformation to be applied.
|
|
Example:
|
; pattern:move-element
|
|
; 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
|
|
; Move the prism.
|
|
(define transform (entity:transform prism
|
|
|
(transform:axes origin (gvector 1 0 0)
|
|
|
(gvector 0 1 0))))
|
|
;; transform
|
|
; Make a pattern.
|
|
(define x-vec (gvector 2 0 0))
|
|
;; x-vec
|
|
(define num_x 8)
|
|
;; num_x
|
|
(define y-vec (gvector 0 3 0))
|
|
;; y-vec
|
|
(define num_y 8)
|
|
;; num_y
|
|
(define pat (pattern:linear x-vec num_x y-vec num_y))
|
|
;; pat
|
|
; OUTPUT Original
|
|
|
; Move one of the pattern elements.
|
|
(define disp (gvector 0.4 1.2 0.5))
|
|
;; disp
|
|
(define move (transform:translation disp))
|
|
;; move
|
|
(set! pat (pattern:move-element pat (list 3 2) move))
|
|
;; #[pattern
|
|
;; trans-vec:
|
"DOMAIN(X*VEC(2,0,0)+X2*VEC
|
|
;; (0,3,0),0,7,0,7)"
|
|
;; x-vec:
|
"null_law"
|
|
;; y-vec:
|
"null_law"
|
|
;; z-vec:
|
"null_law"
|
|
;; scale:
|
"null_law"
|
|
;; keep:
|
"null_law"
|
|
;; [list]]
|
|
; Apply the pattern to the prism.
|
|
(define body (entity:pattern prism pat))
|
|
;; body
|
|
; OUTPUT Result
|
|
|
|
|
Figure 14-5. Moving Pattern Elements
|