| 6 | double dot(P(a), P(b)) { return real(conj(a) * b); } |
| 7 | double cross(P(a), P(b)) { return imag(conj(a) * b); } |
| 8 | point rotate(P(p), double radians = pi / 2, |
| 9 | P(about) = point(0,0)) { |
| 10 | return (p - about) * exp(point(0, radians)) + about; } |
| 11 | point reflect(P(p), L(about1, about2)) { |
| 12 | point z = p - about1, w = about2 - about1; |
| 13 | return conj(z / w) * w + about1; } |