MCPcopy
hub / github.com/g3n/engine / ProjectOnVector

Method ProjectOnVector

math32/vector3.go:545–551  ·  view source on GitHub ↗

ProjectOnVector sets this vector to its projection on other vector. Returns the pointer to this updated vector.

(other *Vector3)

Source from the content-addressed store, hash-verified

543// ProjectOnVector sets this vector to its projection on other vector.
544// Returns the pointer to this updated vector.
545func (v *Vector3) ProjectOnVector(other *Vector3) *Vector3 {
546
547 var on Vector3
548 on.Copy(other).Normalize()
549 dot := v.Dot(&on)
550 return v.Copy(&on).MultiplyScalar(dot)
551}
552
553// ProjectOnPlane sets this vector to its projection on the plane
554// specified by its normal vector.

Callers 1

ProjectOnPlaneMethod · 0.80

Calls 4

CopyMethod · 0.95
DotMethod · 0.95
NormalizeMethod · 0.45
MultiplyScalarMethod · 0.45

Tested by

no test coverage detected