I am starting this class along with my V3 class to add some more functionality to both 3d and 2d.
Small but needed item, distance2d, first and only method in the class at the moment:
V2.inc
class V2
{
declare V2();
declare _V2();
declare distance2D(VECTOR2 P1, VECTOR2 P2),float;
}
V2.src
declare cdecl import, pow(double x, double y),double;
#include "V2.inc"
V2 :: V2()
{
}
V2 :: _V2()
{
}
V2 :: distance2D(VECTOR2 P1, VECTOR2 P2), float
{
float resD2D;
resD2D = sqrt(pow(P1.y - P2.y,2) + pow(P1.x - P2.x,2));
return resD2D;
}
Cool, I read that 3d distance is the same, so with an optional flag it could do either
declare Distance(point p1, point p2, opt int flag);
if (flag 3) resD2D = sqrt(pow(P1.y - P2.y,2) + pow(P1.x - P2.x,2)+ pow(P1.z - P2.z,2));
if (flag 2) resD2D = sqrt(pow(P1.y - P2.y,2) + pow(P1.x - P2.x,2));
for example.
Yea the formula is about the same going to add that to my V3 class
sqrt(pow(x2-x1,2)+pow(y2-y1,2)+pow(z2-z1,2))
Key thing to note is the import of the pow math command, makes things simpler.
I think ()^2ÂÃ, Ã‚Ã, works also. instead of pow
Yes. ^ is power just like in basic languages. Would be faster too.