1. The forums will be archived and moved to a read only mode in about 2 weeks (mid march).

Difference of trigonometric function and directionvector

Discussion in 'Development' started by Hoyee, Mar 6, 2020.

  1. Hoyee

    Hoyee Baby Zombie

    Messages:
    126
    trigonometric function is just using in distance and directionvector is using in lookingside, isn't?
     
  2. GamakCZ

    GamakCZ Zombie Pigman

    Messages:
    598
    GitHub:
    GamakCZ
    Trigonometric functions are functions for calculating. Player->getDirectionVector() returns the side to which player is looking.

    PHP:
    /**
         * @return Vector3
         */
        
    public function getDirectionVector() : Vector3{
            
    $y = -sin(deg2rad($this->pitch));
            
    $xz cos(deg2rad($this->pitch));
            
    $x = -$xz sin(deg2rad($this->yaw));
            
    $z $xz cos(deg2rad($this->yaw));

            return 
    $this->temporalVector->setComponents($x$y$z)->normalize();
        }
     
    jasonwynn10 and HimbeersaftLP like this.
  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.