class colBox { Vector3D loc, lineh; colBox(){ } void setBox(float theta_, Vector3D loc_) { loc = loc_; pushMatrix(); noFill(); stroke(255); translate(loc_.x,loc_.y); rotate(theta_); beginShape(QUADS); vertex(-10,-50); vertex(-10,10); vertex(10,10); vertex(10,-50); endShape(); popMatrix(); lineh = new Vector3D(0,0); } void setLine(float theta_, Vector3D loc_, Vector3D vel_) { // getting theta already, why vel again? loc = loc_; // Vector3D tempPointer= new Vector3D(30*cos(theta_),30*sin(theta_)); // tempPointer.add(loc); // line(loc.x,loc.y,tempPointer.x,tempPointer.y); fill(255); stroke(255); lineh = vel_.copy(); lineh.normalize(); lineh.mult(50); lineh.add(loc); } void drawLine(float theta_, Vector3D loc_, Vector3D vel_) { loc = loc_; lineh = vel_.copy(); lineh.normalize(); lineh.mult(50); lineh.add(loc); line(loc.x,loc.y,lineh.x,lineh.y); } boolean intersect(Obstacle obstacle) { Vector3D locD = obstacle.loc.copy(); Vector3D d = Vector3D.sub(loc,obstacle.loc); d.normalize(); d.mult(obstacle.mass*2); locD.add(d); float dist = Vector3D.distance(lineh,obstacle.loc); //println(dist); //line(obstacle.x,obstacle.y,locD.x,locD.y); if(dist < obstacle.mass) { // println(obstacle.x); return true; } return false; } }