1. Visit this thread for your chance to win a selection of Lionsgate action films on UV!
    Dismiss Notice

anyone familiar with vector math?

Discussion in 'Archived Threads 2001-2004' started by felix_suwarno, Sep 13, 2002.

  1. felix_suwarno

    felix_suwarno Screenwriter

    Joined:
    Dec 2, 2001
    Messages:
    1,523
    Likes Received:
    0
    my prof wants me to write these methods :

    vector operator*(double d, const vector& v)
    {
    // Calculate d * v
    }

    vector operator*(const vector& v, double d)
    {
    // calculate v * d
    }

    v would be vector with x,y and z components.

    my question is, what is the difference between d times vector and vector times d?

    i have consulted my calculus book and didnt find anything to answer this question. the book is "calculus" by james stewart. it only explains about multiplying vector with scalar, basically c times vector -> c times (x,y,z) equal to (cx, cy, cz).
     
  2. James Gumbart

    James Gumbart Stunt Coordinator

    Joined:
    Feb 7, 2002
    Messages:
    70
    Likes Received:
    0
    There is no difference provided d is merely a number (scalar) which it appears to be.

    However when d takes the form of a more complicated operator (matrix, derivative, etc.) then it becomes important.

    No idea why he's making you write two methods though.
     
  3. felix_suwarno

    felix_suwarno Screenwriter

    Joined:
    Dec 2, 2001
    Messages:
    1,523
    Likes Received:
    0
    thanks james. that is very helpful.
     
  4. Wayne Bundrick

    Wayne Bundrick Cinematographer

    Joined:
    May 17, 1999
    Messages:
    2,358
    Likes Received:
    0
    I vaguely remember C++ operator overloading. Maybe the compiler won't automatically invoke d * v if it sees v * d? But if the answer is the same then the second method is easy to write: just call the first method.
     

Share This Page