Go to the documentation of this file. 37 #define EQUAL(a,b) (fabsf((a)-(b))<0.0000000001f) 40 #define Vector2FromInt(x, y) { static_cast<float>(x), static_cast<float>(y) } 41 #define Vector3FromInt(x, y, z) { static_cast<float>(x), static_cast<float>(y), static_cast<float>(z) } 44 #define DotProduct(x,y) ((x)[0]*(y)[0]+(x)[1]*(y)[1]+(x)[2]*(y)[2]) 45 #define VectorSubtract(a,b,dest) ((dest)[0]=(a)[0]-(b)[0],(dest)[1]=(a)[1]-(b)[1],(dest)[2]=(a)[2]-(b)[2]) 46 #define Vector2Subtract(a,b,dest) ((dest)[0]=(a)[0]-(b)[0],(dest)[1]=(a)[1]-(b)[1]) 47 #define VectorAdd(a,b,dest) ((dest)[0]=(a)[0]+(b)[0],(dest)[1]=(a)[1]+(b)[1],(dest)[2]=(a)[2]+(b)[2]) 48 #define VectorMul(scalar,b,dest) ((dest)[0]=(scalar)*(b)[0],(dest)[1]=(scalar)*(b)[1],(dest)[2]=(scalar)*(b)[2]) 49 #define Vector2Mul(scalar,b,dest) ((c)[0]=(scalar)*(b)[0],(dest)[1]=(scalar)*(b)[1]) 50 #define VectorDiv(in,scalar,out) VectorScale((in),(1.0f/(scalar)),(out)) 51 #define VectorCopy(src,dest) ((dest)[0]=(src)[0],(dest)[1]=(src)[1],(dest)[2]=(src)[2]) 52 #define Vector2Copy(src,dest) ((dest)[0]=(src)[0],(dest)[1]=(src)[1]) 53 #define Vector4Copy(src,dest) ((dest)[0]=(src)[0],(dest)[1]=(src)[1],(dest)[2]=(src)[2],(dest)[3]=(src)[3]) 54 #define Vector2Clear(a) ((a)[0]=(a)[1]=0) 55 #define VectorClear(a) ((a)[0]=(a)[1]=(a)[2]=0) 56 #define VectorInside(vec,mins,maxs) (vec[0] >= mins[0] && vec[0] <= maxs[0] && vec[1] >= mins[1] && vec[1] <= maxs[1] && vec[2] >= mins[2] && vec[2] <= maxs[2]) 57 #define Vector4Clear(a) ((a)[0]=(a)[1]=(a)[2]=(a)[3]=0) 58 #define VectorNegate(src,dest) ((dest)[0]=-(src)[0],(dest)[1]=-(src)[1],(dest)[2]=-(src)[2]) 59 #define VectorSet(v, x, y, z) ((v)[0]=(x), (v)[1]=(y), (v)[2]=(z)) 60 #define VectorSum(a) ((a)[0]+(a)[1]+(a)[2]) 61 #define Vector2Set(v, x, y) ((v)[0]=(x), (v)[1]=(y)) 62 #define Vector4Set(v, r, g, b, a) ((v)[0]=(r), (v)[1]=(g), (v)[2]=(b), (v)[3]=(a)) 63 #define VectorCompare(a,b) ((a)[0]==(b)[0]?(a)[1]==(b)[1]?(a)[2]==(b)[2]?true:false:false:false) 64 #define VectorEqualEpsilon(a,b,epsilon) (EQUAL2((a)[0],(b)[0],epsilon)?EQUAL2((a)[1],(b)[1],epsilon)?EQUAL2((a)[2],(b)[2],epsilon)?true:false:false:false) 65 #define VectorEqual(a,b) (EQUAL((a)[0],(b)[0])?EQUAL((a)[1],(b)[1])?EQUAL((a)[2],(b)[2])?true:false:false:false) 66 #define Vector2Compare(a,b) ((a)[0]==(b)[0]?(a)[1]==(b)[1]?true:false:false) 67 #define Vector2Equal(a,b) (EQUAL((a)[0],(b)[0])?EQUAL((a)[1],(b)[1])?true:false:false) 68 #define VectorDistSqr(a,b) (((b)[0]-(a)[0])*((b)[0]-(a)[0])+((b)[1]-(a)[1])*((b)[1]-(a)[1])+((b)[2]-(a)[2])*((b)[2]-(a)[2])) 69 #define VectorDist(a,b) (sqrtf(((b)[0]-(a)[0])*((b)[0]-(a)[0])+((b)[1]-(a)[1])*((b)[1]-(a)[1])+((b)[2]-(a)[2])*((b)[2]-(a)[2]))) 70 #define Vector2Dist(a,b) (sqrtf(((b)[0]-(a)[0])*((b)[0]-(a)[0])+((b)[1]-(a)[1])*((b)[1]-(a)[1]))) 71 #define VectorLengthSqr(a) ((a)[0]*(a)[0]+(a)[1]*(a)[1]+(a)[2]*(a)[2]) 72 #define VectorNotEmpty(a) (!VectorEmpty((a))) 73 #define VectorEmpty(a) (VectorEqual((a), vec3_origin)) 74 #define Vector2Empty(a) (Vector2Equal((a), vec2_origin)) 75 #define Vector2NotEmpty(a) (!Vector2Empty((a))) 76 #define Vector4NotEmpty(a) (VectorNotEmpty(a) || !EQUAL((a)[3],0.0f)) 77 #define VectorIntZero(a) ((a)[0] == 0 && (a)[1] == 0 && (a)[2] == 0) 78 #define LinearInterpolation(a, b, x, y) ((y)=(a)[1] + ((((x) - (a)[0]) * ((b)[1] - (a)[1])) / ((b)[0] - (a)[0]))) 79 #define VectorScale(in,scale,out) ((out)[0] = (in)[0] * (scale),(out)[1] = (in)[1] * (scale),(out)[2] = (in)[2] * (scale)) 80 #define VectorInterpolation(p1,p2,frac,mid) ((mid)[0]=(p1)[0]+(frac)*((p2)[0]-(p1)[0]),(mid)[1]=(p1)[1]+(frac)*((p2)[1]-(p1)[1]),(mid)[2]=(p1)[2]+(frac)*((p2)[2]-(p1)[2])) 81 #define VectorAbs(a) (a[0] = fabsf(a[0]), a[1] = fabsf(a[1]), a[2] = fabsf(a[2]))