15 | BondLengthInAngstrom : Scale
16 | BondLengthInAngstrom = 1.25
20 | BondLengthInPixels : Scale
21 | BondLengthInPixels = 20
35 | ScalingFactor : Scale
36 | ScalingFactor = BondLengthInPixels / BondLengthInAngstrom
43 | Mol : AffineTransformation
44 | Mol = AT (scaling $
inverse ScalingFactor) vzero
48 | MolPoint = Point Mol
52 | MolVector = Vector (transform Mol)
58 | toCoord : Double -> Maybe Coordinate
59 | toCoord d = refineCoordinate (cast $
d * cast Precision)
64 | toCoords : Point Mol -> Vect 3 Coordinate -> Vect 3 Coordinate
65 | toCoords (P x y) cs@[_,_,z] =
66 | let Just cx := toCoord x | Nothing => cs
67 | Just cy := toCoord (negate y) | Nothing => cs
71 | GetPoint (Vect 3 Coordinate) where
73 | point [x,y,_] = P (cast x) (negate $
cast y)
76 | ModPoint (Vect 3 Coordinate) where
78 | modPoint f cs = toCoords (f $
point cs) cs
81 | GetPoint MolAtom where
83 | point = point . position
86 | ModPoint MolAtom where
88 | modPoint f = {position $= modPoint f}
91 | GetPoint MolAtomAT where
93 | point = point . position
96 | ModPoint MolAtomAT where
98 | modPoint f = {position $= modPoint f}
101 | (m : ModPoint a) => ModPoint (Graph b a) where
102 | mtrans = mtrans @{m}
103 | modPoint = map . modPoint
106 | {k : _} -> (m : ModPoint a) => ModPoint (IGraph k b a) where
107 | mtrans = mtrans @{m}
108 | modPoint = map . modPoint
116 | bondLength : GetPoint a => {k : _} -> IGraph k b a -> Edge k b -> Double
117 | bondLength g (E x y _) = distance (point $
lab g x) (point $
lab g y)
121 | averageBondLength : GetPoint a => {k : _} -> IGraph k b a -> Maybe Double
122 | averageBondLength g = case edges g of
124 | es => Just $
sum (bondLength g <$> es) / cast (length es)
129 | {auto mod : ModPoint a}
130 | -> {auto get : GetPoint a}
132 | -> {auto 0 mp : mtrans @{mod} === Mol}
133 | -> {auto 0 gp : gtrans @{get} === Mol}
136 | normalizeMol g = case averageBondLength g of
138 | Just v => scale (BondLengthInAngstrom / scale v) g