1. Limited time only! Sign up for a free 30min personal tutor trial with Chegg Tutors
    Dismiss Notice
Dismiss Notice
Join Physics Forums Today!
The friendliest, high quality science and math community on the planet! Everyone who loves science is here!

3d vectors question

Tags:
  1. Oct 1, 2014 #1
    1. The problem statement, all variables and given/known data
    A man is standing in his home , his position his facing direction and the position of the sweet dish are given ,if he faces the sweet dish , he eats it .
    Translating it into CS programming question : write a function ->
    bool IsManInFrontofDish( vector3& manPosition, vector3& manFacingPos, vector3& dishPos )
    which return true when the man faces the dish;

    The programming part is easy , I was worried about the physics part .
    Is the manPosition really important in this , or is it just to deceive?
    I am attempting a physics programming question for the first time...
    2. Relevant equations
    A.B = ||A||.||B||

    3. The attempt at a solution
    the angle between 2 vectors is 0 if they are in the same direction so simply by replacing manFacingPos with A and
    dishPos with B and checking the equation i will be able to get the answer:
    translating it into program if it helps :

    bool IsManInFrontofDish( vector3& manPosition, vector3& manFacingPos, vector3& dishPos ) {
    int magnitude1 = sqrt( dot(manFacingPos, manFacingPos) ); //square root of dot product
    int magnitude2 = sqrt( dot(dishPos,dishPos) );
    if(dot(manFacingPos, dishPos) == magnitude1*magnitude2) return true;
    else return false;
    }

    P.S. I am not attending any university or school right now , so this is not a homework question
     
  2. jcsd
  3. Oct 3, 2014 #2

    gneill

    User Avatar

    Staff: Mentor

    It would probably be easier to take the two positions (man and sweet dish) and form a unit vector pointing from the man to the dish. Then form a unit vector from the man's facing direction vector. Compare them.

    That the man's position is important should be clear. Make a sketch. Keeping the same facing direction vector, move the man about the room and see if he ever faces the sweet dish depending upon his location.
     
Know someone interested in this topic? Share this thread via Reddit, Google+, Twitter, or Facebook

Have something to add?
Draft saved Draft deleted



Similar Discussions: 3d vectors question
  1. Vector Question (Replies: 3)

Loading...