TABLE OF CONTENTS
::pwtk::scaleVec
SYNOPSIS
proc ::pwtk::scaleVec {args} {
USAGE
::pwtk::scaleVec scale_x ?scale_y? ?scale_z? vecs
PURPOSE
Scale (lattice) 3D vectors
ARGUMENTS
- scale_x --- scale factor for x-components
- scale_y --- (optional) scale factor for y-components (default = scale_x)
- scale_z --- (optional) scale factor for z-components (default = scale_x)
- vecs --- 3D vectors to scale in the form of a list (can be many), i.e. vx1 vy1 vz1 vx2 vy2 vz2 ...
SOURCE
if { [ llength $args] < 2 || [llength $args] > 4 } { ::pwtk::error "wrong number of arguments, must be: pwtk::scaleVec scale_x ?scale_y? ?scale_z? vectors" 1 } # parse args set nargs [llength $args] set scale(0) [lindex $args 0] set scale(1) $scale(0) set scale(2) $scale(0) for {set i 1} {$i < $nargs-1} {incr i} { set scale($i) [lindex $args $i] } set vec [lindex $args end] # scale vectors set nl {} set result {} foreach {x y z} $vec { append result "$nl[expr $scale(0) * $x] [expr $scale(1) * $y] [expr $scale(2) * $z]" set nl \n } return $result }