# Revision history [back]

### Is it possible to determine if a line segment is present between two points?

Hello everyone. I'm working on a program which plots 3D molecular structures and associated point group symmetries. I've had some issues figuring out how to fill in the remaining single bonds of a six member ring (aromatic class) after the user dictates where double bonds should be placed. These aromatics are basically 6 member cycle graphs for the purposes of my problem. Is there any way to evaluate two coordinates (atoms) on a 3d graphic object (molecule) and check if a line segment (bond) has already been added between them? By necessity any pi (double) bond should only be connected to the adjacent, (non pi-bonded) atom. So for example if there was a pi bond present between Atoms 1 and 2 of a ring then we should have single bonds between A6-A1 and A2-A3. The code below is how I am currently approaching that problem.

Bonds = str(input('Enter pi bond atomic pair in format "A1-A2" or type PLOT: '))

while (Bonds != 'PLOT'):
Bonds2 = Bonds.split('-')
for bond in Bonds2:
if bond == 'A1':
pi_list.append(A1)
elif bond == 'A2':
pi_list.append(A2)
elif bond == 'A3':
pi_list.append(A3)
elif bond == 'A4':
pi_list.append(A4)
elif bond == 'A5':
pi_list.append(A5)
elif bond == 'A6':
pi_list.append(A6)
if pi_list != []:
x += pi_bond(x,pi_list, pi_list)
for atom in Coords:
for pi_atom in pi_list:
if (atom != pi_list) and (atom != pi_list) and (float(distance(pi_atom,atom))==float(distance(A1,A2))):
x += single_bond(pi_atom, atom)


Can anyone think of a more elegant way to approach this?

### Is it possible to determine if a line segment is present between two points?

Hello everyone. I'm working on a program which plots 3D molecular structures and associated point group symmetries. I've had some issues figuring out how to fill in the remaining single bonds of a six member ring (aromatic class) after the user dictates where double bonds should be placed. These aromatics are basically 6 member cycle graphs for the purposes of my problem. Is there any way to evaluate two coordinates (atoms) on a 3d graphic object (molecule) and check if a line segment (bond) has already been added between them? By necessity any pi (double) bond should only be connected to the adjacent, (non pi-bonded) atom. So for example if there was a pi bond present between Atoms 1 and 2 of a ring then we should have single bonds between A6-A1 and A2-A3. The code below is how I am currently approaching that problem.

 Bonds = str(input('Enter pi bond atomic pair in format "A1-A2" or type PLOT: '))

while (Bonds != 'PLOT'):
Bonds2 = Bonds.split('-')
for bond in Bonds2:
if bond == 'A1':
pi_list.append(A1)
elif bond == 'A2':
pi_list.append(A2)
elif bond == 'A3':
pi_list.append(A3)
elif bond == 'A4':
pi_list.append(A4)
elif bond == 'A5':
pi_list.append(A5)
elif bond == 'A6':
pi_list.append(A6)
if pi_list != []:
x += pi_bond(x,pi_list, pi_list)
for atom in Coords:
for pi_atom in pi_list:
if (atom != pi_list) and (atom != pi_list) and (float(distance(pi_atom,atom))==float(distance(A1,A2))):
x += single_bond(pi_atom, atom)
pi_list.clear()

if (Bonds == 'PLOT'):
break
Bonds = str(input('Enter additional pi bonds or


Can anyone think of a more elegant way to approach this?

### Is it possible to determine if a line segment is present between two points?

Hello everyone. I'm working on a program which plots 3D molecular structures and associated point group symmetries. I've had some issues figuring out how to fill in the remaining single bonds of a six member ring (aromatic class) after the user dictates where double bonds should be placed. These aromatics are basically 6 member cycle graphs for the purposes of my problem. Is there any way to evaluate two coordinates (atoms) on a 3d graphic object (molecule) and check if a line segment (bond) has already been added between them? By necessity any pi (double) bond should only be connected to the adjacent, (non pi-bonded) atom. So for example if there was a pi bond present between Atoms 1 and 2 of a ring then we should have single bonds between A6-A1 and A2-A3. The code below is how I am currently approaching that problem.

    Bonds = str(input('Enter pi bond atomic pair in format "A1-A2" or type PLOT: '))

while (Bonds != 'PLOT'):
Bonds2 = Bonds.split('-')
for bond in Bonds2:

if bond == 'A1':
pi_list.append(A1)
elif bond == 'A2':
pi_list.append(A2)
elif bond == 'A3':
pi_list.append(A3)
elif bond == 'A4':
pi_list.append(A4)
elif bond == 'A5':
pi_list.append(A5)
elif bond == 'A6':
pi_list.append(A6)

if pi_list != []:
x += pi_bond(x,pi_list, pi_list)
for atom in Coords:
for pi_atom in pi_list:
if (atom != pi_list) and (atom != pi_list) and (float(distance(pi_atom,atom))==float(distance(A1,A2))):
x += single_bond(pi_atom, atom)
pi_list.clear()

if (Bonds == 'PLOT'):
break
Bonds = str(input('Enter additional pi bonds or
or type PLOT: '))


Can anyone think of a more elegant way to approach this?

### Is it possible to determine if a line segment is present between two points?

Hello everyone. I'm working on a program which plots 3D molecular structures and associated point group symmetries. I've had some issues figuring out how to fill in the remaining single bonds of a six member ring (aromatic class) after the user dictates where double bonds should be placed. These aromatics are basically 6 member cycle graphs for the purposes of my problem. Is there any way to evaluate two coordinates (atoms) on a 3d graphic object (molecule) and check if a line segment (bond) has already been added between them? By necessity any pi (double) bond should only be connected to the adjacent, (non pi-bonded) atom. So for example if there was a pi bond present between Atoms 1 and 2 of a ring then we should have single bonds between A6-A1 and A2-A3. The code below is how I am currently approaching that problem.

A1,A2,A3,A4,A6 are fixed, three dimensional coordinates associated with each position on the ring.

    Bonds = str(input('Enter pi bond atomic pair in format "A1-A2" or type PLOT: '))

while (Bonds != 'PLOT'):
Bonds2 = Bonds.split('-')
for bond in Bonds2:

if bond == 'A1':
pi_list.append(A1)
elif bond == 'A2':
pi_list.append(A2)
elif bond == 'A3':
pi_list.append(A3)
elif bond == 'A4':
pi_list.append(A4)
elif bond == 'A5':
pi_list.append(A5)
elif bond == 'A6':
pi_list.append(A6)

if pi_list != []:
x += pi_bond(x,pi_list, pi_list)
for atom in Coords:
for pi_atom in pi_list:
if (atom != pi_list) and (atom != pi_list) and (float(distance(pi_atom,atom))==float(distance(A1,A2))):
x += single_bond(pi_atom, atom)
pi_list.clear()

if (Bonds == 'PLOT'):
break
Bonds = str(input('Enter additional pi bonds or type PLOT: '))


Can anyone think of a more elegant way to approach this?

### Is it possible to determine if a line segment is present between two points?

Hello everyone. I'm working on a program which plots 3D molecular structures and associated point group symmetries. I've had some issues figuring out how to fill in the remaining single bonds of a six member ring (aromatic class) after the user dictates where double bonds should be placed. These aromatics are basically 6 member cycle graphs for the purposes of my problem. Is there any way to evaluate two coordinates (atoms) on a 3d graphic object (molecule) and check if a line segment (bond) has already been added between them? By necessity any pi (double) bond should only be connected to the adjacent, (non pi-bonded) atom. So for example if there was a pi bond present between Atoms 1 and 2 of a ring then we should have single bonds between A6-A1 and A2-A3. The code below is how I am currently approaching that problem.

A1,A2,A3,A4,A6 are fixed, three dimensional coordinates associated with each position on the ring.

    Bonds = str(input('Enter pi bond atomic pair in format "A1-A2" or type PLOT: '))

while (Bonds != 'PLOT'):
Bonds2 = Bonds.split('-')
for bond in Bonds2:

if bond == 'A1':
pi_list.append(A1)
elif bond == 'A2':
pi_list.append(A2)
elif bond == 'A3':
pi_list.append(A3)
elif bond == 'A4':
pi_list.append(A4)
elif bond == 'A5':
pi_list.append(A5)
elif bond == 'A6':
pi_list.append(A6)

if pi_list != []:
x += pi_bond(x,pi_list, pi_list)
for atom in Coords:
for pi_atom in pi_list:
if (atom != pi_list) and (atom != pi_list) and (float(distance(pi_atom,atom))==float(distance(A1,A2))):
x += single_bond(pi_atom, atom)
pi_list.clear()

if (Bonds == 'PLOT'):
break
Bonds = str(input('Enter additional pi bonds or type PLOT: '))


Can anyone think of a more elegant way to approach this?

### Is it possible to determine if a line segment is present between two points?points on a 3d graphic object?

Hello everyone. I'm working on a program which plots 3D molecular structures and associated point group symmetries. I've had some issues figuring out how to fill in the remaining single bonds of a six member ring (aromatic class) after the user dictates where double bonds should be placed. These aromatics are basically 6 member cycle graphs for the purposes of my problem. Is there any way to evaluate two coordinates (atoms) on a 3d graphic object (molecule) and check if a line segment (bond) has already been added between them? By necessity any pi (double) bond should only be connected to the adjacent, (non pi-bonded) atom. So for example if there was a pi bond present between Atoms 1 and 2 of a ring then we should have single bonds between A6-A1 and A2-A3. The code below is how I am currently approaching that problem.

A1,A2,A3,A4,A6 are fixed, three dimensional coordinates associated with each position on the ring.

    Bonds = str(input('Enter pi bond atomic pair in format "A1-A2" or type PLOT: '))

while (Bonds != 'PLOT'):
Bonds2 = Bonds.split('-')
for bond in Bonds2:

if bond == 'A1':
pi_list.append(A1)
elif bond == 'A2':
pi_list.append(A2)
elif bond == 'A3':
pi_list.append(A3)
elif bond == 'A4':
pi_list.append(A4)
elif bond == 'A5':
pi_list.append(A5)
elif bond == 'A6':
pi_list.append(A6)

if pi_list != []:
x += pi_bond(x,pi_list, pi_list)
for atom in Coords:
for pi_atom in pi_list:
if (atom != pi_list) and (atom != pi_list) and (float(distance(pi_atom,atom))==float(distance(A1,A2))):
x += single_bond(pi_atom, atom)
pi_list.clear()

if (Bonds == 'PLOT'):
break
Bonds = str(input('Enter additional pi bonds or type PLOT: '))


Can anyone think of a more elegant way to approach this?

Here is the function I am currently using to add a double bond between two points:

def pi_bond(x,Cx,Cy): X = 0.05 if Cx == Cy: Ca = Cx-X Cb = Cx+X Cc = Cy-X Cd = Cy+X Cx1 = (Cx, Ca, Cx) Cx2 = (Cx, Cb, Cx) Cy1 = (Cy, Cc, Cy) Cy2 = (Cy, Cd, Cy) x += LineSegment(Cx1, Cy1, 1, color='white', axes=False, frame=False) x += LineSegment(Cx2, Cy2, 1, color='white', axes=False, frame=False) return x else: Ca = Cx-X Cb = Cx+X Cc = Cy-X Cd = Cy+X Cx1 = (Cx, Cx, Ca) Cx2 = (Cx, Cx, Cb) Cy1 = (Cy, Cy, Cc) Cy2 = (Cy, Cy, Cd) x += LineSegment(Cx1, Cy1, 1, color='white', axes=False, frame=False) x += LineSegment(Cx2, Cy2, 1, color='white', axes=False, frame=False) return x

### Is it possible to determine if a line segment is present between two points on a 3d graphic object?

Hello everyone. I'm working on a program which plots 3D molecular structures and associated point group symmetries. I've had some issues figuring out how to fill in the remaining single bonds of a six member ring (aromatic class) after the user dictates where double bonds should be placed. These aromatics are basically 6 member cycle graphs for the purposes of my problem. Is there any way to evaluate two coordinates (atoms) on a 3d graphic object (molecule) and check if a line segment (bond) has already been added between them? By necessity any pi (double) bond should only be connected to the adjacent, (non pi-bonded) atom. So for example if there was a pi bond present between Atoms 1 and 2 of a ring then we should have single bonds between A6-A1 and A2-A3. The code below is how I am currently approaching that problem.

A1,A2,A3,A4,A6 are fixed, three dimensional coordinates associated with each position on the ring.

    Bonds = str(input('Enter pi bond atomic pair in format "A1-A2" or type PLOT: '))

while (Bonds != 'PLOT'):
Bonds2 = Bonds.split('-')
for bond in Bonds2:

if bond == 'A1':
pi_list.append(A1)
elif bond == 'A2':
pi_list.append(A2)
elif bond == 'A3':
pi_list.append(A3)
elif bond == 'A4':
pi_list.append(A4)
elif bond == 'A5':
pi_list.append(A5)
elif bond == 'A6':
pi_list.append(A6)

if pi_list != []:
x += pi_bond(x,pi_list, pi_list)
for atom in Coords:
for pi_atom in pi_list:
if (atom != pi_list) and (atom != pi_list) and (float(distance(pi_atom,atom))==float(distance(A1,A2))):
x += single_bond(pi_atom, atom)
pi_list.clear()

if (Bonds == 'PLOT'):
break
Bonds = str(input('Enter additional pi bonds or type PLOT: '))


Can anyone think of a more elegant way to approach this?

Here is the function I am currently using to add a double bond between two points:

 def pi_bond(x,Cx,Cy):
X = 0.05
if Cx == Cy:
Ca = Cx-X
Cb = Cx+X
Cc = Cy-X
Cd = Cy+X
Cx1 = (Cx, Ca, Cx)
Cx2 = (Cx, Cb, Cx)
Cy1 = (Cy, Cc, Cy)
Cy2 = (Cy, Cd, Cy)
x += LineSegment(Cx1, Cy1, 1, color='white', axes=False, frame=False)
x += LineSegment(Cx2, Cy2, 1, color='white', axes=False, frame=False)
return x
else:
Ca = Cx-X
Cb = Cx+X
Cc = Cy-X
Cd = Cy+X
Cx1 = (Cx, Cx, Ca)
Cx2 = (Cx, Cx, Cb)
Cy1 = (Cy, Cy, Cc)
Cy2 = (Cy, Cy, Cd)
x += LineSegment(Cx1, Cy1, 1, color='white', axes=False, frame=False)
x += LineSegment(Cx2, Cy2, 1, color='white', axes=False, frame=False)
return xx


### Is it possible to determine if a line segment is present between two points on a 3d graphic object?

Hello everyone. I'm working on a program which plots 3D molecular structures and associated point group symmetries. I've had some issues figuring out how to fill in the remaining single bonds of a six member ring (aromatic class) after the user dictates where double bonds should be placed. These aromatics are basically 6 member cycle graphs for the purposes of my problem. Is there any way to evaluate two coordinates (atoms) on a 3d graphic object (molecule) and check if a line segment (bond) has already been added between them? By necessity any pi (double) bond should only be connected to the adjacent, (non pi-bonded) atom. So for example if there was a pi bond present between Atoms 1 and 2 of a ring then we should have single bonds between A6-A1 and A2-A3. The code below is how I am currently approaching that problem.

A1,A2,A3,A4,A6 are fixed, three dimensional coordinates associated with each position on the ring.

    Bonds = str(input('Enter pi bond atomic pair in format "A1-A2" or type PLOT: '))

while (Bonds != 'PLOT'):
Bonds2 = Bonds.split('-')
for bond in Bonds2:

if bond == 'A1':
pi_list.append(A1)
elif bond == 'A2':
pi_list.append(A2)
elif bond == 'A3':
pi_list.append(A3)
elif bond == 'A4':
pi_list.append(A4)
elif bond == 'A5':
pi_list.append(A5)
elif bond == 'A6':
pi_list.append(A6)

if pi_list != []:
x += pi_bond(x,pi_list, pi_list)
for atom in Coords:
for pi_atom in pi_list:
if (atom != pi_list) and (atom != pi_list) and (float(distance(pi_atom,atom))==float(distance(A1,A2))):
x += single_bond(pi_atom, atom)
pi_list.clear()

if (Bonds == 'PLOT'):
break
Bonds = str(input('Enter additional pi bonds or type PLOT: '))


Can anyone think of a more elegant way to approach this?

Here is the function I am currently using to add a double bond between two points:

    def pi_bond(x,Cx,Cy):
X = 0.05
if Cx == Cy:
Ca = Cx-X
Cb = Cx+X
Cc = Cy-X
Cd = Cy+X
Cx1 = (Cx, Ca, Cx)
Cx2 = (Cx, Cb, Cx)
Cy1 = (Cy, Cc, Cy)
Cy2 = (Cy, Cd, Cy)
x += LineSegment(Cx1, Cy1, 1, color='white', axes=False, frame=False)
x += LineSegment(Cx2, Cy2, 1, color='white', axes=False, frame=False)
return x
else:
Ca = Cx-X
Cb = Cx+X
Cc = Cy-X
Cd = Cy+X
Cx1 = (Cx, Cx, Ca)
Cx2 = (Cx, Cx, Cb)
Cy1 = (Cy, Cy, Cc)
Cy2 = (Cy, Cy, Cd)
x += LineSegment(Cx1, Cy1, 1, color='white', axes=False, frame=False)
x += LineSegment(Cx2, Cy2, 1, color='white', axes=False, frame=False)
return x


### Is it possible to determine if a line segment is present between two points on a 3d graphic object?

Hello everyone. I'm working on a program which plots 3D molecular structures and associated point group symmetries. I've had some issues figuring out how to fill in the remaining single bonds of a six member ring (aromatic class) after the user dictates where double bonds should be placed. These aromatics are basically 6 member cycle graphs for the purposes of my problem. Is there any way to evaluate two coordinates (atoms) on a 3d graphic object (molecule) and check if a line segment (bond) has already been added between them? By necessity any pi (double) bond should only be connected to the adjacent, (non pi-bonded) atom. So for example if there was a pi bond present between Atoms 1 and 2 of a ring then we should have single bonds between A6-A1 and A2-A3. The code below is how I am currently approaching that problem.

A1,A2,A3,A4,A6 are fixed, three dimensional coordinates associated with each position on the ring.

    Bonds = str(input('Enter pi bond atomic pair in format "A1-A2" or type PLOT: '))

while (Bonds != 'PLOT'):
Bonds2 = Bonds.split('-')
for bond in Bonds2:

if bond == 'A1':
pi_list.append(A1)
elif bond == 'A2':
pi_list.append(A2)
elif bond == 'A3':
pi_list.append(A3)
elif bond == 'A4':
pi_list.append(A4)
elif bond == 'A5':
pi_list.append(A5)
elif bond == 'A6':
pi_list.append(A6)

if pi_list != []:
x += pi_bond(x,pi_list, pi_list)
for atom in Coords:
for pi_atom in pi_list:
if (atom != pi_list) and (atom != pi_list) and (float(distance(pi_atom,atom))==float(distance(A1,A2))):
x += single_bond(pi_atom, atom)
pi_list.clear()

if (Bonds == 'PLOT'):
break
Bonds = str(input('Enter additional pi bonds or type PLOT: '))


Can anyone think of a more elegant way to approach this?

Here is the function I am currently using to add a double bond between two points:

    def pi_bond(x,Cx,Cy):
X = 0.05
if Cx == Cy:
Ca = Cx-X
Cb = Cx+X
Cc = Cy-X
Cd = Cy+X
Cx1 = (Cx, Ca, Cx)
Cx2 = (Cx, Cb, Cx)
Cy1 = (Cy, Cc, Cy)
Cy2 = (Cy, Cd, Cy)
x += LineSegment(Cx1, Cy1, 1, color='white', axes=False, frame=False)
x += LineSegment(Cx2, Cy2, 1, color='white', axes=False, frame=False)
return x
else:
Ca = Cx-X
Cb = Cx+X
Cc = Cy-X
Cd = Cy+X
Cx1 = (Cx, Cx, Ca)
Cx2 = (Cx, Cx, Cb)
Cy1 = (Cy, Cy, Cc)
Cy2 = (Cy, Cy, Cd)
x += LineSegment(Cx1, Cy1, 1, color='white', axes=False, frame=False)
x += LineSegment(Cx2, Cy2, 1, color='white', axes=False, frame=False)
return x


### Is it possible to determine if a line segment is present between two points on a 3d graphic object?

Hello everyone. I'm working on a program which plots 3D molecular structures and associated point group symmetries. I've had some issues figuring out how to fill in the remaining single bonds of a six member ring (aromatic class) after the user dictates where double bonds should be placed. These aromatics are basically 6 member cycle graphs for the purposes of my problem. Is there any way to evaluate two coordinates (atoms) on a 3d graphic object (molecule) and check if a line segment (bond) has already been added between them? By necessity any pi (double) bond should only be connected to the adjacent, (non pi-bonded) atom. So for example if there was a pi bond present between Atoms 1 and 2 of a ring then we should have single bonds between A6-A1 and A2-A3. The code below is how I am currently approaching that problem.

A1,A2,A3,A4,A6 are fixed, three dimensional coordinates associated with each position on the ring.

 Bonds = str(input('Enter pi bond atomic pair in format "A1-A2" or type PLOT: '))

while (Bonds != 'PLOT'):
Bonds2 = Bonds.split('-')
for bond in Bonds2:
if bond == 'A1':
pi_list.append(A1)
elif bond == 'A2':
pi_list.append(A2)
elif bond == 'A3':
pi_list.append(A3)
elif bond == 'A4':
pi_list.append(A4)
elif bond == 'A5':
pi_list.append(A5)
elif bond == 'A6':
pi_list.append(A6)
if pi_list != []:
x += pi_bond(x,pi_list, pi_list)
for atom in Coords:
for pi_atom in pi_list:
if (atom != pi_list) and (atom != pi_list) and (float(distance(pi_atom,atom))==float(distance(A1,A2))):
x += single_bond(pi_atom, atom)
pi_list.clear()

if (Bonds == 'PLOT'):
break
Bonds = str(input('Enter additional pi bonds or type PLOT: '))


Can anyone think of a more elegant way to approach this?

Here is the function I am currently using to add a double bond between two points:

 def pi_bond(x,Cx,Cy):
X = 0.05
if Cx == Cy:
Ca = Cx-X
Cb = Cx+X
Cc = Cy-X
Cd = Cy+X
Cx1 = (Cx, Ca, Cx)
Cx2 = (Cx, Cb, Cx)
Cy1 = (Cy, Cc, Cy)
Cy2 = (Cy, Cd, Cy)
x += LineSegment(Cx1, Cy1, 1, color='white', axes=False, frame=False)
x += LineSegment(Cx2, Cy2, 1, color='white', axes=False, frame=False)
return x
else:
Ca = Cx-X
Cb = Cx+X
Cc = Cy-X
Cd = Cy+X
Cx1 = (Cx, Cx, Ca)
Cx2 = (Cx, Cx, Cb)
Cy1 = (Cy, Cy, Cc)
Cy2 = (Cy, Cy, Cd)
x += LineSegment(Cx1, Cy1, 1, color='white', axes=False, frame=False)
x += LineSegment(Cx2, Cy2, 1, color='white', axes=False, frame=False)
return x


### Is it possible to determine if a line segment is present between two points on a 3d graphic object?

Hello everyone. I'm working on a program which plots 3D molecular structures and associated point group symmetries. I've had some issues figuring out how to fill in the remaining single bonds of a six member ring (aromatic class) after the user dictates where double bonds should be placed. These aromatics are basically 6 member cycle graphs for the purposes of my problem. Is there any way to evaluate two coordinates (atoms) on a 3d graphic object (molecule) and check if a line segment (bond) has already been added between them? By necessity any pi (double) bond should only be connected to the adjacent, (non pi-bonded) atom. So for example if there was a pi bond present between Atoms 1 and 2 of a ring then we should have single bonds between A6-A1 and A2-A3. The code below is how I am currently approaching that problem.

A1,A2,A3,A4,A6 are fixed, three dimensional coordinates associated with each position on the ring.

Bonds = str(input('Enter pi bond atomic pair in format "A1-A2" or type PLOT: '))

while (Bonds != 'PLOT'):
Bonds2 = Bonds.split('-')
for bond in Bonds2:
if bond == 'A1':
pi_list.append(A1)
elif bond == 'A2':
pi_list.append(A2)
elif bond == 'A3':
pi_list.append(A3)
elif bond == 'A4':
pi_list.append(A4)
elif bond == 'A5':
pi_list.append(A5)
elif bond == 'A6':
pi_list.append(A6)
if pi_list != []:
x += pi_bond(x,pi_list, pi_list)
for atom in Coords:
for pi_atom in pi_list:
if (atom != pi_list) and (atom != pi_list) and (float(distance(pi_atom,atom))==float(distance(A1,A2))):
x += single_bond(pi_atom, atom)
pi_list.clear()

if (Bonds == 'PLOT'):
break
Bonds = str(input('Enter additional pi bonds or type PLOT: '))


Can anyone think of a more elegant way to approach this?

Here is the function I am currently using to add a double bond between two points:

def pi_bond(x,Cx,Cy):
X = 0.05
if Cx == Cy:
Ca = Cx-X
Cb = Cx+X
Cc = Cy-X
Cd = Cy+X
Cx1 = (Cx, Ca, Cx)
Cx2 = (Cx, Cb, Cx)
Cy1 = (Cy, Cc, Cy)
Cy2 = (Cy, Cd, Cy)
x += LineSegment(Cx1, Cy1, 1, color='white', axes=False, frame=False)
x += LineSegment(Cx2, Cy2, 1, color='white', axes=False, frame=False)
return x
else:
Ca = Cx-X
Cb = Cx+X
Cc = Cy-X
Cd = Cy+X
Cx1 = (Cx, Cx, Ca)
Cx2 = (Cx, Cx, Cb)
Cy1 = (Cy, Cy, Cc)
Cy2 = (Cy, Cy, Cd)
x += LineSegment(Cx1, Cy1, 1, color='white', axes=False, frame=False)
x += LineSegment(Cx2, Cy2, 1, color='white', axes=False, frame=False)
return x


### Is it possible to determine if a line segment is present between two points on a 3d graphic object?

Hello everyone. I'm working on a program which plots 3D molecular structures and associated point group symmetries. I've had some issues figuring out how to fill in the remaining single bonds of a six member ring (aromatic class) after the user dictates where double bonds should be placed. These aromatics are basically 6 member cycle graphs for the purposes of my problem. Is there any way to evaluate two coordinates (atoms) on a 3d graphic object (molecule) and check if a line segment (bond) has already been added between them? By necessity any pi (double) bond should only be connected to the adjacent, (non pi-bonded) atom. So for example if there was a pi bond present between Atoms 1 and 2 of a ring then we should have single bonds between A6-A1 and A2-A3. The code below is how I am currently approaching that problem.

A1,A2,A3,A4,A6 are fixed, three dimensional coordinates associated with each position on the ring.

Bonds = str(input('Enter pi bond atomic pair in format "A1-A2" or type PLOT: '))

while (Bonds != 'PLOT'):
Bonds2 = Bonds.split('-')
for bond in Bonds2:
if bond == 'A1':
pi_list.append(A1)
elif bond == 'A2':
pi_list.append(A2)
elif bond == 'A3':
pi_list.append(A3)
elif bond == 'A4':
pi_list.append(A4)
elif bond == 'A5':
pi_list.append(A5)
elif bond == 'A6':
pi_list.append(A6)
if pi_list != []:
x += pi_bond(x,pi_list, pi_list)
for atom in Coords:
for pi_atom in pi_list:
if (atom != pi_list) and (atom != pi_list) and (float(distance(pi_atom,atom))==float(distance(A1,A2))):
x += single_bond(pi_atom, atom)
pi_list.clear()

if (Bonds == 'PLOT'):
break
Bonds = str(input('Enter additional pi bonds or type PLOT: '))


Can anyone think of a more elegant way to approach this?

Here is the function I am currently using to add a double bond between two points:

def pi_bond(x,Cx,Cy):
X = 0.05
if Cx == Cy:
Ca = Cx-X
Cb = Cx+X
Cc = Cy-X
Cd = Cy+X
Cx1 = (Cx, Ca, Cx)
Cx2 = (Cx, Cb, Cx)
Cy1 = (Cy, Cc, Cy)
Cy2 = (Cy, Cd, Cy)
x += LineSegment(Cx1, Cy1, 1, color='white', axes=False, frame=False)
x += LineSegment(Cx2, Cy2, 1, color='white', axes=False, frame=False)
return x
else:
Ca = Cx-X
Cb = Cx+X
Cc = Cy-X
Cd = Cy+X
Cx1 = (Cx, Cx, Ca)
Cx2 = (Cx, Cx, Cb)
Cy1 = (Cy, Cy, Cc)
Cy2 = (Cy, Cy, Cd)
x += LineSegment(Cx1, Cy1, 1, color='white', axes=False, frame=False)
x += LineSegment(Cx2, Cy2, 1, color='white', axes=False, frame=False)
return x