OpenGL VRML W3D            
  Home Tutorials Books Applications Tools Docs Models Textures  

 

              Bugs

3D Maths for CG   

  3D Maths for CG

Index

Vectors
Cross Product
Dot Product
Vector Projection

Lines Rays and Planes
Lines and Rays
Planes

Intersection
Ray Sphere Intersecion
Ray Triangle Intersection

Interpolation
Catmull-Rom Spline


Google

OpenGLTutorials @ Lighthouse3d.com

Led Shader
View Frustum Culling
GLSL Tutorial
Maths Tutorial
Billboarding Tutorial
Picking Tutorial
Terrain Tutorial
Display Lists Tutorial
GLUT Tutorial

   
[Previous: Cross Product] [Next: Vector Projection]

3D Maths for CG


Vectors - Dot Product


The dot product, aka inner product, takes two vectors and returns a scalar value. It is an easy way to find the cosine between two vectors. The equations bellow show the necessary steps to compute the inner product v, of two vectors v1 and v2. The operation is commonly represented by ".".


    	v1 . v2 = v1x*v2x + v1y*v2y + v1z*v2z



The relation between the cosine of the angle between v1 and v2 is given by


    	v1.v2 = |v1| |v2| * cos(a)


From the above we also know that the inner product of two vectors is 0 (zero) either if any of the vectors is null, or if the vectors are orthogonal, i.e. the angle is 90 degrees (see also the cross product). Bellow is a list of some properties of the inner product:


    	v1 . v2 = v2 . v1	

	v1 . (v2 + v3) = (v1 . v2) + (v1 . v3) 


The inner product can be defined as a macro in C:


    	#define innerProduct(v,q) \
		((v)[0] * (q)[0] + \
		(v)[1] * (q)[1] + \
		(v)[2] * (q)[2])	



[Previous: Cross Product] [Next: Vector Projection]

       


Site designed and maintained by António Ramires Fernandes
Your comments, suggestions and references to further material are welcome!

Lighthouse 3D privacy statement