src/Vector.php
public function projectOnto(self $b)
    {
        $bUnit = $b->normalize();
        return $bUnit->multiplyByScalar($this->dotProduct($bUnit));
    }
public function projectOnto(self $b)
    {
        $bUnit = $b->normalize();
        return $bUnit->multiplyByScalar($this->dotProduct($bUnit));
    }
Project the vector onto another vector.

@api
@param self $b The vector to project this vector onto.
@return self The vector projection of this vector onto $b.
@throws Exception if the vector length of $b is zero.
@throws Exception if the vectors are not in the same vector space.
@see self::_checkVectorSpace() For exception information.