Hi,
As far as can read C++ (and it's not far at all) and from what I can see with the examples you provide, it seems to me that the result coordinates are:
v3.X = (scalar * v2.X) - (area * v2.Y);
v3.Y = (scalar * v2.Y) + (area * v2.X);
where:
scalar is the scalar product (or dot product) of v1 v2:
(v1.X * v2.X) + (v1.Y * v2.Y)
area is the algebraic (signed) area of the triangle descibed by the 2 vectors:
(v1.X * v2.Y) - (v1.Y * v2.X)
As we're in a LISP forum, her're two ways to implement this 'mirror' function
(defun mirror (v1 v2)
((lambda (s a)
(list (- (* s (car v2)) (* a (cadr v2)))
(+ (* s (cadr v2)) (* a (car v2))))
)
(+ (* (car v1) (car v2)) (* (cadr v1) (cadr v2))) ; scalar product
(- (* (car v1) (cadr v2)) (* (cadr v1) (car v2))) ; algebric area
)
)
(defun mirror (v1 v2)
((lambda (x1 x2 y1 y2)
(list
(+ (* x1 (- (* x2 x2) (* y2 y2))) (* 2 x2 y1 y2))
(+ (* y1 (- (* y2 y2) (* x2 x2))) (* 2 x1 x2 y2))
)
)
(car v1)
(car v2)
(cadr v1)
(cadr v2)
)
)