Dismiss Notice
Join Physics Forums Today!
The friendliest, high quality science and math community on the planet! Everyone who loves science is here!

A problem with Dot Product

  1. Aug 8, 2014 #1
    So, is there anyway to make the dot product change linearly? What I mean by this is when the angle is 45 degrees, I want it to be 0.5 instead of 0.7071 as you can see in this image:

    CosineValues.png

    Instead I want 45 degrees to be 0.5, 60 degrees to be 0.33 and 30 degrees to be 0.66. Same would apply for the other side(135 should be -0.5)

    Thank you
     
  2. jcsd
  3. Aug 8, 2014 #2

    HallsofIvy

    User Avatar
    Staff Emeritus
    Science Advisor

    You can redefine it to be anything you like but it wouldn't be the dot product anymore. What is your purpose in wanting to do such a thing?
     
  4. Aug 8, 2014 #3

    jbunniii

    User Avatar
    Science Advisor
    Homework Helper
    Gold Member

    The dot product between two unit vectors is ##\cos(\theta)##. It seems that you just want ##\theta##. So you can compute ##\cos^{-1}(u \cdot v)## if ##u## and ##v## are unit vectors, or ##\cos^{-1}((u/\|u\|) \cdot (v / \|v\|))## in general. The result will be an angle between ##-\pi/2## and ##\pi/2##, which you can then scale as you like. If you want the range to be from ##-1## to ##1##, then multiply by ##2/\pi##.
     
  5. Aug 8, 2014 #4
    I'm trying to make a game and for some reason I thought that the dot product changed consistently with the angle.
     
  6. Aug 8, 2014 #5
    Thank You! I did not know that the dot product is cos!
    :D
     
  7. Aug 9, 2014 #6

    Student100

    User Avatar
    Education Advisor
    Gold Member

    This is an incorrect way to interpret what was said, you missed the unit vector qualifier that would make A dot B = cos(theta) true. Generally the dot product is defined as A dot B = ||A|| ||B||cos(theta). I think if you just defined a switch statement or better yet, a class, to do what you want you could avoid the whole reinventing the dot product here.
     
    Last edited: Aug 9, 2014
Know someone interested in this topic? Share this thread via Reddit, Google+, Twitter, or Facebook




Similar Discussions: A problem with Dot Product
Loading...