g: GHOST ATOMS=1,2,3 COORDINATES=1.0,2.0,3.0

gpos: POSITION ATOM=g NOPBC

# alternative explicit calculation:
pos1: POSITION ATOM=1
n12: DISTANCE ATOMS=1,2 COMPONENTS
n13: DISTANCE ATOMS=1,3 COMPONENTS
n12nx: MATHEVAL PERIODIC=NO ARG=n12.x,n12.y,n12.z FUNC=x/sqrt(x*x+y*y+z*z)
n12ny: MATHEVAL PERIODIC=NO ARG=n12.x,n12.y,n12.z FUNC=y/sqrt(x*x+y*y+z*z)
n12nz: MATHEVAL PERIODIC=NO ARG=n12.x,n12.y,n12.z FUNC=z/sqrt(x*x+y*y+z*z)
n13nx: MATHEVAL PERIODIC=NO ARG=n13.x,n13.y,n13.z FUNC=x/sqrt(x*x+y*y+z*z)
n13ny: MATHEVAL PERIODIC=NO ARG=n13.x,n13.y,n13.z FUNC=y/sqrt(x*x+y*y+z*z)
n13nz: MATHEVAL PERIODIC=NO ARG=n13.x,n13.y,n13.z FUNC=z/sqrt(x*x+y*y+z*z)
n14x:  MATHEVAL PERIODIC=NO ARG=n12nx,n12ny,n12nz,n13nx,n13ny,n13nz VAR=ax,ay,az,bx,by,bz FUNC=ay*bz-by*az+0*ax+0*bx
n14y:  MATHEVAL PERIODIC=NO ARG=n12nx,n12ny,n12nz,n13nx,n13ny,n13nz VAR=ax,ay,az,bx,by,bz FUNC=az*bx-bz*ax+0*ay+0*by
n14z:  MATHEVAL PERIODIC=NO ARG=n12nx,n12ny,n12nz,n13nx,n13ny,n13nz VAR=ax,ay,az,bx,by,bz FUNC=ax*by-bx*ay+0*az+0*bz
n14nx: MATHEVAL PERIODIC=NO ARG=n14x,n14y,n14z FUNC=x/sqrt(x*x+y*y+z*z)
n14ny: MATHEVAL PERIODIC=NO ARG=n14x,n14y,n14z FUNC=y/sqrt(x*x+y*y+z*z)
n14nz: MATHEVAL PERIODIC=NO ARG=n14x,n14y,n14z FUNC=z/sqrt(x*x+y*y+z*z)
n15x:  MATHEVAL PERIODIC=NO ARG=n12nx,n12ny,n12nz,n14nx,n14ny,n14nz VAR=ax,ay,az,bx,by,bz FUNC=ay*bz-by*az+0*ax+0*bx
n15y:  MATHEVAL PERIODIC=NO ARG=n12nx,n12ny,n12nz,n14nx,n14ny,n14nz VAR=ax,ay,az,bx,by,bz FUNC=az*bx-bz*ax+0*ay+0*by
n15z:  MATHEVAL PERIODIC=NO ARG=n12nx,n12ny,n12nz,n14nx,n14ny,n14nz VAR=ax,ay,az,bx,by,bz FUNC=ax*by-bx*ay+0*az+0*bz

gposx: MATHEVAL PERIODIC=NO ARG=pos1.x,n12nx,n14nx,n15x VAR=a,b1,b2,b3 FUNC=a+1.0*b1+2.0*b2+3.0*b3
gposy: MATHEVAL PERIODIC=NO ARG=pos1.y,n12ny,n14ny,n15y VAR=a,b1,b2,b3 FUNC=a+1.0*b1+2.0*b2+3.0*b3
gposz: MATHEVAL PERIODIC=NO ARG=pos1.z,n12nz,n14nz,n15z VAR=a,b1,b2,b3 FUNC=a+1.0*b1+2.0*b2+3.0*b3

#RESTRAINT ARG=gposx,gposy,gposz KAPPA=5.0,6.0,7.0 AT=0.0,0.0,0.0

RESTRAINT ARG=gpos.x,gpos.y,gpos.z KAPPA=5.0,6.0,7.0 AT=0.0,0.0,0.0

PRINT FILE=colvar ARG=gpos.x,gpos.y,gpos.z,gposx,gposy,gposz

DUMPATOMS ATOMS=g FILE=x
