public static function angle(
        Segment $a,
        Segment $b,
        Segment $c
    ): Degree {
        $a = $a->length();
        $b = $b->length();
        $c = $c->length();
        $longest = max($a, $b, $c);
        $opposites = (new Set(Number::class))
            ->add($a)
            ->add($b)
            ->add($c)
            ->remove($longest);
        $opposites = add(...$opposites);

        if ($longest->higherThan($opposites) && !$longest->equals($opposites)) {
            throw new SegmentsCannotBeJoined;
        }

        $cosAB = $a
            ->power(new Integer(2))
            ->add($b->power(new Integer(2)))
            ->subtract($c->power(new Integer(2)))
            ->divideBy(
                (new Integer(2))
                    ->multiplyBy($a)
                    ->multiplyBy($b)
            );

        return arcCosine($cosAB)->toDegree();
    }
public static function angle(
        Segment $a,
        Segment $b,
        Segment $c
    ): Degree {
        $a = $a->length();
        $b = $b->length();
        $c = $c->length();
        $longest = max($a, $b, $c);
        $opposites = (new Set(Number::class))
            ->add($a)
            ->add($b)
            ->add($c)
            ->remove($longest);
        $opposites = add(...$opposites);

        if ($longest->higherThan($opposites) && !$longest->equals($opposites)) {
            throw new SegmentsCannotBeJoined;
        }

        $cosAB = $a
            ->power(new Integer(2))
            ->add($b->power(new Integer(2)))
            ->subtract($c->power(new Integer(2)))
            ->divideBy(
                (new Integer(2))
                    ->multiplyBy($a)
                    ->multiplyBy($b)
            );

        return arcCosine($cosAB)->toDegree();
    }
public static function angle ( Segment $ a , Segment $ b , Segment $ c ) : Degree { $ a = $ a -> length ( ) ; $ b = $ b -> length ( ) ; $ c = $ c -> length ( ) ; $ longest = max ( $ a , $ b , $ c ) ; $ opposites = ( new Set ( Number :: class ) ) -> add ( $ a ) -> add ( $ b ) -> add ( $ c ) -> remove ( $ longest ) ; $ opposites = add ( ... $ opposites ) ; if ( $ longest -> higherThan ( $ opposites ) && ! $ longest -> equals ( $ opposites ) ) { throw new SegmentsCannotBeJoined ; } $ cosAB = $ a -> power ( new Integer ( 2 ) ) -> add ( $ b -> power ( new Integer ( 2 ) ) ) -> subtract ( $ c -> power ( new Integer ( 2 ) ) ) -> divideBy ( ( new Integer ( 2 ) ) -> multiplyBy ( $ a ) -> multiplyBy ( $ b ) ) ; return arcCosine ( $ cosAB ) -> toDegree ( ) ; }
Return the angle between a and b sides
Return the angle between a and b sides