Skip to main content
10 events
when toggle format what by license comment
Nov 13, 2020 at 20:03 comment added DMGregory These two expressions are equivalent for objects on the direct line through the center of the camera's lens. But if the object is off to the side or a corner of the camera's view, then its separation vector isn't pointing fully in the same direction as CameraDir, so you would underestimate the diagonal distance to it by counting only the component parallel to the camera's axis and not the component perpendicular.. If you want a measure of "depth" from the camera though, like what's stored in a depth buffer, the dot product will get you that.
Nov 13, 2020 at 19:58 comment added Raildex I have a camera direction vector and arbitrary positions of objects. instead of using Length(Object-Camera) I can use Dot(CameraDir,Object-Camera)?
Nov 13, 2020 at 18:30 comment added DMGregory @Raildex If you know in advance the direction you want to measure distance in, yes. You need to have already prepared a unit vector in that direction though; if you try to make a unit vector on the fly, that costs a sqrt anyway. But if you have such a perfectly-aligned unit vector set aside in advance, you've effectively precomputed the sqrt and cached the result so you don't have to re-compute it.
Nov 13, 2020 at 18:22 comment added Raildex doest that mean that i can use dot product to calculate a distance instead of using sqrt?
Nov 13, 2020 at 13:13 history edited doppelgreener CC BY-SA 4.0
added mathjax: https://gamedev.meta.stackexchange.com/questions/2588/mathjax-latex-in-posts-has-been-added-lets-make-some-math
Oct 23, 2015 at 17:48 comment added Jonathan Mee +1 for "If you have one unit vector U and one arbitrary vector V, you can interpret the dot product as the length of the projection of V onto U"
Dec 21, 2014 at 3:35 vote accept JesseTG
Dec 21, 2014 at 3:35 vote accept JesseTG
Dec 21, 2014 at 3:35
Dec 17, 2014 at 3:26 history edited DMGregory CC BY-SA 3.0
Correcting leftover reference to non-existent diagram.
Dec 17, 2014 at 3:17 history answered DMGregory CC BY-SA 3.0