








Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
This page cannot be seen from the preview
Don't miss anything!









The dot product is a scalar value that tells
us something about the relationship
between two vectors
If a b > 0 then _ < 90º
If a b < 0 then _ > 90º
If a b = 0 then _ = 90º (or one or more of
the vectors is degenerate (0,0,0))
a
u
a u
If | u |=1.0 then a · u is the length of the projection
of a onto u
The distance is the length of the projection
of x - p onto n :
p
n
- x
x-p
dist = ( x − p )⋅ n
Dot Products with Unit Vectors
b
_ a
a b = 0
0 < a b <
a b = -
a b = 1
-1 < a b <
cos ( θ )
a
b
0
sin
× =
× =
× =
×
a b
a b
a b a b
a b
θ
area of parallelogram ab
is a vector perpendicular to both
a and b , in the direction defined by
the right hand rule
if a and b are parallel
Find the unit length normal of the triangle
defined by 3D points a , b , and c
a
b
c
Find the area of the triangle defined by 3D
points a , b , and c
a
b
c
= ( b − a )× ( c − a )
b-a
c-a
a
b
c
Example: Alignment to Target
p
h
t t-p
_
a
( )
( )
( )
( )
−
1
θ cos
Vector Class
class Vector3 {
public:
Vector3() {x=0.0f; y=0.0f; z=0.0f;}
Vector3(float x0,float y0,float z0) {x=x0; y=y0; z=z0;}
void Set(float x0,float y0,float z0) {x=x0; y=y0; z=z0;}
void Add(Vector3 &a) {x+=a.x; y+=a.y; z+=a.z;}
void Add(Vector3 &a,Vector3 &b) {x=a.x+b.x; y=a.y+b.y; z=a.z+b.z;}
void Subtract(Vector3 &a) {x-=a.x; y-=a.y; z-=a.z;}
void Subtract(Vector3 &a,Vector3 &b) {x=a.x-b.x; y=a.y-b.y; z=a.z-b.z;}
void Negate() {x=-x; y=-y; z=-z;}
void Negate(Vector3 &a) {x=-a.x; y=-a.y; z=-a.z;}
void Scale(float s) {x=s; y=s; z*=s;}
void Scale(float s,Vector3 &a) {x=sa.x; y=sa.y; z=s*a.z;}
float Dot(Vector3 &a) {return xa.x+ya.y+z*a.z;}
void Cross(Vector3 &a,Vector3 &b)
{x=a.yb.z-a.zb.y; y=a.zb.x-a.xb.z; z=a.xb.y-a.yb.x;}
float Magnitude() {return sqrtf(xx+yy+z*z);}
void Normalize() {Scale(1.0f/Magnitude());}
float x,y,z;
};