How to align 3D viewport along two 3D points using python I'm trying to figure out how to align my 3D viewport to the line connecting two 3D points.
For example, say I want my 3D viewport to be oriented such that it looks directly along the line connecting (1, 2, 3) to (6, 5, 4). As an added constraint, say I wanted to position the viewpoint a distance of 10 from the point (1, 2, 3).
I know how to query the current view_location, view_matrix, view_distance, and view_rotation, but I am unfamiliar with how to transform it to be in the correct position and orientation.
C = bpy.context
viewports_3D = []
for area in C.screen.areas:
    if area.type == 'VIEW_3D':
        viewports_3D.append(area)
viewports_3D[0].spaces.active.region_3d.view_location
viewports_3D[0].spaces.active.region_3d.view_matrix
viewports_3D[0].spaces.active.region_3d.view_distance
viewports_3D[0].spaces.active.region_3d.view_rotation
Track to quaternion.
Can get the quaternion rotation of any vector using Vector.to_track_quat(track, up) and assign an axis to track and an axis for up.
Test script to make the largest 3d view in the area track from the scene camera to the active object.
import bpy

context = bpy.context
scene = context.scene
cam = scene.camera
ob = context.object

start = cam.matrix_world.translation
stop  = ob.matrix_world.translation

norm = start - stop
norm.normalize()

q = norm.to_track_quat()

viewports_3D = [
        a
        for a in context.screen.areas
        if a.type == 'VIEW_3D'
        ]

viewports_3D.sort(
        key=lambda vp: (vp.width * vp.height), 
        )     

# use max area vp
if viewports_3D: 
    vp = viewports_3D.pop() # largest
    r3d = vp.spaces.active.region_3d
    r3d.view_rotation = q
    r3d.view_location = start #lookat this point
    r3d.view_distance = 0 # from this far away

Note above uses default for track to so vector is flipped, more concise would be
norm = stop - start #start - stop
norm.normalize()

q = norm.to_track_quat('-Z', 'Y')

This is equivalent of the result of adding a track to constraint on camera to object. Have used to test