3

I was looking over an effect file I found in the DirectX SDK , and the only part that really threw me was the Dot() function. That led me to a Wikipedia page about dot products that made no sense to me. What is a dot product?

Code Monkey
  • 889
  • 3
  • 11
  • 27
  • 1
    That's a maths question, rather than programming. http://math.stackexchange.com/questions/77/understanding-dot-and-cross-product – Orbling Oct 15 '12 at 20:53
  • If you want to do graphics programming, you need a pretty solid understanding of geometry. – Orbling Oct 15 '12 at 20:55

1 Answers1

2

It's defined as the sum of scalar products: e.g. for float3 vectors A and B, dot(A,B) is equal to (A.x*B.x + A.y*B.y + A.z*B.z).

dot products are used by HLSL as components of matrix multiplications, and a nice feature of dot(), if both inputs are normalized, is that dot(A,B) will be equal tot he cosine of the angle between the vectors A & B (used a LOT in lighting)

Proxy
  • 1,824
  • 1
  • 16
  • 27
bjorke
  • 3,295
  • 1
  • 16
  • 20