i am getting strange results and cannot figure out why:
Vel CONTROL (the vector 1,0), and Acc are Vec2D objects, which has X and Y values, and methods such as add, angle between, and other such vector util
particle extends ellipse2d.double updateSuper() simply changes the values for it
OLine extends line2d.double
i cannot remember why the for loop uses object
Vel.Y=-Vel.Y is to correct for java's coordinate system being +=down
i think the problem may be a missed conversion between radians and degrees, but can't find it.
public void move(){
X = X + Vel.X;
Y = Y + Vel.Y;
updateSuper();
Vel.add(acc);
life = life - 0.5;
for(Object l:lines){
OLine ol = (OLine)l;
if(ol.ptSegDist(X,Y)<=radius){
// System.out.println("XVel B: " + Vel.X);
// System.out.println("YVel B: " + Vel.Y);
// System.out.println("XN: " + ol.Normal.X);
// System.out.println("YN: " + ol.Normal.Y);
double normAngle = Vec2d.angleBetween(CONTROL,ol.Normal);
double velAngle = Vec2d.angleBetween(CONTROL,Vel);
double addAngle = Vec2d.angleBetween(ol.Normal,Vel);
double newAngle;
if(ol.Normal.Y<0){
if(ol.Normal.X<0){
normAngle = Math.PI + (Math.PI - normAngle);
} else {
normAngle = Math.PI + normAngle;
}
}
if(Vel.Y<0){
if(Vel.X<0){
velAngle = Math.PI + (Math.PI - velAngle);
} else {
velAngle = Math.PI + velAngle;
}
}
if(velAngle<=normAngle){
newAngle = normAngle + addAngle;
} else {
newAngle = normAngle - addAngle;
}
//Vec2d PVel = Vel.copY();
Vel = new Vec2d((Vel.magnitude())*Math.cos(newAngle),(Vel.magnitude())*Math.sin(newAngle));
Vel.Y = -Vel.Y;
// System.out.println("Nangle: " + Math.toDegrees(normAngle));
// System.out.println("Vangle: " + Math.toDegrees(velAngle));
// System.out.println("Aangle: " + Math.toDegrees(addAngle));
// System.out.println("NEWangle: " + Math.toDegrees(newAngle));
//
// System.out.println("XVel: " + Vel.X);
// System.out.println("YVel: " + Vel.Y);
}
}
}
any questions on the reasoning that may help will be gladly answered.
this is the result i am getting (the red particles originate at the blue point):
i gave up on this a while ago, but after getting my other questions from other projects answered, this came back to my mind, help would be appreciated