TABLE OF CONTENTS
::pwtk::scaleAtmPos
SYNOPSIS
proc ::pwtk::scaleAtmPos {args} {
USAGE
::pwtk::scaleAtmPos scale_x ?scale_y? ?scale_z? atmPos
PURPOSE
Scale given atomic positions.
ARGUMENTS
- scale_x --- scale factor for x-coordinates
- scale_y --- (optional) scale factor for y-coordinates (default = scale_x)
- scale_z --- (optional) scale factor for z-coordinates (default = scale_x)
- atmPos --- atomic positions (aka AtmPos)
SOURCE
if { [ llength $args] < 2 || [llength $args] > 4 } { ::pwtk::error "wrong number of arguments, must be: pwtk::scaleAtmPos scale_x ?scale_y? ?scale_z? atmPos" 1 } 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 atmPos [lindex $args end] set result "" foreach line [split $atmPos \n] { set len [llength $line] if { $len == 4 || $len == 7 } { lassign $line sym x y z ix iy iz # we multiply by 1.0 to force the use of floating-point arithmetics (scale can be expression such as 1/2) append result [format $::pwtk::fmt_atmPos($len) \ $sym [expr $x * 1.0*$scale(0)] [expr $y * 1.0*$scale(1)] [expr $z * 1.0*$scale(2)] $ix $iy $iz] } } return $result }