def scalar_potential_difference(field, frame, point1, point2, origin):
 _check_frame(frame)
 if isinstance(field, Vector):
  scalar_fn = scalar_potential(field, frame)
 else:
  scalar_fn = field
 position1 = express(point1.pos_from(origin), frame, variables=True)
 position2 = express(point2.pos_from(origin), frame, variables=True)
 subs_dict1 = {}
 subs_dict2 = {}
 for (i, x) in enumerate(frame):
  subs_dict1[frame[i]] = x.dot(position1)
  subs_dict2[frame[i]] = x.dot(position2)
 return (scalar_fn.subs(subs_dict2) - scalar_fn.subs(subs_dict1))

def scalar_potential_difference ( field , frame , point1 , point2 , origin ) : _check_frame ( frame ) if isinstance ( field , Vector ) : scalar_fn = scalar_potential ( field , frame ) else : scalar_fn = field position1 = express ( point1 . pos_from ( origin ) , frame , variables = True ) position2 = express ( point2 . pos_from ( origin ) , frame , variables = True ) subs_dict1 = { } subs_dict2 = { } for ( i , x ) in enumerate ( frame ) : subs_dict1 [ frame [ i ] ] = x . dot ( position1 ) subs_dict2 [ frame [ i ] ] = x . dot ( position2 ) return ( scalar_fn . subs ( subs_dict2 ) - scalar_fn . subs ( subs_dict1 ) )
returns the scalar potential difference between two points in a certain coordinate system .