MCPcopy
hub / github.com/processing/p5.js / reflect

Method reflect

src/math/p5.Vector.js:2726–2729  ·  view source on GitHub ↗

* 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)

Source from the content-addressed store, hash-verified

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.

Callers 1

p5.Vector.jsFile · 0.80

Calls 7

subMethod · 0.95
dotMethod · 0.95
_friendlyErrorMethod · 0.95
normalizeMethod · 0.45
multMethod · 0.45
copyMethod · 0.45
setMethod · 0.45

Tested by

no test coverage detected