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

Action: Creates a hexagonal packing pattern.

Filename: kern/kern_scm/pattern_scm.cxx

APIs: api_hex_pattern

Syntax: (pattern:hex normal xvec xnum ynum)

Arg Types: normal gvector

xvec gvector

xnum integer

ynum integer

Returns: pattern

Description: Creates a hexagonal pattern in the plane defined by normal.


normal defines the plane.


xvec defines the x direction.


xnum and ynum defines the number of pattern entities in the x and y directions.

Example: ; pattern:hex

; Create a prism to demonstrate command.

(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

; Enlarge prism for viewing.

(define zoom (zoom 4))

;; zoom

; OUTPUT Original


; Reposition 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

; Create a pattern.

(define normal (gvector 0 0 1))

;; normal

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

;; x-vec

(define num_x 6)

;; num_x

(define num_y 6)

;; num_y

(define pat (pattern:hex normal x-vec num_x num_y))

;; pat

; Apply the pattern to the prism.

(define body (entity:pattern prism pat))

;; body

; Adjust picture for better viewing.

(view:compute-extrema)

;; ()

; OUTPUT Result





Figure 14-4. pattern:hex
PDF/KERN/14SCI.PDF
HTM/DATA/KERN/KERN/14SCI/0065.HTM