IonicWind Software

Aurora Compiler => 2D Graphics => Topic started by: J B Wood (Zumwalt) on September 01, 2006, 09:56:26 PM

Title: Started V2 Class
Post by: J B Wood (Zumwalt) on September 01, 2006, 09:56:26 PM
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;
}
Title: Re: Started V2 Class
Post by: kryton9 on September 01, 2006, 10:03:39 PM
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.
Title: Re: Started V2 Class
Post by: J B Wood (Zumwalt) on September 01, 2006, 10:06:53 PM
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.
Title: Re: Started V2 Class
Post by: kryton9 on September 01, 2006, 10:08:19 PM
I think ()^2ÂÃ,  ÂÃ, works also. instead of pow
Title: Re: Started V2 Class
Post by: Ionic Wind Support Team on September 01, 2006, 10:46:41 PM
Yes.  ^ is power just like in basic languages.  Would be faster too.