MouseListen();
mousePressed=false;
}
if (dClicked=="Clicked")
{
text("Now input on the keyboard your vehicle type - a for lorry, b for car or c for pedestrian",150,150);
text("You want the most vehicles on the bridge without causing excessive bending stresses - be careful!",200,150);
KeyListen();
keyPressed=false;
if (VSelect=="Incomplete")
{
background(139,139,139);
text("Please input a proper vehicle type - a for lorry, b for car or c for pedestrian",150,150);
KeyListen();
keyPressed=false;
}
background(139,139,139);
VSelect="Round1";
text("Select where on the bridge you want your vehicle",150,150);
text("Or press 2 to rotate your chosen vehicle - remember you're aiming for low stress!",200,150);
KeyListen();
keyPressed=false;
if (VehicleType=="Lorry")
{
if (RotateVehicle=="NoRotate")
{
rect(mouseX,mouseY,330,50);
}
if (RotateVehicle=="YesRotate")
{
rect(mouseX,mouseY,50,330);
}
MouseListen();
mousePressed=false;
V1type=1;
V1m=3500;
V1rad=150;
}
if (VehicleType=="Car")
{
if (RotateVehicle=="NoRotate")
{
rect(mouseX,mouseY,126,48);
}
if (RotateVehicle=="YesRotate")
{
rect(mouseX,mouseY,48,126);
}
MouseListen();
mousePressed=false;
V1type=2;
V1m=1200;
V1rad=60;
}
if (VehicleType=="Ped")
{
if (RotateVehicle=="NoRotate")
{
ellipse(mouseX,mouseY,88,23.2);
}
if (RotateVehicle=="YesRotate")
{
ellipse(mouseX,mouseY,23.2,88);
}
MouseListen();
mousePressed=false;
V1type=3;
V1m=100;
V1rad=7;
}
background(139,139,139);
RotateVehicle="NoRotate";
text("Select your second vehicle type - a for lorry, b for car or c for pedestrian",150,150);
text("Or press 1 to exit vehicle input",200,150);
KeyListen();
keyPressed=false;
if (VSelect=="Incomplete")
{
background(139,139,139);
text("Please input a proper vehicle type - a for lorry, b for car or c for pedestrian",150,150);
KeyListen();
keyPressed=false;
}
VSelect="Round2";
background(139,139,139);
text("Select where on the bridge you want your second vehicle",150,150);
text("Vehicle 1",V1x,V1y);
triangle((V1x-15),(V1y-15),(V1x+15),(V1y-15),V1x,(V1y+15));
text("Or press 2 to rotate your chosen vehicle - remember you're aiming for low stress!",200,150);
KeyListen();
keyPressed=false;
if (VehicleType=="Lorry")
{
if (RotateVehicle=="NoRotate")
{
rect(mouseX,mouseY,330,50);
}
if (RotateVehicle=="YesRotate")
{
rect(mouseX,mouseY,50,330);
}
MouseListen();
mousePressed=false;
V2type=1;
V2m=3500;
V2rad=150;
}
if (VehicleType=="Car")
{
if (RotateVehicle=="NoRotate")
{
rect(mouseX,mouseY,126,48);
}
if (RotateVehicle=="YesRotate")
{
rect(mouseX,mouseY,48,126);
}
MouseListen();
mousePressed=false;
V2type=2;
V2m=1200;
V2rad=60;
}
if (VehicleType=="Ped")
{
if (RotateVehicle=="NoRotate")
{
ellipse(mouseX,mouseY,88,23.2);
}
if (RotateVehicle=="YesRotate")
{
ellipse(mouseX,mouseY,23.2,88);
}
MouseListen();
mousePressed=false;
V2type=3;
V2m=100;
V2rad=7;
}
RotateVehicle="NoRotate";
text("Select your third vehicle type - a for lorry, b for car or c for pedestrian",150,150);
text("Or press 1 to exit vehicle input",200,150);
KeyListen();
keyPressed=false;
if (VSelect=="Incomplete")
{
background(139,139,139);
text("Please input a proper vehicle type - a for lorry, b for car or c for pedestrian",150,150);
KeyListen();
keyPressed=false;
}
VSelect="Round3";
background(139,139,139);
text("Select where on the bridge you want your third vehicle",150,150);
text("Vehicle 1",V1x,V1y);
triangle((V1x-15),(V1y-15),(V1x+15),(V1y-15),V1x,(V1y+15));
text("Vehicle 2",V2x,V2y);
triangle((V2x-15),(V2y-15),(V2x+15),(V2y-15),V2x,(V2y+15));
text("Or press 2 to rotate your chosen vehicle - remember you're aiming for low stress!",200,150);
KeyListen();
keyPressed=false;
if (VehicleType=="Lorry")
{
if (RotateVehicle=="NoRotate")
{
rect(mouseX,mouseY,330,50);
}
if (RotateVehicle=="YesRotate")
{
rect(mouseX,mouseY,50,330);
}
MouseListen();
mousePressed=false;
V3type=1;
V3m=3500;
V3rad=150;
}
if (VehicleType=="Car")
{
if (RotateVehicle=="NoRotate")
{
rect(mouseX,mouseY,126,48);
}
if (RotateVehicle=="YesRotate")
{
rect(mouseX,mouseY,48,126);
}
MouseListen();
mousePressed=false;
V3type=2;
V3m=1200;
V3rad=60;
}
if (VehicleType=="Ped")
{
if (RotateVehicle=="NoRotate")
{
ellipse(mouseX,mouseY,88,23.2);
}
if (RotateVehicle=="YesRotate")
{
ellipse(mouseX,mouseY,23.2,88);
}
MouseListen();
mousePressed=false;
V3type=3;
V3m=100;
V3rad=7;
}
RotateVehicle="NoRotate";
text("Select your fourth vehicle type - a for lorry, b for car or c for pedestrian",150,150);
text("Or press 1 to exit vehicle input",200,150);
KeyListen();
keyPressed=false;
if (VSelect=="Incomplete")
{
background(139,139,139);
text("Please input a proper vehicle type - a for lorry, b for car or c for pedestrian",150,150);
KeyListen();
keyPressed=false;
}
VSelect="Round4";
background(139,139,139);
text("Select where on the bridge you want your fourth vehicle, ",150,150);
text("Vehicle 1",V1x,V1y);
triangle((V1x-15),(V1y-15),(V1x+15),(V1y-15),V1x,(V1y+15));
text("Vehicle 2",V2x,V2y);
triangle((V2x-15),(V2y-15),(V2x+15),(V2y-15),V2x,(V2y+15));
text("Vehicle 3",V3x,V3y);
triangle((V3x-15),(V3y-15),(V3x+15),(V3y-15),V3x,(V3y+15));
text("Or press 2 to rotate your chosen vehicle - remember you're aiming for low stress!",200,150);
keyListen();
keyPressed=false;
if (VehicleType=="Lorry")
{
if (RotateVehicle=="NoRotate")
{
rect(mouseX,mouseY,330,50);
}
if (RotateVehicle=="YesRotate")
{
rect(mouseX,mouseY,50,330);
}
MouseListen();
mousePressed=false;
V4type=1;
V4m=3500;
V4rad=150;
}
if (VehicleType=="Car")
{
if (RotateVehicle=="NoRotate")
{
rect(mouseX,mouseY,126,48);
}
if (RotateVehicle=="YesRotate")
{
rect(mouseX,mouseY,48,126);
}
MouseListen();
mousePressed=false;
V4type=2;
V4m=1200;
V4rad=60;
}
if (VehicleType=="Ped")
{
if (RotateVehicle=="NoRotate")
{
ellipse(mouseX,mouseY,88,23.2);
}
if (RotateVehicle=="YesRotate")
{
ellipse(mouseX,mouseY,23.2,88);
}
MouseListen();
mousePressed=false;
V4type=3;
V4m=100;
V4rad=7;
}
RotateVehicle="NoRotate";
text("Select your final vehicle type - a for lorry, b for car or c for pedestrian",150,150);
text("Or press 1 to exit vehicle input",200,150);
KeyListen();
keyPressed=false;
if (VSelect=="Incomplete")
{
background(139,139,139);
text("Please input a proper vehicle type - a for lorry, b for car or c for pedestrian",150,150);
KeyListen();
keyPressed=false;
}
VSelect="Round5";
background(139,139,139);
text("Select where on the bridge you want your final vehicle, ",150,150);
text("Vehicle 1",V1x,V1y);
triangle((V1x-15),(V1y-15),(V1x+15),(V1y-15),V1x,(V1y+15));
text("Vehicle 2",V2x,V2y);
triangle((V2x-15),(V2y-15),(V2x+15),(V2y-15),V2x,(V2y+15));
text("Vehicle 3",V3x,V3y);
triangle((V3x-15),(V3y-15),(V3x+15),(V3y-15),V3x,(V3y+15));
text("Vehicle 4",V4x,V4y);
triangle((V4x-15),(V4y-15),(V4x+15),(V4y-15),V4x,(V4y+15));
text("Or press 2 to rotate your chosen vehicle - remember you're aiming for low stress!",200,150);
KeyListen();
keyPressed=false;
if (VehicleType=="Lorry")
{
if (RotateVehicle=="NoRotate")
{
rect(mouseX,mouseY,330,50);
}
if (RotateVehicle=="YesRotate")
{
rect(mouseX,mouseY,50,330);
}
MouseListen();
mousePressed=false;
V5type=1;
V5m=3500;
V5rad=150;
}
if (VehicleType=="Car")
{
if (RotateVehicle=="NoRotate")
{
rect(mouseX,mouseY,126,48);
}
if (RotateVehicle=="YesRotate")
{
rect(mouseX,mouseY,48,126);
}
MouseListen();
mousePressed=false;
V5type=2;
V5m=1200;
V5rad=60;
}
if (VehicleType=="Ped")
{
if (RotateVehicle=="NoRotate")
{
ellipse(mouseX,mouseY,88,23.2);
}
if (RotateVehicle=="YesRotate")
{
ellipse(mouseX,mouseY,23.2,88);
}
MouseListen();
mousePressed=false;
V5type=3;
V5m=100;
V5rad=7;
}
background(139,139,139);
text("No further vehicle input allowed",150,150);
FinishInput();
}
}
void FinishInput()
{
CheckVehicleClash();
background(116,108,250);
text("You've inputted all your vehicles. Press 0 to calculate the arch forces.",150,150);
KeyListen();
keyPressed=false;
if (dCalc=="Calculate")
{
ArchRad=(Blength/2);
VehicleGeometry();
ArchGeometry();
LoadArch();
BridgeOutput();
}
else
{
text("Your vehicle input has been stored, but no calculations carried out. Thank you and goodbye.",150,150);
exit();
}
}
void CheckVehicleClash()
// allowing a 30m distance between vehicles in both directions
{
if (abs(V1x-V2x)<30)
{
ClashScreenSetup();
}
if (abs(V1x-V3x)<30)
{
ClashScreenSetup();
}
if (abs(V1x-V4x)<30)
{
ClashScreenSetup();
}
if (abs(V1x-V5x)<30)
{
ClashScreenSetup();
}
if (abs(V2x-V3x)<30)
{
ClashScreenSetup();
}
if (abs(V2x-V4x)<30)
{
ClashScreenSetup();
}
if (abs(V2x-V5x)<30)
{
ClashScreenSetup();
}
if (abs(V3x-V4x)<30)
{
ClashScreenSetup();
}
if (abs(V3x-V5x)<30)
{
ClashScreenSetup();
}
if (abs(V4x-V5x)<30)
{
ClashScreenSetup();
}
}
void ClashScreenSetup()
{
background(232,28,28);
text("Vehicles clash. Please recomplete vehicle input and ensure sufficient spacing.",150,150);
text("Press z to restart.",300,150);
}
void VehicleGeometry()
{
l1x=(V1x/1000)*Blength;
w1y=(V1y/400)*Bwidth;
l2x=(V2x/1000)*Blength;
w2y=(V2y/400)*Bwidth;
l3x=(V3x/1000)*Blength;
w3y=(V3y/400)*Bwidth;
l4x=(V4x/1000)*Blength;
w4y=(V4y/400)*Bwidth;
l5x=(V5x/1000)*Blength;
w5y=(V5y/400)*Bwidth;
V1z=sqrt(sq(ArchRad)+sq(ArchRad-V1x));
V2z=sqrt(sq(ArchRad)+sq(ArchRad-V2x));
V3z=sqrt(sq(ArchRad)+sq(ArchRad-V3x));
V4z=sqrt(sq(ArchRad)+sq(ArchRad-V4x));
V5z=sqrt(sq(ArchRad)+sq(ArchRad-V5x));
thetaV1=atan(V1z/l1x);
thetaV2=atan(V2z/l2x);
thetaV3=atan(V3z/l3x);
thetaV4=atan(V4z/l4x);
thetaV5=atan(V5z/l5x);
}
void ArchGeometry()
{
segments=9;
// using a span to rise ratio of 0.4 for a parabolic arch shape (according to MEXE method)
ArchHeight=(0.4*Blength);
deltaX = Blength/segments;
deltaZ=(ArchHeight/(segments/2));
A1x=0;
A2x=A1x+deltaX;
A3x=A2x+deltaX;
A4x=A3x+deltaX;
A5x=A4x+deltaX;
A6x=A5x+deltaX;
A7x=A6x+deltaX;
A8x=A7x+deltaX;
A9x=A8x+deltaX;
A1z=0;
A2z=A1z+deltaZ;
A3z=A2z+deltaZ;
A4z=A3z+deltaZ;
A5z=A4z+deltaZ;
A6z=A5z-deltaZ;
A7z=A6z-deltaZ;
A8z=A7z-deltaZ;
A9z=0;
thetaA1=atan(A1z/A1x);
thetaA2=atan(A2z/A2x);
thetaA3=atan(A3z/A3x);
thetaA4=atan(A4z/A4x);
thetaA5=atan(A5z/A5x);
thetaA6=atan(A6z/A6x);
thetaA7=atan(A7z/A7x);
thetaA8=atan(A8z/A8x);
thetaA9=atan(A9z/A9x);
}
void LoadArch()
{
SimplySupportM();
LateralForceEffects();
// calculating moments based on superposition of simply supported moments and horizontal thrust lever arm
A1Mom=A1SMom-(A1Horz*A1z);
A2Mom=A2SMom-(A2Horz*A2z);
A3Mom=A3SMom-(A3Horz*A3z);
A4Mom=A4SMom-(A4Horz*A4z);
A5Mom=A5SMom-(A5Horz*A5z);
A6Mom=A6SMom-(A6Horz*A6z);
A7Mom=A7SMom-(A7Horz*A7z);
A8Mom=A8SMom-(A8Horz*A8z);
A9Mom=A9SMom-(A9Horz*A9z);
// calculating stress based on (My/I), with standard masonry brick dimensions of 65mm high, 102.5mm wide and 215mm long
Bricky=0.3;
BrickI=((1.025*(0.65*0.65*0.65))/12);
A1Stress=(A1Mom*Bricky)/BrickI;
A2Stress=(A2Mom*Bricky)/BrickI;
A3Stress=(A3Mom*Bricky)/BrickI;
A4Stress=(A4Mom*Bricky)/BrickI;
A5Stress=(A5Mom*Bricky)/BrickI;
A6Stress=(A6Mom*Bricky)/BrickI;
A7Stress=(A7Mom*Bricky)/BrickI;
A8Stress=(A8Mom*Bricky)/BrickI;
A9Stress=(A9Mom*Bricky)/BrickI;
}
void SimplySupportM()
{
// calculating the forces for a simply supported beam with the flattened arch geometry
TotalLoad=((V1m+V2m+V3m+V4m+V5m)*gravity);
VSupport=(TotalLoad/2);
MaxMom=(VSupport*ArchRad);
A1SMom=0;
A2SMom=((ArchRad-A2x)/ArchRad)*MaxMom;
A3SMom=((ArchRad-A3x)/ArchRad)*MaxMom;
A4SMom=((ArchRad-A4x)/ArchRad)*MaxMom;
A5SMom=MaxMom;
A6SMom=((A6x-ArchRad)/ArchRad)*MaxMom;
A7SMom=((A7x-ArchRad)/ArchRad)*MaxMom;
A8SMom=((A8x-ArchRad)/ArchRad)*MaxMom;
A9SMom=0;
if (l1x>ArchRad)
{
V1SMom=((l1x-ArchRad)/ArchRad)*MaxMom;
}
else
{
V1SMom=((ArchRad-l1x)/ArchRad)*MaxMom;
}
if (l2x>ArchRad)
{
V2SMom=((l2x-ArchRad)/ArchRad)*MaxMom;
}
else
{
V2SMom=((ArchRad-l2x)/ArchRad)*MaxMom;
}
if (l3x>ArchRad)
{
V3SMom=((l3x-ArchRad)/ArchRad)*MaxMom;
}
else
{
V3SMom=((ArchRad-l3x)/ArchRad)*MaxMom;
}
if (l4x>ArchRad)
{
V4SMom=((l4x-ArchRad)/ArchRad)*MaxMom;
}
else
{
V4SMom=((ArchRad-l4x)/ArchRad)*MaxMom;
}
if (l5x>ArchRad)
{
V5SMom=((l5x-ArchRad)/ArchRad)*MaxMom;
}
else
{
V5SMom=((ArchRad-l5x)/ArchRad)*MaxMom;
}
}
void LateralForceEffects()
{
// calculating the horizontal component as thrust , then converting this into component force in the horizontal (x) and vertical (y) planes to calculate additional moment and shear
Thrust=(MaxMom/ArchHeight);
V1Horz=cos(thetaV1)*Thrust;
V1Vert=sin(thetaV1)*Thrust;
V2Horz=cos(thetaV2)*Thrust;
V2Vert=sin(thetaV2)*Thrust;
V3Horz=cos(thetaV3)*Thrust;
V3Vert=sin(thetaV3)*Thrust;
V4Horz=cos(thetaV4)*Thrust;
V4Vert=sin(thetaV4)*Thrust;
V5Horz=cos(thetaV5)*Thrust;
V5Vert=sin(thetaV5)*Thrust;
A1Horz=cos(thetaA1)*Thrust;
A1Vert=sin(thetaA1)*Thrust;
A2Horz=cos(thetaA2)*Thrust;
A2Vert=sin(thetaA2)*Thrust;
A3Horz=cos(thetaA3)*Thrust;
A3Vert=sin(thetaA3)*Thrust;
A4Horz=cos(thetaA4)*Thrust;
A4Vert=sin(thetaA4)*Thrust;
A5Horz=cos(thetaA5)*Thrust;
A5Vert=sin(thetaA5)*Thrust;
A6Horz=cos(thetaA6)*Thrust;
A6Vert=sin(thetaA6)*Thrust;
A7Horz=cos(thetaA7)*Thrust;
A7Vert=sin(thetaA7)*Thrust;
A8Horz=cos(thetaA8)*Thrust;
A8Vert=sin(thetaA8)*Thrust;
A9Horz=cos(thetaA9)*Thrust;
A9Vert=sin(thetaA9)*Thrust;
}
void BridgeOutput()
{
line(A1x,A2x,A1z,A2z);
line(A2x,A3x,A2z,A3z);
line(A3x,A4x,A3z,A4z);
line(A4x,A5x,A4z,A5z);
line(A5x,A6x,A5z,A6z);
line(A6x,A7x,A6z,A7z);
line(A7x,A8x,A7z,A8z);
line(A8x,A9x,A8z,A9z);
ellipse(l1x,V1z,V1rad,V1rad);
ellipse(l2x,V2z,V2rad,V2rad);
ellipse(l3x,V3z,V3rad,V3rad);
ellipse(l4x,V4z,V4rad,V4rad);
ellipse(l5x,V5z,V5rad,V5rad);
}
void MouseListen()
{
if (mousePressed=false)
{
noLoop();
}
else
{
mousePressed();
}
}
void KeyListen()
{
if (keyPressed=false)
{
noLoop();
}
else
{
keyPressed();
}
}