You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
25 lines
376 B
25 lines
376 B
// Vector Math
|
|
|
|
#include "VMath.h"
|
|
|
|
float DotProduct(PointF v1,PointF v2)
|
|
{
|
|
return v1.X*v2.X+v1.Y*v2.Y;
|
|
}
|
|
|
|
float Magnitude(PointF v)
|
|
{
|
|
return (float)sqrt(DotProduct(v,v));
|
|
}
|
|
|
|
PointF Normalize(PointF vPoint)
|
|
{
|
|
float flDenom;
|
|
PointF vResult;
|
|
|
|
flDenom=Magnitude(vPoint);
|
|
vResult.X=vPoint.X/flDenom;
|
|
vResult.Y=vPoint.Y/flDenom;
|
|
|
|
return vResult;
|
|
}
|