Results 1 to 3 of 3

Thread: [RESOLVED] Angle between two vectors.

  1. #1

    Thread Starter
    Retired G&G Mod NoteMe's Avatar
    Join Date
    Oct 2002
    Location
    @ Opera Software
    Posts
    10,190

    Resolved [RESOLVED] Angle between two vectors.

    I don't have any of my math books here, but I am reading in a game programming book about vectors, but I can't get the same result as the authour. I am getting something else all the time.

    I'll give a rep to the first guy that gets the same result as me or the authour for these vectors:

    v1 = [1.5, 3.0, 4.0]
    v2 = [4.0, 1.0, 2.0]


    PS: Please give the angle in both Rad and Deg.

    Thanks
    - ØØ -

  2. #2
    Frenzied Member zaza's Avatar
    Join Date
    Apr 2001
    Location
    Borneo Rainforest Habits: Scratching
    Posts
    1,486

    Re: Angle between two vectors.

    Hi,

    Two words for you, Product and Dot. Not necessarily in that order.

    A dot B = mod(A)mod(B)cos(theta)

    A.B = (1.5*4)+(3*1)+(4*2) = 6+3+8 = 17

    mod(A) = sqrt((1.5^2)+(3^2)+(4^2)) = sqrt(2.25+9+16) = 5.22015....

    mod(B) = sqrt((4^2)+(1^2)+(2^2)) = sqrt(16+1+4) = 4.58258...

    Hence cos(theta) = 17 / sqrt(27.25*21) = 0.71065...

    Hence theta = 44.7 degrees or 0.78 rad

    What do you get?

    zaza

    PS. Lazy whatnot.

    Please give the angle in both Rad and Deg.

  3. #3

    Thread Starter
    Retired G&G Mod NoteMe's Avatar
    Join Date
    Oct 2002
    Location
    @ Opera Software
    Posts
    10,190

    Re: [RESOLVED] Angle between two vectors.

    Me:

    Angle (Rad): 0.7803741
    Angle (Deg): 44.7121424

    Authour:

    Angle (Rad): 0.26
    Angle (Deg): 15.0




    So I guess my Vertex class is working after all then.....Thanks for the help. I was going nuts..


    - ØØ -

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width