How can I quickly make two normals opposites? The best way I can really explain this is, in a 2D space, two lines are parallel when you can draw a perpendicular line between both of them. In a 3D space, if you have two surfaces that are facing each other exactly, you could draw a normal between them (except when put into function, since both objects have normals, one of them would have to be the opposite of the other, so they could face each other).

For example:



It's easy enough to do in rotations like that, but with rotations like this, it's not as easy:



I want to rotate the cone so its base is 'parallel in 3D' and facing the side of the cube. The thing is though, I need a fairly quick method of doing this because I need to do this many, many times.
If you know the 3D coordinates of both unit-length normals $\hat n_1$ and $\hat n_2$ -- both expressed in the same coordinate system (e.g. global), and you want to rotate the object owner of $\hat n_2$, you have to rotate around axis:

$$
\hat u = \hat n_1 \times \hat n_2
$$

by an angle

$$
\alpha = \pi - (\hat n_1 \cdot \hat n_2)
$$

In Python:

def rotateObjectSoNormalsOppose(obj, n1, n2):
    '''
    Rotate object so n2 is parallel and opposite to n1

    @param obj (bpy.type.Object) Object to rotate
    @param n1  (mathutils.Vector) Unit-left normal used as reference (in global coordinates)
    @param n2  (mathutils.Vector) Unit-left normal to rotate (in global coordinates)
    @return The rotated object
    '''
    # Compute axis of rotation
    u = n1.cross(n2)
    # Angle of rotation
    alpha = pi - acos(n1.dot(n2))
    # 3x3 rotation matrix
    rot = Matrix.Rotation(alpha, 3, u)

    # Get current orientation of object
    curr_orientation = obj.matrix_world
    # apply delta rotation to obtain the new orientation
    obj.matrix_world = curr_orientation @ rot.to_4x4()

    return obj


where rot is a 3x3 rotation matrix that will rotate the owner of $\hat n_2$ so that $\hat n'_2$ will be parallel but opposite to $\hat n_1$.