Can the Dot Product be Customized to Change Linearly?

Join the discussion
Registration is free. Ask a follow-up in this thread, or start your own.
5 replies · 2K views
aosome23
Messages
16
Reaction score
0
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
 
Physics news on Phys.org
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##.
 
  • Like
Likes   Reactions: 1 person
HallsofIvy said:
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?

I'm trying to make a game and for some reason I thought that the dot product changed consistently with the angle.
 
jbunniii said:
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##.

Thank You! I did not know that the dot product is cos!
:D
 
aosome23 said:
Thank You! I did not know that the dot product is cos!
:D

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: