Ok, so I have basically completely rewritten my ball class. Not everything is completed, but I've done a lot of research and read a lot of things in the very few spare hours I have in the evenings, and I've tried to make this as realistic as possible. So before I go any further, I'd really like to know exactly which parts that I have so far that are correct, which parts are wrong, and which parts are just beyond totally fucked up, lol. For the parts that are wrong or fucked up, let me know why, and the best way to fix it. So, with all of that being said, here goes:
class ball
{
float x, y, z;
float IG;
float roh;
float A;
float cd;
float FL;
int slot;
ball()
{
vector position;
vector NetF; //force
vector vel; //final velocity
vector acc; //acceleration
vector l1; //current location of ball
vector l2; //location 2, where the ball comes to rest;
vector c; //the court surface
vector d; //distance
}
ball(float x, float y, float z, float IG, float roh, float a, float cd, float FL, int slot)
{
this.x = x;
this.y = y;
this.z = z;
this.IG = IG;
this.roh = roh;
this.A = A;
this.cd = cd;
this.FL = FL;
this.slot = slot;
vector position(0, 0, 0);
vector NetF(0, 0, 0);
vector vel(0, 0, 0);
vector acc(0, 0, 0);
vector l1(0, 0, 0);
vector l2(0, 0, 0);
vector c(0, 0, 0);
vector d(0, 0, 0);
}
//get distance between two vectors
float GetDistance(vector@ V1, vector@ V2)
{
v.x = v1.x - v2.x;
v.y = v1.y - v2.y;
v.z = v1.z - v2.z;
return d = square_root(power(v.x,2)+power(v.y,2)+power(v.z,2));
}
//calculate initial gravitational force given altitude
float IGForce()
{
float M1 = 5.972*1024; //mass of the earth
float M2 = 0.057; //mass of the ball
float G = (6.6742*power(10, -11)*M1*M2)/(power(d.z,2));
float gtv = 9.81;
if (IG >= GTV)
return;
else if(IG < GTV)
{
return d = GetDistance(L1, C)
return IG = (G*M1*M2)/power(d,2);
}
}
//calculate drag and lift forces
float GetDL()
{
float CD = 0.507; //drag coefficient
float CL = 0.6; //lift coefficient
roh = 1.151; //air density
A = 0.0033; //projected area of the ball
return float drag = CD*A*0.5*roh*power(vel,2);
return float lift = FL*A*0.5*roh*power(vel,2);
}
//calculate impulse and momentum
float ImpF()
{
return float imp = NetF*DT;
return float mom = M2*vel;
}
//calculate net force
{
NetF((strength*CT)+imp+lift-drag-IG)*cos(theta), (strength*CT)+imp+lift-drag-IG)*sin(theta), -IG*sin(theta));
acc = NetF/M2;
}
void move(double DT)
{
vel += pos*DT;
pos += vel*DT;
}
...
I look forward to your reply. Thanks.
JLove