(* ::Package:: *) PIflattrans::usage = "PIflattrans attaches Pi clouds to C=C and C=O (C=N) by trans- forming the triangle of every connection triple X-C=C etc. into the xy plane with the C atom to be decorated in the origin. One leg is along the x axis. This version transforms the whole molecular skeleton into the plane of the first triangle transformed. It is thus appropriate for plane molecules like benzene, coronene a.o. The input consists of connection table connc, its length cj, the coordinates of the molecule in table t, and the radii rpo, rpi of the Pi clouds obove and below the plane." Do[(c = connc[[k]]; (* Target 2 *) p=Table[t[[c[[i]]]],{i,1,P}]; If[k==1,v = Table[Join[t[[c[[i]]]], {1}], {i, 1, P}]; x2 = t[[c[[2]],1]]; y2 = t[[c[[2]],2]]; z2 = t[[c[[2]],3]]; Q = {{1, 0, 0, 0}, {0, 1, 0, 0}, {0, 0, 1, 0}, {-x2, -y2, -z2, 1}}; p = v.Q; t2=t1.Q; p = Table[Take[p[[i]], 3], {i, 1, P}]; t2=Table[Take[t2[[i]],3],{i,1,n}]; T1 = ArcTan[p[[1,3]]/p[[1,2]]]; U = p; U1=t2; T = RotationMatrix[T1, {1, 0, 0}]; p = U.T; t2=U1.T; T2 = ArcTan[p[[1,2]]/p[[1,1]]]; U = p; U3=t2; T = RotationMatrix[T2, {0, 0, 1}]; p = U.T; t2=U3.T; T3 = ArcTan[p[[3,3]]/p[[3,2]]]; U = p; U3=t2; T = RotationMatrix[T3, {1, 0, 0}]; p =U.T; t2=U3.T; t=Chop[t2]]; mk = p; ml = p; mk[[2,3]] = rpo[[k]]; ml[[2,3]] = -rpi[[k]]; tpo[[k]] = mk[[2]]; tpu[[k]] = ml[[2]]), {k,cj}];