Working with Bonds
Once again we can define many functions on our Bond
, but for now we can just define the following:
Options[DisplayBond]=Flatten@{
Options@DisplayAtom,
BondWidth->Automatic
};
DisplayBond[b_Bond,ops:OptionsPattern[]]:=Graphics3D[
With[{p1=b["Atom1"]["Position"],
p2=b["Atom2"]["Position"],
v=b["Atom2"]["Position"]-b["Atom1"]["Position"],
bw=Replace[OptionValue@BondWidth,Except[_?NumericQ]:>.1]},
{EdgeForm[None],
{b["Atom1"]["Color"],Cylinder[{p1,p1+1/2Norm@v*Normalize@v},bw]},
{b["Atom2"]["Color"],Cylinder[{p2,p2-1/2Norm@v*Normalize@v},bw]}
}],FilterRules[{ops,
Options@DisplayBond
},
Options@Graphics3D]
]