class GeometricDoubleBondEncoderFactory implements StereoEncoderFactory {

    static GeometricParity geometric(IAtomContainer mol, int l, int r, int l1, int l2, int r1, int r2) {

        // we need all points for 2D as they may be skewed, i.e.
        //
        // \
        //  C=C
        //    |\
        //    C H
        Point2d l2d = mol.getAtom(l).getPoint2d();
        Point2d r2d = mol.getAtom(r).getPoint2d();
        Point2d l12d = mol.getAtom(l1).getPoint2d();
        Point2d l22d = mol.getAtom(l2).getPoint2d();
        Point2d r12d = mol.getAtom(r1).getPoint2d();
        Point2d r22d = mol.getAtom(r2).getPoint2d();

        if (l2d != null && r2d != null && l12d != null && l22d != null && r12d != null && r22d != null) {
            return new DoubleBond2DParity(l2d, r2d, l12d, l22d, r12d, r22d);
        }

        // we only need the first point, we presume the 3D angles are all correct
        Point3d l3d = mol.getAtom(l).getPoint3d();
        Point3d r3d = mol.getAtom(r).getPoint3d();
        Point3d l13d = mol.getAtom(l1).getPoint3d();
        Point3d r13d = mol.getAtom(r1).getPoint3d();
        if (l3d != null && r3d != null && l13d != null && r13d != null)
            return new DoubleBond3DParity(l3d, r3d, l13d, r13d);

        return null;

    }

}