EField4 Script Example: EField Constrain Y

Initialize

A test charge is constrained to move along a path of constant y.  Efield supports constraints on x, y, and along a function path, f(x).


Script Example

<script language="JavaScript"> 
function initEField(){
   document.EField.setAutoRefresh(false); 
   document.EField.setDefault();
   document.EField.setShowFieldVectors(true);
   id=document.EField.addObject("charge","x=0,y=-1.5,q=-10,r=8, m=1");
   document.EField.setDragable(id,false);
   document.EField.setRGB(id,0,0,0);
   document.EField.setLabel(id,"-");
   document.EField.setShowForce(true);
   id=document.EField.addObject("testcharge","x=-2,y=0.5,q=1,r=3, m=1");
   document.EField.setDragable(id,true);
   document.EField.setRGB(id,0,255,0);
   document.EField.setConstrainY(id,0.5,0,0);
   document.EField.setAutoRefresh(true);
}
</script>