• Create Account

### #Actualserumas

Posted 02 October 2012 - 01:56 PM

hmm wrote an answer but it disapeard .
I think maybe your problem is in two places , try to rewrite these places with code below
maybe this helps...


if (v1.active == true && v2.active == true)
{
v1pos -= cv * ((1 - t) * lambda / 2.0f) * fraction;   //   (1-t)/2
v2pos -= cv * (t * lambda / 2.0f) * fraction;	 	 //	 t/2		   ( t+(1-t))/2=1/2   half energy for edge
}
else if (v1.active == false && v2.active == true)
{
v2pos -= cv * (t * lambda/2.0f) * fraction;   	 	 //half energy for edge
}
else if (v1.active == true && v2.active == false)
{
v1pos -= cv * ((1 - t) * lambda/2.0f) * fraction;	 //half energy
}
mpos += cv * fraction/2.0f;				   // if half energy for edge so must leav half energy to m


About mass, ofcouse if mass different , collision will effect diferently for that objects

//redistribute energy to objects with different mass
float c=1/(obj1.invmass+obj2.invmass);
obj1.vec -= obj1.invmass*c/2*collision_vector;
obj2.vec += obj1.invmass*c/2*collision_vector;
//invmas=1/mass;


### #3serumas

Posted 02 October 2012 - 01:55 PM

hmm wrote an answer but it disapeard .
I think maybe your problem is in two places , try to rewrite these places with code below
maybe this helps...


if (v1.active == true && v2.active == true)
{
v1pos -= cv * ((1 - t) * lambda / 2.0f) * fraction;   //   (1-t)/2
v2pos -= cv * (t * lambda / 2.0f) * fraction;	 	 //	 t/2		   ( t+(1-t))/2=1/2   half energy for edge
}
else if (v1.active == false && v2.active == true)
{
v2pos -= cv * (t * lambda/2.0f) * fraction;   	 	 //half energy for edge
}
else if (v1.active == true && v2.active == false)
{
v1pos -= cv * ((1 - t) * lambda/2.0f) * fraction;	 //half energy
}
mpos += cv * fraction/2.0f;				   // if half energy for edge so must leav half energy to m


About mass, ofcouse if mass different , collision will effect diferently for that objects

float c=1/(obj1.invmass+obj2.invmass);
obj1.vec -= obj1.invmass*c/2*collision_vector;
obj2.vec += obj1.invmass*c/2*collision_vector;
//invmas=1/mass;


### #2serumas

Posted 02 October 2012 - 01:54 PM

hmm wrote an answer but it disapeard .
I think maybe your problem is in two places , try to rewrite these places with code below
maybe this helps...


if (v1.active == true && v2.active == true)
{
v1pos -= cv * ((1 - t) * lambda / 2.0f) * fraction;   //   (1-t)/2
v2pos -= cv * (t * lambda / 2.0f) * fraction;	 	 //	 t/2		   ( t+(1-t))/2=1/2   half energy for edge
}
else if (v1.active == false && v2.active == true)
{
v2pos -= cv * (t * lambda/2.0f) * fraction;   	 	 //half energy for edge
}
else if (v1.active == true && v2.active == false)
{
v1pos -= cv * ((1 - t) * lambda/2.0f) * fraction;	 //half energy
}
mpos += cv * fraction/2.0f;				   // if half energy for edge so must leav half energy to m


About mass, ofcouse if mass different , collision will effect diferently for that objects

float c=0.5f/(obj1.invmass+obj2.invmass);
obj1.vec -= obj1.invmass*c ......
obj2.vec += obj1.invmass*c .....
invmas=1/mass;


### #1serumas

Posted 02 October 2012 - 01:50 PM

hmm wrote an answer but it disapeard .
I think maybe your problem is in two places , try to rewrite these places with code below
maybe this helps...


if (v1.active == true && v2.active == true)
{
v1pos -= cv * ((1 - t) * lambda / 2.0f) * fraction;
v2pos -= cv * (t * lambda / 2.0f) * fraction;
mpos += cv * fraction/2.0f;
}
else if (v1.active == false && v2.active == true)
{
v2pos -= cv * (t * lambda) * fraction;
mpos += cv * fraction;
}
else if (v1.active == true && v2.active == false)
{
v1pos -= cv * ((1 - t) * lambda) * fraction;
mpos += cv * fraction;
}



About mass, ofcouse if mass different , collision will effect diferently for that objects

float c=0.5f/(obj1.invmass+obj2.invmass);
obj1.vec -= obj1.invmass*c ......
obj2.vec += obj1.invmass*c .....
invmas=1/mass;


PARTNERS