Q:

python find point-B on line by distance from point-A

I have line-equation, point-A and distance, and need to find point-B at the edge of the distance, on the line.
I have 2 equations:
distance = math.sqrt((pt1[0] - pt2[0])**2 + (pt1[1] - pt2[1])**2)
pt2[1] = m*pt2[0] + n

distance, pt1, m and n are known. 
How i implement this calculation in python?
Maybe there is python library that already know to do this for me?

A:

Given the line y=mx+b, the slope m tells us the ratio between the change in x (dx) and the change in y (dy).
Math:
// Given
point_b = (point_a[0]+dx,point_a[1]+dy)
other_possible_point_b = (point_a[0]-dx,point_a[1]-dy)
dy = m*dx
x**2 + y**2 = distance

// Calculations
dx**2 + (m*dx)**2 = distance
(m**2+1)(dx**2) = distance
dx = sqrt(distance/(m**2+1))
dy = m*sqrt(distance/(m**2+1))

Python solution:
from math import sqrt

point_b = (point_a[0]+dx(distance,m), point_a[1]+dy(distance,m))
other_possible_point_b = (point_a[0]-dx(distance,m), point_a[1]-dy(distance,m)) # going the other way

def dy(distance, m):
    return m*dx(distance, m)

def dx(distance, m):
    return sqrt(distance/(m**2+1))

