MathPHP\LinearAlgebra\Vector::perpDotProduct PHP Метод

perpDotProduct() публичный Метод

http://mathworld.wolfram.com/PerpDotProduct.html
public perpDotProduct ( Vector $B ) : number
$B Vector
Результат number
    public function perpDotProduct(Vector $B)
    {
        if ($this->n !== 2 || $B->getN() !== 2) {
            throw new Exception\VectorException('Cannot do perp dot product unless both vectors are two-dimensional');
        }
        $A⊥ = $this->perpendicular();
        return $A⊥->dotProduct($B);
    }

Usage Example

Пример #1
0
 /**
  * Perpendicular of A on B
  * https://en.wikipedia.org/wiki/Vector_projection#Vector_projection
  *
  *          A⋅B⊥
  * perpᵇA = ---- B⊥
  *          |B|²
  *
  * @param Vector $B
  *
  * @return Vector
  */
 public function perp(Vector $B) : Vector
 {
     $A⋅B⊥ = $B->perpDotProduct($this);
     $│B│² = $B->l2norm() ** 2;
     $B⊥ = $B->perpendicular();
     return $B⊥->scalarMultiply($A⋅B⊥ / $│B│²);
 }