* Reflects a vector about a line in 2D or a plane in 3D. * * The orientation of the line or plane is described by a normal vector that * points away from the shape. * * The static version of `reflect()`, as in `p5.Vector.reflect(v, n)`, * returns a new p5.Vect
(surfaceNormal)
| 2724 | * } |
| 2725 | */ |
| 2726 | reflect(surfaceNormal) { |
| 2727 | const surfaceNormalCopy = Vector.normalize(surfaceNormal); |
| 2728 | return this.sub(surfaceNormalCopy.mult(2 * this.dot(surfaceNormalCopy))); |
| 2729 | } |
| 2730 | |
| 2731 | /** |
| 2732 | * Returns the vector's components as an array of numbers. |
no test coverage detected