8){
vxBar =0 ; // make stop immediately
axBar = 0; // far away
}
}
else if (diagramView=="B"){ // iron always attract
//diagramView=="A"?vxBar:0
vxBar = vxBar; // do ntg
//diagramView=="A"?(xBar<8?-50:0):0
if (xBar<8){
axBar = -attractivepower; // near enough at 8
}
else if (xBar>8){
vxBar =0 ;
axBar = 0; // far away
}
}
else if (diagramView=="C"){ // magnet attract
//diagramView=="A"?vxBar:0
vxBar = vxBar; // do ntg
//diagramView=="A"?(xBar<8?-50:0):0
if (xBar<8 && battDef==true){
axBar = -attractivepower; // near enough at 8
}
if (xBar<8 && battDef==false){
axBar = attractivepower; // near enough at 8
}
else if (xBar>8){
vxBar =0 ; // make stop immediately
axBar =0; // far away
}
}
// if need copy to make D
]]>
=8&&battDef==true){
hint= " Magnet is too far from the electromagnet, so it is stationary.";
}
else if (diagramView=="A"&&xBar<8&&battDef==false){
hint= " South North facing, so the objects attract each other";
}
else if (diagramView=="A"&&xBar>=8&&battDef==false){
hint= " Magnet is too far from the electromagnet, so it is stationary.";
}
else if (diagramView=="B"&&xBar<8){
hint= " Electromagnet attracts iron bar, so the objects attract each other";
}
else if (diagramView=="B"&&xBar>=8){
hint= " Iron bar too far from the electromagnet, so it is stationary. ";
}
else if (diagramView=="C"&&xBar<8&&battDef==false){
hint= " South South facing, so the objects repel each other";
}
else if (diagramView=="C"&&xBar>=8&&battDef==false){
hint= " Magnet is too far from the electromagnet, so it is stationary.";
}
else if (diagramView=="C"&&xBar<8&&battDef==true){
hint= " North South facing, so the objects attract each other";
}
else if (diagramView=="C"&&xBar>=8&&battDef==true){
hint= " Magnet is too far from the electromagnet, so it is stationary.";
}
]]>
=8&&battDef==true){
hint= " Magnet is too far from the electromagnet, so it is stationary.";
}
else if (diagramView=="A"&&xBar<8&&battDef==false){
hint= " Like poles are facing, so the objects attract each other";
}
else if (diagramView=="A"&&xBar>=8&&battDef==false){
hint= " Magnet is too far from the electromagnet, so it is stationary.";
}
else if (diagramView=="B"&&xBar<8){
hint= " Electromagnet attracts iron bar, so the objects attract each other";
}
else if (diagramView=="B"&&xBar>=8){
hint= " Iron bar too far from the electromagnet, so it is stationary. ";
}
else if (diagramView=="C"&&xBar<8&&battDef==false){
hint= " Like poles are facing, so the objects repel each other";
}
else if (diagramView=="C"&&xBar>=8&&battDef==false){
hint= " Magnet is too far from the electromagnet, so it is stationary.";
}
else if (diagramView=="C"&&xBar<8&&battDef==true){
hint= " Unlike poles are facing, so the objects attract each other";
}
else if (diagramView=="C"&&xBar>=8&&battDef==true){
hint= " Magnet is too far from the electromagnet, so it is stationary.";
}
]]>
=8&&battDef==true){
hint= " Magnet is too far from the electromagnet, so it is stationary.";
}
if (diagramView=="A"&&xBar<8&&battDef==false){
hint= " Unlike poles are facing, so the objects attract each other";
}
else if (diagramView=="A"&&xBar>=8&&battDef==false){
hint= " Magnet is too far from the electromagnet, so it is stationary.";
}
if (diagramView=="B"&&xBar<8){
hint= " Electromagnet attracts the iron bar.";
}
else if (diagramView=="B"&&xBar>=8){
hint= " Iron bar is too far from the electromagnet, so it is stationary. ";
}
if (diagramView=="C"&&xBar<8&&battDef==false){
hint= " Like poles are facing, so the objects repel each other";
}
else if (diagramView=="C"&&xBar>=8&&battDef==false){
hint= " Magnet is too far from the electromagnet, so it is stationary.";
}
if (diagramView=="C"&&xBar<8&&battDef==true){
hint= " Unlike poles are facing, so the objects attract each other";
}
else if (diagramView=="C"&&xBar>=8&&battDef==true){
hint= " Magnet is too far from the electromagnet, so it is stationary.";
}
}
]]>
0){ // to repel
if (xBar-xSizeBar/2-4.5<=0){
//_pause();
vxBar =0.1; // give it a little velocity
xBar =-(-xSizeBar/2-4.5) ; // force stop exactly at electromagnet rod
}
}
//battDef is false battery face right
else if (axBar<0&&battDef==false){ // to attract
if (xBar-xSizeBar/2-4.5<=0){
//_pause();
vxBar =0; // make stop moving
xBar =-(-xSizeBar/2-4.5) ; // force stop exactly at electromagnet rod
}
}
else if (axBar>0){ // to repel
if (xBar-xSizeBar/2-4.5<=0){
//_pause();
vxBar =0.1; // give it a little velocity
xBar =-(-xSizeBar/2-4.5) ; // force stop exactly at electromagnet rod
}
}
else{
//ntg
}
if (xBar>12.5){
//xBar=9; // bad idea to drop to new position, feels like a force
xBar=12.5; // like blocked
}
}
]]>
Recognise that a magnet can exert a push or a pull and unlike poles attract and like poles repel
This simulation shows how the polarity of the electromagnet changes with the direction of the battery placed in the circuit.
The north seeking pole (N-pole) of the magnet is indicated as N, while the south seeking pole (S-pole) of it is indicated as S.
Initially, the battery faces the left side, inducing a north seeking pole (N-pole) on the right side of the iron rod.
The user is able to drag the magnet. When the magnet is close enough, it will be attracted/repelled to/by the iron rod accordingly.
The following are the controllable variables:
The object used to identify the poles of the electromagnet, from Magnet NS to Iron bar, to Magnet SN.
The side of the battery changing from left to right.
The object is moveable in the x-axis direction.
Reset Button will put the simulation back to its default state.
]]>