loading

Step 3: 1523 lines of code on the wall...

 

The Processing Code:

The code is so large that instructables won't let me upload it as text :p

A text file and the processing app file are attached.

 

Is it possible to load other circuits and what format is expected by the code(falstads format or netlists, etc).
Schematic (using Falstad Circuit Sim)
//PROCESSING CODE <br> <br>import processing.serial.*; <br>Serial port; <br> <br>String serialdata = &quot;&quot;; <br>String[] serialsplit = { <br> &quot;&quot;, &quot;&quot; <br>}; <br>float lastedit = 0; <br>float editincrement = 1; <br>int keylast; <br>int lastX; <br>int lastY; <br>int currentX; <br>int currentY; <br>int dmouseX; <br>int dmouseY; <br>int tolerance = 0; <br>int particleslastgenerate = 0; <br>int particleslastupdate = 0; <br>boolean mousestatelast; <br>boolean holding = false; <br>boolean editing = false; <br>boolean overduino = false; <br>int arduinoalpha = 0; <br>color graphpointcolor = color(0, 255, 150); <br>float graphdomain = 1; <br>float graphrange = 1; <br>float desval = 0; <br>float phasortime = 0; <br>float phasortimecoefficient = -1; <br>float[] phasorthetas = new float[5]; <br>float[] phasormagnitudes = new float[5]; <br>color[] phasorcolors = new color[5]; <br>String[] phasorlabels = new String[5]; <br>String desunits = &quot;NONE&quot;; <br>String mode = &quot;Low-Pass Filter (RC)&quot;; <br>String modelast = &quot;NONE&quot;; <br> <br>PImage Arduino; <br>PFont font; <br>PFont font2; <br>Button modeswitch; <br>Button addcap; <br>Button addind; <br>Button addres; <br>Button addacs; <br>Button decreasedomain; <br>Button increasedomain; <br>Button decreaserange; <br>Button increaserange; <br>Button increasephasortimecoefficient; <br>Button decreasephasortimecoefficient; <br>Button graphicaldisplay; <br>Capacitor capacitor1; <br>Capacitor capacitor2; <br>Inductor inductor1; <br>ACSource ac1; <br>Resistor resistor1; <br>ArrayList particles; <br>ArrayList capacitors; <br>ArrayList inductors; <br>ArrayList resistors; <br>ArrayList acsources; <br>ArrayList schemwires; <br>ArrayList schemouts; <br>ArrayList schemgrounds; <br>ArrayList schemcapacitors; <br>ArrayList scheminductors; <br>ArrayList schemresistors; <br>ArrayList schemacsources; <br>//SchemInd sind1; <br>//SchemCap scap1; <br>//SchemRes sres1; <br>//SchemACS sacs1; <br>//SchemWire swire1; <br>//SchemOUT sout1; <br> <br>void setup() { <br> size(800, 500); <br> port = new Serial(this, &quot;COM4&quot;, 9600); <br> port.bufferUntil('\n'); <br> Arduino = loadImage(&quot;arduino_icon.png&quot;); <br> Arduino.resize(0, 50); <br> font = loadFont(&quot;EurostileBold-20.vlw&quot;); <br> font2 = loadFont(&quot;EurostileRegular-12.vlw&quot;); <br> textFont(font); <br> <br> modeswitch = new Button(color(150, 100, 0), 200, 400, 100, 30, &quot;NextCircuit&quot;); <br> addcap = new Button(color(0, 0, 120), 100, 15, 30, 30, &quot;C&quot;); <br> addind = new Button(color(200, 100, 0), 200, 15, 30, 30, &quot;L&quot;); <br> addres = new Button(color(200, 0, 0), 300, 15, 30, 30, &quot;R&quot;); <br> addacs = new Button(color(0, 200, 100), 400, 15, 30, 30, &quot;AC&quot;); <br> decreasedomain = new Button(color(0, 255, 150), 550, 340, 90, 30, &quot; -Domain&quot;); <br> increasedomain = new Button(color(0, 255, 150), 640, 340, 90, 30, &quot; +Domain&quot;); <br> decreaserange = new Button(color(0, 255, 150), 550, 370, 90, 30, &quot; -Range&quot;); <br> increaserange = new Button(color(0, 255, 150), 640, 370, 90, 30, &quot; +Range&quot;); <br> increasephasortimecoefficient = new Button(color(0, 255, 150), 640, 370, 90, 30, &quot; +Omega&quot;); <br> decreasephasortimecoefficient = new Button(color(0, 255, 150), 550, 370, 90, 30, &quot; -Omega&quot;); <br> graphicaldisplay = new Button(color(0, 255, 125), 550, 15, 90, 30, &quot;PLOT&quot;); <br> capacitor1 = new Capacitor(color(0, 175, 255), 85, 60, .001); <br> capacitor2 = new Capacitor(color(0, 0, 255), 200, 10, .002); <br> inductor1 = new Inductor(color(255, 125, 0), 200, 60, .001); <br> ac1 = new ACSource(color(200, 200, 200), 400, 60, 1000); <br> resistor1 = new Resistor(color(255, 0, 0), 300, 60, 100); <br> particles = new ArrayList(); <br> capacitors = new ArrayList(); <br> inductors = new ArrayList(); <br> resistors = new ArrayList(); <br> acsources = new ArrayList(); <br> schemwires = new ArrayList(); <br> schemouts = new ArrayList(); <br> schemgrounds = new ArrayList(); <br> schemcapacitors = new ArrayList(); <br> scheminductors = new ArrayList(); <br> schemresistors = new ArrayList(); <br> schemacsources = new ArrayList(); <br> capacitors.add((Capacitor) capacitor1); <br> inductors.add((Inductor) inductor1); <br> resistors.add((Resistor) resistor1); <br> acsources.add((ACSource) ac1); <br> //sind1 = new SchemInd(200, 200, 1); <br> //scap1 = new SchemCap(300, 300, 1); <br> //sres1 = new SchemRes(300, 200, 1); <br> //sacs1 = new SchemACS(400, 300, 1); <br> //swire1 = new SchemWire(100, 200, 100, 250, 1); <br> //sout1 = new SchemOUT(100, 100, 200, 200, 1); <br> //scheminductors.add((SchemInd) sind1); <br> //schemcapacitors.add((SchemCap) scap1); <br> //schemresistors.add((SchemRes) sres1); <br> //schemacsources.add((SchemACS) sacs1); <br> //schemwires.add((SchemWire) swire1); <br>} <br> <br>void draw() { <br> background(255); <br> color(0); <br> //text(serialsplit[0], 100, 100); <br> serialdata = &quot;&quot;; <br> strokeWeight(1); <br> keylast = 0; <br> if (keyPressed) keylast = key; <br> displayAll(); <br> updateAll(); <br> currentX = mouseX; <br> currentY = mouseY; <br> dmouseX = (currentX - lastX); <br> dmouseY = (currentY - lastY); <br> lastX = mouseX; <br> lastY = mouseY; <br> modeswitch.display(); <br> addcap.display(); <br> addind.display(); <br> addres.display(); <br> addacs.display(); <br> if (modeswitch.isPressed() &amp;&amp; !mousestatelast) { <br> if (mode == &quot;Low-Pass Filter (RC)&quot;) mode = &quot;High-Pass Filter (RC)&quot;; <br> else if (mode==&quot;High-Pass Filter (RC)&quot;) { <br> mode = &quot;Low-Pass Filter (RL)&quot;; <br> } <br> else if (mode==&quot;Low-Pass Filter (RL)&quot;) { <br> mode = &quot;High-Pass Filter (RL)&quot;; <br> } <br> else if (mode==&quot;High-Pass Filter (RL)&quot;) { <br> mode = &quot;Band-Reject (Notch): Driven LC Series&quot;; <br> } <br> else if (mode==&quot;Band-Reject (Notch): Driven LC Series&quot;) { <br> mode = &quot;Band-Pass: Driven LC Parallel&quot;; <br> } <br> else if (mode==&quot;Band-Pass: Driven LC Parallel&quot;) { <br> mode = &quot;Resonance (LC Tank)&quot;; <br> } <br> else if (mode==&quot;Resonance (LC Tank)&quot;) { <br> mode = &quot;Dual Resonant Air-Core Step-Up Transformer (Tesla Coil)&quot;; <br> } <br> else if (mode==&quot;Dual Resonant Air-Core Step-Up Transformer (Tesla Coil)&quot;) { <br> mode = &quot;Low-Pass Filter (RC)&quot;; <br> } <br> } <br> if (addcap.isPressed() &amp;&amp; !mousestatelast) capacitors.add(new Capacitor(color(random(0, 100), random(0, 100), 55+random(0, 200)), 85, 60, .001)); <br> if (addind.isPressed() &amp;&amp; !mousestatelast) inductors.add(new Inductor(color(200+random(-50, 50), 100+random(-50, 50), 0), 200, 60, .001)); <br> if (addres.isPressed() &amp;&amp; !mousestatelast) resistors.add(new Resistor(color(100+random(0, 100), random(0, 50), 0), 300, 60, .001)); <br> if (addacs.isPressed() &amp;&amp; !mousestatelast) acsources.add(new ACSource(color(50+random(0, 200), 50+random(0, 200), 50+random(0, 200)), 400, 60, .001)); <br> graphicaldisplay.display(); <br> if (graphicaldisplay.isPressed() &amp;&amp; !mousestatelast) { <br> if (graphicaldisplay.symbol == &quot;PLOT&quot;) graphicaldisplay.symbol = &quot;VECTOR&quot;; <br> else if (graphicaldisplay.symbol == &quot;VECTOR&quot;) graphicaldisplay.symbol = &quot;PHASOR&quot;; <br> else if (graphicaldisplay.symbol == &quot;PHASOR&quot;) graphicaldisplay.symbol = &quot;PLOT&quot;; <br> } <br> if (graphicaldisplay.symbol == &quot;PHASOR&quot;) { <br> phasortime += .000000001; <br> } <br> else phasortime = 0; <br> if (graphicaldisplay.symbol == &quot;PLOT&quot;) { <br> decreasedomain.display(); <br> increasedomain.display(); <br> decreaserange.display(); <br> increaserange.display(); <br> if (decreasedomain.isPressed() &amp;&amp; !mousestatelast) graphdomain = (graphdomain * .1); <br> if (increasedomain.isPressed() &amp;&amp; !mousestatelast) graphdomain = (graphdomain * 10); <br> if (decreaserange.isPressed() &amp;&amp; !mousestatelast) graphrange = (graphrange * .1); <br> if (increaserange.isPressed() &amp;&amp; !mousestatelast) graphrange = (graphrange * 10); <br> } <br> if (graphicaldisplay.symbol == &quot;PHASOR&quot;) { <br> decreasephasortimecoefficient.display(); <br> increasephasortimecoefficient.display(); <br> if (decreasephasortimecoefficient.isPressed() &amp;&amp; !mousestatelast) phasortimecoefficient *= .1; <br> if (increasephasortimecoefficient.isPressed() &amp;&amp; !mousestatelast) phasortimecoefficient *= 10; <br> } <br> if (!holding) { <br> desval = 0; <br> desunits = &quot;NONE&quot;; <br> } <br> description(); <br> updateSchematic(); <br> if(overduino) { <br> arduinoalpha += 10; <br> if(arduinoalpha&gt;250) arduinoalpha = 0; <br> } <br> else { <br> arduinoalpha = 255; <br> } <br> tint(255, arduinoalpha); <br> image(Arduino, 0, 200); <br> overduino = false; <br> mouseStateUpdate(mousePressed); <br>} <br> <br>void serialEvent(Serial port) { <br> serialdata = port.readStringUntil('\n'); <br> serialsplit = (String[])split(serialdata, '_'); <br>} <br>boolean overArduino(float x, float y) { <br> if ((sqrt(sq(25-x)+sq(225-y)))&lt;30) { <br> overduino = true; <br> return true; <br> } <br> else return false; <br>} <br>void requestImport(String units) { <br> port.write(&quot;request&quot;+units); <br> port.write('\n'); <br>} <br>class Button { <br> <br> boolean pressed = false; <br> int lastclicktime = 0; <br> float xpos; <br> float ypos; <br> float widthv; <br> float heightv; <br> float leftbound; <br> float rightbound; <br> float upperbound; <br> float lowerbound; <br> color colorv; <br> String symbol; <br> <br> Button(color Tempcolorv, float Tempxpos, float Tempypos, float Tempwidthv, float Tempheightv, String Tempsymbol) { <br> xpos = Tempxpos; <br> ypos = Tempypos; <br> widthv = Tempwidthv; <br> heightv = Tempheightv; <br> leftbound = xpos - widthv/2; <br> rightbound = xpos + widthv/2; <br> upperbound = ypos - heightv/2; <br> lowerbound = ypos + heightv/2; <br> colorv = Tempcolorv; <br> symbol = Tempsymbol; <br> } <br> <br> void display() { <br> stroke(0); <br> fill(colorv); <br> rectMode(CENTER); <br> rect(xpos, ypos, widthv, heightv); <br> fill(255); <br> textFont(font); <br> text(symbol, leftbound, ypos); <br> } <br> <br> boolean isMouseOver() { <br> if (mouseX &gt; leftbound &amp;&amp; mouseX &lt; rightbound <br> &amp;&amp; mouseY &gt; upperbound &amp;&amp; mouseY &lt; lowerbound) { <br> return true; <br> } <br> else return false; <br> } <br> boolean isPressed() { <br> if (mousePressed &amp;&amp; isMouseOver()) { <br> if (pressed) return true; <br> else if (mousePressed &amp;&amp; mousestatelast == false) { <br> lastclicktime = millis()/100; <br> pressed = true; <br> return true; <br> } <br> else return false; <br> } <br> else return false; <br> } <br>} <br> <br>class Element { <br> String units; <br> float value; <br> color c; <br> float xpos; <br> float ypos; <br> float centerx; <br> float centery; <br> int area = 50; <br> boolean held; <br> boolean edit = false; <br> boolean applied; <br> boolean isfinished = false; <br> <br> <br> <br> void update() { <br> if ((centerx &gt; 50) &amp;&amp; (centerx &lt; 70) &amp;&amp; (centery &gt; 450) &amp;&amp; (centery &lt; 480)) { <br> isfinished = true; <br> held = false; <br> holding = false; <br> } <br> if (held &amp;&amp; !mousePressed) <br> { <br> holding = false; <br> } <br> if (edit &amp;&amp; (keylast == 32)) { <br> <br> editing = false; <br> } <br> if (held &amp;&amp; mousePressed) <br> { <br> <br> centerx = mouseX; <br> centery = mouseY; <br> if (!overArduino(centerx, centery)) { <br> generateSparks(0, .7, .04, .04, 3, color(0, 245, 245)); <br> } <br> else { <br> generateSparks(random(0, 1), random(-1, 1), .10, .10, 3, color(0, 245, 245)); <br> //if (serialsplit[0] == units) { <br> if (units == &quot;Farads&quot; || units == &quot;Henrys&quot;) value = float(serialsplit[0])/1000000000; <br> else value = float(serialsplit[0]); <br> //} <br> requestImport(units); <br> } <br> } <br> else <br> { <br> held = false; <br> } <br> <br> if (edit) { <br> desunits = units; <br> desval = value; <br> description(); <br> stroke(color(0, 255, 55+((sin(float(millis())/1000)+1)*.5)*200)); <br> noFill(); <br> ellipse(centerx, centery, area, area); <br> ellipse(centerx, centery, <br> (area + (3*sin(millis()/100))), <br> (area + (3*cos(millis()/100)))); <br> } <br> <br> if (edit &amp;&amp; (lastedit &lt; ((millis()/10) - 10))) { <br> if (keyPressed) { <br> if (keylast == 100) { <br> value += editincrement; <br> } <br> if (keylast == 97) { <br> value -= editincrement; <br> } <br> if (lastedit &lt; ((millis()/10) - 20)) { <br> if (keylast == 119) { <br> editincrement = (editincrement*10); <br> } <br> if (keylast == 115) { <br> editincrement = (editincrement/10); <br> } <br> } <br> lastedit = (millis()/10); <br> } <br> } <br> <br> <br> if ( mouseX &gt; ((centerx - 15) - tolerance) <br> &amp;&amp; mouseX &lt; ((centerx + 15) + tolerance) <br> &amp;&amp; mouseY &gt; ((centery - 20) - tolerance) <br> &amp;&amp; mouseY &lt; ((centery + 20) + tolerance) <br> &amp;&amp; !held) <br> { <br> noFill(); <br> if (true) { <br> if (keylast == 32) { <br> editing = true; <br> edit = true; <br> } <br> } <br> if (edit) stroke(color(0, 255, 55+((sin(float(millis())/1000)+1)*.5)*200)); <br> else stroke(color(0, 0, 0)); <br> ellipse(centerx, centery, area, area); <br> ellipse(centerx, centery, <br> (area + (3*sin(millis()/100))), <br> (area + (3*cos(millis()/100)))); <br> if (mousePressed &amp;&amp; mousestatelast == false) { <br> if (holding == false) { <br> holding = true; <br> held = true; <br> desval = value; <br> desunits = units; <br> } <br> } <br> } <br> else { <br> if (edit &amp;&amp; keylast == 32) { <br> editing = false; <br> edit = false; <br> } <br> } <br> } <br>} <br> <br> <br> <br> <br> <br> <br> <br> <br>class Capacitor extends Element { <br> <br> Capacitor(color tempC, float tempXpos, float tempYpos, float tempValue) { <br> units = &quot;Farads&quot;; <br> value = tempValue; <br> c = tempC; <br> xpos = tempXpos; <br> ypos = tempYpos; <br> centerx = xpos + 10; <br> centery = ypos; <br> } <br> <br> <br> <br> <br> void display() { <br> //centerx = xpos + 10; <br> //centery = ypos; <br> stroke(0); <br> fill(c); <br> rectMode(CENTER); <br> rect(centerx - 5, centery, 5, 30); <br> rect(centerx - 5 + 15, centery, 5, 30); <br> } <br>} <br> <br>class Inductor extends Element { <br> <br> Inductor(color tempC, float tempXpos, float tempYpos, float tempValue) { <br> units = &quot;Henrys&quot;; <br> value = tempValue; <br> c = tempC; <br> xpos = tempXpos; <br> ypos = tempYpos; <br> centerx = xpos; <br> centery = ypos; <br> } <br> <br> <br> <br> <br> void display() { <br> stroke(0); <br> fill(c); <br> //beginShape(); <br> /* curveVertex(centerx - 20, centery - 10); <br> curveVertex(centerx - 15, centery); <br> curveVertex(centerx - 10, centery - 10); <br> curveVertex(centerx - 5, centery); <br> curveVertex(centerx, centery - 10); <br> curveVertex(centerx + 5, centery); <br> curveVertex(centerx + 10, centery - 10); <br> curveVertex(centerx + 15, centery); <br> curveVertex(centerx + 15, centery + 10); <br> curveVertex(centerx + 10, centery); <br> curveVertex(centerx + 5, centery + 10); <br> curveVertex(centerx, centery); <br> curveVertex(centerx - 5, centery + 10); <br> curveVertex(centerx - 10, centery); <br> curveVertex(centerx - 15, centery + 10); <br> curveVertex(centerx - 20, centery); <br> */ <br> for (int i = 0; i &lt; 3; i++) { <br> fill(c); <br> arc(centerx + (-10 + (10 * i)), centery + 5, 10, 40, PI, TWO_PI); <br> noFill(); <br> arc(centerx + (-10 + (10 * i)), centery + 5, 5, 30, PI, TWO_PI); <br> } <br> //endShape(CLOSE); <br> } <br>} <br> <br>class Resistor extends Element { <br> <br> Resistor(color tempC, float tempXpos, float tempYpos, float tempValue) { <br> units = &quot;Ohms&quot;; <br> value = tempValue; <br> c = tempC; <br> xpos = tempXpos; <br> ypos = tempYpos; <br> centerx = xpos; <br> centery = ypos; <br> } <br> <br> <br> <br> <br> void display() { <br> stroke(0); <br> fill(c); <br> beginShape(); <br> curveVertex(centerx - 20, centery - 10); <br> curveVertex(centerx - 15, centery); <br> curveVertex(centerx - 10, centery - 10); <br> curveVertex(centerx - 5, centery); <br> curveVertex(centerx, centery - 10); <br> curveVertex(centerx + 5, centery); <br> curveVertex(centerx + 10, centery - 10); <br> curveVertex(centerx + 15, centery); <br> curveVertex(centerx + 15, centery + 10); <br> curveVertex(centerx + 10, centery); <br> curveVertex(centerx + 5, centery + 10); <br> curveVertex(centerx, centery); <br> curveVertex(centerx - 5, centery + 10); <br> curveVertex(centerx - 10, centery); <br> curveVertex(centerx - 15, centery + 10); <br> curveVertex(centerx - 20, centery); <br> endShape(CLOSE); <br> } <br>} <br> <br>class ACSource extends Element { <br> <br> ACSource(color tempC, float tempXpos, float tempYpos, float tempValue) { <br> units = &quot;Hertz&quot;; <br> value = tempValue; <br> c = tempC; <br> xpos = tempXpos; <br> ypos = tempYpos; <br> centerx = xpos; <br> centery = ypos; <br> } <br> <br> <br> <br> <br> void display() { <br> //centerx = xpos + 10; <br> //centery = ypos; <br> stroke(0); <br> fill(c); <br> ellipse(centerx, centery, 30, 30); <br> for (int i = 0; i &lt; 20; i++) { <br> /*set(-10 + i + int(centerx), int(((sin((i*TWO_PI)/20) * -10) + int(centery))), color(255*(-1*sin((i*TWO_PI)/20) + 1), 0, 255*(sin((i*TWO_PI)/20) + 1))); <br> set(-10 + i + int(centerx), int(((sin((i*TWO_PI)/20) * -10) + int(centery) - 1)), color(255*(-1*sin((i*TWO_PI)/20) + 1), 0, 255*(sin((i*TWO_PI)/20) + 1))); <br> set(-10 + i + int(centerx), int(((sin((i*TWO_PI)/20) * -10) + int(centery) + 1)), color(255*(-1*sin((i*TWO_PI)/20) + 1), 0, 255*(sin((i*TWO_PI)/20) + 1))); <br> set(-10 + i + int(centerx), int(((sin((i*TWO_PI)/20) * -10) + int(centery) - 2)), color(255*(-1*sin((i*TWO_PI)/20) + 1), 0, 255*(sin((i*TWO_PI)/20) + 1))); <br> set(-10 + i + int(centerx), int(((sin((i*TWO_PI)/20) * -10) + int(centery) + 2)), color(255*(-1*sin((i*TWO_PI)/20) + 1), 0, 255*(sin((i*TWO_PI)/20) + 1))); <br> set(-10 + i + int(centerx), int(((sin((i*TWO_PI)/20) * -10) + int(centery) - 3)), color(255*(-1*sin((i*TWO_PI)/20) + 1), 0, 255*(sin((i*TWO_PI)/20) + 1))); <br> set(-10 + i + int(centerx), int(((sin((i*TWO_PI)/20) * -10) + int(centery) + 3)), color(255*(-1*sin((i*TWO_PI)/20) + 1), 0, 255*(sin((i*TWO_PI)/20) + 1))); <br> */ <br> set(-10 + i + int(centerx), int(((sin((i*TWO_PI)/20) * -10) + int(centery))), color(0, 255, 125)); <br> set(-10 + i + int(centerx), int(((sin((i*TWO_PI)/20) * -10) + int(centery) - 1)), color(0, 255, 125)); <br> set(-10 + i + int(centerx), int(((sin((i*TWO_PI)/20) * -10) + int(centery) + 1)), color(0, 255, 125)); <br> set(-10 + i + int(centerx), int(((sin((i*TWO_PI)/20) * -10) + int(centery) - 2)), color(0, 255, 125)); <br> set(-10 + i + int(centerx), int(((sin((i*TWO_PI)/20) * -10) + int(centery) + 2)), color(0, 255, 125)); <br> set(-10 + i + int(centerx), int(((sin((i*TWO_PI)/20) * -10) + int(centery) - 3)), color(0, 255, 125)); <br> set(-10 + i + int(centerx), int(((sin((i*TWO_PI)/20) * -10) + int(centery) + 3)), color(0, 255, 125)); <br> set(-10 + i + int(centerx), int(((sin((i*TWO_PI)/20) * -10) + int(centery) - 4)), color(0, 0, 0)); <br> set(-10 + i + int(centerx), int(((sin((i*TWO_PI)/20) * -10) + int(centery) + 4)), color(0, 0, 0)); <br> set(-10 + i + int(centerx), int(((sin((i*TWO_PI)/20) * -10) + int(centery) - 5)), color(0, 0, 0)); <br> set(-10 + i + int(centerx), int(((sin((i*TWO_PI)/20) * -10) + int(centery) + 5)), color(0, 0, 0)); <br> } <br> /*ellipse(centerx, centery, 20 <br> arc(centerx - 5, centery, 10, 10, 0, PI); <br> arc(centerx +5, centery, 10, 10, PI, TWO_PI); <br> */ <br> } <br>} <br> <br>class Sparks { <br> <br> PVector location; <br> PVector movement; <br> PVector acceleration; <br> float radiusv[] = new float[6]; <br> float thetav[] = new float[6]; <br> float thetao; <br> float omega; <br> float sizev; <br> color colorv; <br> int birth; <br> int lifetime; <br> <br> Sparks(float dx, float dy, float ddx, float ddy, float sizecoefficient, color sparkcolor) { <br> location = new PVector(mouseX + random(-2, 2), mouseY + random(-2, 2), 0); <br> movement = new PVector(dx + random(-.1, .1), dy + random(-.1, .1), 0); <br> acceleration = new PVector(1 + ddx + random(-.01, .01), 1 + ddy + random(-.01, .01), 0); <br> radiusv[0] = 0; <br> radiusv[1] = 2; <br> radiusv[2] = sqrt(20); <br> radiusv[3] = sqrt(2); <br> radiusv[4] = sqrt(5); <br> radiusv[5] = sqrt(20); <br> thetav[0] = 0; <br> thetav[1] = PI; <br> thetav[2] = atan(2); <br> thetav[3] = QUARTER_PI; <br> thetav[4] = atan(.5); <br> thetav[5] = PI + atan(2); <br> omega = 0; <br> sizev = sizecoefficient; <br> colorv = sparkcolor; <br> birth = millis()/1000; <br> lifetime = 10; <br> } <br> <br> void update() { <br> physics(); <br> } <br> <br> void physics() { <br> location.add(movement); <br> movement.mult(acceleration); <br> omega = constrain(tan((movement.y)*(movement.x)*(acceleration.y)*(acceleration.x)), -.1, .1); <br> thetao = thetao + omega; <br> } <br> <br> void render() { <br> stroke(0); <br> fill(colorv); <br> beginShape(); <br> for (int i = 0; i &lt; 6; i++) { <br> vertex(location.x + (sizev * (cos(thetav[i] + thetao) * radiusv[i])), location.y + (sizev * (sin(thetav[i] + thetao) * radiusv[i]))); <br> } <br> endShape(CLOSE); <br> //ellipse(location.x, location.y, 12, 12); <br> } <br> <br> boolean isFinished() { <br> if (lifetime &lt; ((millis()/1000) - birth)) { <br> return true; <br> } <br> else return false; <br> } <br>} <br> <br> <br>void displayAll() { <br> //capacitor1.display(); <br> // capacitor2.display(); <br> //inductor1.display(); <br> //ac1.display(); <br> //resistor1.display(); <br> renderCapacitors(); <br> renderInductors(); <br> renderResistors(); <br> renderACSources(); <br> renderParticles(); <br> displayTrashCan(); <br>} <br> <br>void updateAll() { <br> // updateSchematic(); <br> updateCapacitors(); <br> updateInductors(); <br> updateResistors(); <br> updateACSources(); <br> updateParticles(); <br> updateSchemCap(); <br> updateSchemInd(); <br> updateSchemRes(); <br> updateSchemACS(); <br> updateSchemWire(); <br> updateSchemOUT(); <br> //capacitor1.update(); <br> //capacitor2.update(); <br> // inductor1.update(); <br> // ac1.update(); <br> //resistor1.update(); <br>} <br>void updateCapacitors() { <br> for (int i = capacitors.size()-1; i &gt;= 0; i--) { <br> Capacitor cap = (Capacitor) capacitors.get(i); <br> if (cap.isfinished) { <br> capacitors.remove(i); <br> } <br> else { <br> cap.update(); <br> capacitors.add((Capacitor) cap); <br> capacitors.remove(i); <br> } <br> } <br>} <br>void updateInductors() { <br> for (int i = inductors.size()-1; i &gt;= 0; i--) { <br> Inductor ind = (Inductor) inductors.get(i); <br> if (ind.isfinished) { <br> inductors.remove(i); <br> } <br> else { <br> ind.update(); <br> inductors.add((Inductor) ind); <br> inductors.remove(i); <br> } <br> } <br>} <br>void updateResistors() { <br> for (int i = resistors.size()-1; i &gt;= 0; i--) { <br> Resistor res = (Resistor) resistors.get(i); <br> if (res.isfinished) { <br> resistors.remove(i); <br> } <br> else { <br> res.update(); <br> resistors.add((Resistor) res); <br> resistors.remove(i); <br> } <br> } <br>} <br>void updateACSources() { <br> for (int i = acsources.size()-1; i &gt;= 0; i--) { <br> ACSource acs = (ACSource) acsources.get(i); <br> if (acs.isfinished) { <br> acsources.remove(i); <br> } <br> else { <br> acs.update(); <br> acsources.add((ACSource) acs); <br> acsources.remove(i); <br> } <br> } <br>} <br>void updateParticles() { <br> if (particleslastupdate &lt; (millis()/10) - 1) { <br> for (int i = particles.size()-1; i &gt;= 0; i--) { <br> Sparks spark = (Sparks) particles.get(i); <br> if (spark.isFinished()) { <br> particles.remove(i); <br> } <br> else { <br> spark.update(); <br> particles.add((Sparks) spark); <br> particles.remove(i); <br> } <br> } <br> particleslastupdate = (millis()/100); <br> } <br>} <br> <br>void renderCapacitors() { <br> for (int i = capacitors.size()-1; i &gt;= 0; i--) { <br> Capacitor cap = (Capacitor) capacitors.get(i); <br> cap.display(); <br> } <br>} <br>void renderInductors() { <br> for (int i = inductors.size()-1; i &gt;= 0; i--) { <br> Inductor ind = (Inductor) inductors.get(i); <br> ind.display(); <br> } <br>} <br>void renderResistors() { <br> for (int i = resistors.size()-1; i &gt;= 0; i--) { <br> Resistor res = (Resistor) resistors.get(i); <br> res.display(); <br> } <br>} <br>void renderACSources() { <br> for (int i = acsources.size()-1; i &gt;= 0; i--) { <br> ACSource acs = (ACSource) acsources.get(i); <br> acs.display(); <br> } <br>} <br>void renderParticles() { <br> for (int i = particles.size()-1; i &gt;= 0; i--) { <br> Sparks spark = (Sparks) particles.get(i); <br> spark.render(); <br> } <br>} <br> <br> <br>void generateSparks(float dx, float dy, float ddx, float ddy, float sizecoefficient, color sparkcolor) { <br> if (particleslastgenerate &lt; (millis()/100) - .25) { <br> particles.add(new Sparks(dx, dy, ddx, ddy, sizecoefficient, sparkcolor)); <br> particleslastgenerate = (millis()/100); <br> } <br>} <br> <br>void mouseStateUpdate(boolean mousestatecurrent) <br>{ <br> mousestatelast = mousestatecurrent; <br>} <br>void description() { <br> if (!(desunits == &quot;NONE&quot;)) { <br> textFont(font); <br> noFill(); <br> rectMode(CORNER); <br> rect(100, 450, 400, 50); <br> fill(color(0, 0, 0)); <br> text(str(desval)+ ' ' + desunits, 100, 475); <br> } <br>} <br>void graph(String xlable, String ylable, float domainmin, float domainmax, float rangemin, float rangemax, float xpoint, float ypoint) { <br> if (graphicaldisplay.symbol == &quot;PLOT&quot;) { <br> stroke(color(0, 255, 150)); <br> fill(color(0, 0, 0)); <br> rectMode(CORNER); <br> rect(500, 100, 200, 200); <br> stroke(0, 255, 255); <br> fill(graphpointcolor); <br> ellipse(constrain((map(xpoint, domainmin, domainmax*graphdomain, 0, 200)+500), 500, 700), constrain((map(ypoint, rangemin, rangemax*graphrange, 0, -200)+300), 100, 300), 10, 10); <br> fill(color(0, 255, 150)); <br> text(str(ypoint) + &quot;V&quot;, 500, 150); <br> text(str(xpoint) + &quot;Hz&quot;, 550, 300); <br> text(xlable + &quot;(0Hz - &quot;+str(10*graphdomain)+&quot;Hz)&quot;, 550, 320); <br> text(ylable + &quot;(0V - &quot;+str(5*graphrange)+&quot;Vss)&quot;, 450, 90); <br> } <br>} <br>void vector(String xlable, String ylabel, PVector vector) { <br> if (graphicaldisplay.symbol == &quot;VECTOR&quot;) { <br> stroke(color(0, 0, 0)); <br> strokeWeight(4); <br> line(500, 200, 500, 200-map(vector.y, 0, 1000, 0, 100)); <br> line(500, 200, 500+map(vector.x, 0, 1000, 0, 100), 200); <br> strokeWeight(2); <br> line(500, 200, 500+map(vector.x, 0, 1000, 0, 100), 200-map(vector.y, 0, 1000, 0, 100)); <br> text(&quot;(X)&quot;+xlable+&quot; &quot;+str(abs(vector.x)), 525, 90); <br> text(&quot;(Y)&quot;+ylabel+&quot; &quot;+str(abs(vector.y)), 525, 100); <br> text(&quot;PhaseShift:&quot;, 525, 125); <br> if ((phaseShift(vector.x, vector.y))&gt;0) { <br> text(&quot;Voltage&quot;+&quot; &quot;+&quot;IN PHASE&quot;, 525, 135); <br> text(&quot;Current&quot;+&quot; &quot;+&quot;LAG&quot;+&quot; &quot;+str(degrees(phaseShift(vector.x, vector.y))*-1)+&quot;degrees&quot;, 525, 145); <br> } <br> else if ((phaseShift(vector.x, vector.y))&lt;0) { <br> text(&quot;Voltage&quot;+&quot; &quot;+&quot;LAG&quot;+&quot; &quot;+str(degrees(phaseShift(vector.x, vector.y))*-1)+&quot;degrees&quot;, 525, 135); <br> text(&quot;Current&quot;+&quot; &quot;+&quot;IN PHASE&quot;, 525, 145); <br> } <br> else { <br> text(&quot;Voltage&quot;+&quot; &quot;+&quot;IN PHASE&quot;, 525, 135); <br> text(&quot;Current&quot;+&quot; &quot;+&quot;IN PHASE&quot;, 525, 145); <br> } <br> strokeWeight(1); <br> } <br>} <br> <br>void phasor(int nphasors, float omega, float[] thetas, float[] magnitudes, color[] colors, String[] labels) { <br> strokeWeight(4); <br> for (int i = 0; i stroke(colors[i]); <br> fill(colors[i]); <br> line(500, 200, 500 + cos(phasortimecoefficient*phasortime*omega + thetas[i])*magnitudes[i]*20, 200 + sin(phasortimecoefficient*phasortime*omega + thetas[i])*magnitudes[i]*20); <br> text(labels[i], 500, 400+10*i); <br> text(&quot;[&quot; + (magnitudes[i]) + &quot;]&quot; + &quot;[&quot; + &quot;e^(j&quot; + (thetas[i]) + &quot;)&quot; + &quot;]&quot; + &quot;e^(j&quot; + (omega) + (phasortimecoefficient*phasortime) + &quot;)&quot; + &quot;]&quot;, 500, 300+10*i); <br> } <br>} <br> <br>void updateSchematic() { <br> updateSchemGround(); <br> updateSchemOUT(); <br> updateSchemWire(); <br> updateSchemCap(); <br> updateSchemInd(); <br> updateSchemRes(); <br> updateSchemACS(); <br> if (mode != modelast) { <br> for (int i=schemwires.size()-1;i&gt;=0;i--) { <br> schemwires.remove(i); <br> } <br> for (int i=schemouts.size()-1;i&gt;=0;i--) { <br> schemouts.remove(i); <br> } <br> for (int i=schemgrounds.size()-1;i&gt;=0;i--) { <br> schemgrounds.remove(i); <br> } <br> for (int i=schemcapacitors.size()-1;i&gt;=0;i--) { <br> schemcapacitors.remove(i); <br> } <br> for (int i=scheminductors.size()-1;i&gt;=0;i--) { <br> scheminductors.remove(i); <br> } <br> for (int i=schemresistors.size()-1;i&gt;=0;i--) { <br> schemresistors.remove(i); <br> } <br> for (int i=schemacsources.size()-1;i&gt;=0;i--) { <br> schemacsources.remove(i); <br> } <br> <br> if (mode==&quot;Low-Pass Filter (RC)&quot;) { <br> graphdomain = 1; <br> graphrange = 1; <br> SchemCap c1 = new SchemCap(200, 300, 1); <br> SchemRes r1 = new SchemRes(300, c1.leadly, 1); <br> SchemACS a1 = new SchemACS(250, 200, 1); <br> schemcapacitors.add((SchemCap) c1); <br> schemresistors.add((SchemRes) r1); <br> schemacsources.add((SchemACS) a1); <br> schemwires.add(new SchemWire(c1.leadrx, c1.leadry, r1.leadlx, r1.leadly, 1)); <br> schemwires.add(new SchemWire((c1.leadlx) - 10, c1.leadly, (c1.leadlx) - 10, a1.leadly, 2)); <br> schemwires.add(new SchemWire((r1.leadrx) + 10, r1.leadry, (r1.leadrx) + 10, a1.leadry, 3)); <br> schemwires.add(new SchemWire((c1.leadlx) - 10, c1.leadly, c1.leadlx, c1.leadly, 4)); <br> schemwires.add(new SchemWire((r1.leadrx) + 10, r1.leadry, r1.leadrx, r1.leadry, 5)); <br> schemwires.add(new SchemWire((c1.leadlx) - 10, a1.leadly, a1.leadlx, a1.leadly, 6)); <br> schemwires.add(new SchemWire((r1.leadrx) + 10, a1.leadry, a1.leadrx, a1.leadry, 7)); <br> schemouts.add(new SchemOUT(((c1.leadrx + r1.leadlx)/2), c1.leadry, ((c1.leadrx+r1.leadlx)/2), c1.leadry + 50, 1)); <br> schemgrounds.add(new SchemGround((c1.leadlx) - 10, c1.leadly, (c1.leadlx) - 10, (c1.leadly) +50, 1)); <br> } <br> else if (mode==&quot;High-Pass Filter (RC)&quot;) { <br> } <br> else if (mode==&quot;Low-Pass Filter (RL)&quot;) { <br> } <br> else if (mode==&quot;High-Pass Filter (RL)&quot;) { <br> } <br> else if (mode==&quot;Band-Reject (Notch): Driven LC Series&quot;) { <br> } <br> else if (mode==&quot;Band-Pass: Driven LC Parallel&quot;) { <br> graphdomain = 1; <br> graphrange = 1; <br> SchemCap c1 = new SchemCap(200, 300, 1); <br> SchemInd i1 = new SchemInd(210, 250, 1); <br> SchemRes r1 = new SchemRes(300, c1.leadly, 1); <br> SchemACS a1 = new SchemACS(250, 200, 1); <br> schemcapacitors.add((SchemCap) c1); <br> scheminductors.add((SchemInd) i1); <br> schemresistors.add((SchemRes) r1); <br> schemacsources.add((SchemACS) a1); <br> schemwires.add(new SchemWire(c1.leadrx, c1.leadry, r1.leadlx, r1.leadly, 1)); <br> schemwires.add(new SchemWire((c1.leadlx) - 10, c1.leadly, (c1.leadlx) - 10, a1.leadly, 2)); <br> schemwires.add(new SchemWire((r1.leadrx) + 10, r1.leadry, (r1.leadrx) + 10, a1.leadry, 3)); <br> schemwires.add(new SchemWire((c1.leadlx) - 10, c1.leadly, c1.leadlx, c1.leadly, 4)); <br> schemwires.add(new SchemWire((r1.leadrx) + 10, r1.leadry, r1.leadrx, r1.leadry, 5)); <br> schemwires.add(new SchemWire((c1.leadlx) - 10, a1.leadly, a1.leadlx, a1.leadly, 6)); <br> schemwires.add(new SchemWire((r1.leadrx) + 10, a1.leadry, a1.leadrx, a1.leadry, 7)); <br> schemwires.add(new SchemWire((i1.leadlx) - 15, i1.leadly, i1.leadlx, i1.leadly, 8)); <br> schemwires.add(new SchemWire(((c1.leadrx + r1.leadlx)/2), c1.leadry, ((c1.leadrx+r1.leadlx)/2), i1.leadry, 9)); <br> schemwires.add(new SchemWire(i1.leadrx, i1.leadry, ((c1.leadrx+r1.leadlx)/2), i1.leadry, 10)); <br> schemouts.add(new SchemOUT(((c1.leadrx + r1.leadlx)/2), c1.leadry, ((c1.leadrx+r1.leadlx)/2), c1.leadry + 50, 1)); <br> schemgrounds.add(new SchemGround((c1.leadlx) - 10, c1.leadly, (c1.leadlx) - 10, (c1.leadly) +50, 1)); <br> } <br> else if (mode==&quot;Resonance (LC Tank)&quot;) { <br> } <br> else if (mode==&quot;Dual Resonant Air-Core Step-Up Transformer (Tesla Coil)&quot;) { <br> } <br> modelast = mode; <br> } <br> <br> <br> if (mode==&quot;Low-Pass Filter (RC)&quot;) { <br> <br> for (int i = schemcapacitors.size()-1; i &gt;= 0; i--) { <br> SchemCap capval = (SchemCap) schemcapacitors.get(i); <br> if (capval.id == 1) { <br> for (int ii = schemresistors.size()-1; ii &gt;= 0; ii--) { <br> SchemRes resval = (SchemRes) schemresistors.get(i); <br> if (resval.id == 1) { <br> for (int iii = schemacsources.size()-1; iii &gt;= 0; iii--) { <br> SchemACS acsval = (SchemACS) schemacsources.get(i); <br> if (acsval.id == 1) { <br> if (graphicaldisplay.symbol == &quot;PLOT&quot;) { <br> if (!bandWidth(5,voltagePoint(5, impedance(resval.value, 0, capacitiveReactance(capval.value, acsval.value)), capacitiveReactance(capval.value, acsval.value)))) { <br> graphpointcolor = color(255, 0, 0); <br> } <br> else { <br> graphpointcolor = color(0, 255, 150); <br> } <br> graph(&quot;Frequency&quot;, &quot;OUT1 Amplitude&quot;, 0, 10, 0, 5, acsval.value, voltagePoint(5, impedance(resval.value, 0, capacitiveReactance(capval.value, acsval.value)), capacitiveReactance(capval.value, acsval.value))); <br> } <br> //vector(new PVector(map(resval.value,0,1000,0,100),map(capacitiveReactance(capval.value, acsval.value),0,1000,0,-100))); <br> else if (graphicaldisplay.symbol == &quot;VECTOR&quot;) vector(&quot;Resistance&quot;, &quot;CapacitiveReactance&quot;, new PVector(resval.value, capacitiveReactance(capval.value, acsval.value)*-1)); <br> else if (graphicaldisplay.symbol == &quot;PHASOR&quot;) { <br> phasorthetas[0] = 0; <br> phasorthetas[1] = phaseShift(resval.value, capacitiveReactance(capval.value, acsval.value)); <br> phasormagnitudes[0] = 5; <br> phasormagnitudes[1] = voltagePoint(5, impedance(resval.value, 0, capacitiveReactance(capval.value, acsval.value)), capacitiveReactance(capval.value, acsval.value)); <br> phasorcolors[0] = color(0,255,100); <br> phasorcolors[1] = color(255,0,255); <br> phasorlabels[0] = &quot;SignalVoltage&quot;; <br> phasorlabels[1] = &quot;OUT1Voltage&quot;; <br> phasor(2, acsval.value*TWO_PI, phasorthetas, phasormagnitudes, phasorcolors, phasorlabels); <br> } <br> } <br> } <br> } <br> } <br> } <br> } <br> } <br> else if (mode==&quot;High-Pass Filter (RC)&quot;) { <br> } <br> else if (mode==&quot;Low-Pass Filter (RL)&quot;) { <br> } <br> else if (mode==&quot;High-Pass Filter (RL)&quot;) { <br> } <br> else if (mode==&quot;Band-Reject (Notch): Driven LC Series&quot;) { <br> } <br> else if (mode==&quot;Band-Pass: Driven LC Parallel&quot;) { <br> for (int i = schemcapacitors.size()-1; i &gt;= 0; i--) { <br> SchemCap capval = (SchemCap) schemcapacitors.get(i); <br> if (capval.id == 1) { <br> for (int ii = scheminductors.size()-1; ii &gt;= 0; ii--) { <br> SchemInd indval = (SchemInd) scheminductors.get(ii); <br> if (indval.id == 1) { <br> for (int iii = schemresistors.size()-1; iii &gt;= 0; iii--) { <br> SchemRes resval = (SchemRes) schemresistors.get(iii); <br> if (resval.id == 1) { <br> for (int iiii = schemacsources.size()-1; iiii &gt;= 0; iiii--) { <br> SchemACS acsval = (SchemACS) schemacsources.get(iiii); <br> if (acsval.id == 1) { <br> if (graphicaldisplay.symbol == &quot;PLOT&quot;) { <br> if (!bandWidth(5,voltagePoint(5, impedance(resval.value, 1/ ((1/inductiveReactance(indval.value, acsval.value))-(1/capacitiveReactance(capval.value, acsval.value))), 0), abs(1/ ((1/inductiveReactance(indval.value, acsval.value))-(1/capacitiveReactance(capval.value, acsval.value))))))) { <br> graphpointcolor = color(255, 0, 0); <br> } <br> else { <br> graphpointcolor = color(0, 255, 150); <br> } <br> if (acsval.value &gt; resonantFrequency(capval.value, indval.value)-.001 &amp;&amp; acsval.value &lt; resonantFrequency(capval.value, indval.value)+.001) graphpointcolor = color(255, 255, 255); <br> graph(&quot;Frequency&quot;, &quot;OUT1 Amplitude&quot;, 0, 10, 0, 5, acsval.value, voltagePoint(5, impedance(resval.value, 1/ ((1/inductiveReactance(indval.value, acsval.value))-(1/capacitiveReactance(capval.value, acsval.value))), 0), abs(1/ ((1/inductiveReactance(indval.value, acsval.value))-(1/capacitiveReactance(capval.value, acsval.value)))))); <br> } <br> //vector(new PVector(map(resval.value,0,1000,0,100),map(capacitiveReactance(capval.value, acsval.value),0,1000,0,-100))); <br> else if (graphicaldisplay.symbol == &quot;VECTOR&quot;) vector(&quot;Resistance&quot;, &quot;Reactance&quot;, new PVector(resval.value, ((1/inductiveReactance(indval.value, acsval.value))-(1/capacitiveReactance(capval.value, acsval.value))))); <br> else if (graphicaldisplay.symbol == &quot;PHASOR&quot;) { <br> phasorthetas[0] = 0; <br> phasorthetas[1] = phaseShift(resval.value, 1/inductiveReactance(indval.value, acsval.value) - 1/capacitiveReactance(capval.value, acsval.value)); <br> phasormagnitudes[0] = 5; <br> phasormagnitudes[1] = voltagePoint(5, impedance(resval.value, 1/ ((1/inductiveReactance(indval.value, acsval.value))-(1/capacitiveReactance(capval.value, acsval.value))), 0), abs(1/ ((1/inductiveReactance(indval.value, acsval.value))-(1/capacitiveReactance(capval.value, acsval.value))))); <br> phasorcolors[0] = color(0,255,100); <br> phasorcolors[1] = color(255,0,255); <br> phasorlabels[0] = &quot;SignalVoltage&quot;; <br> phasorlabels[1] = &quot;OUT1Voltage&quot;; <br> phasor(2, acsval.value*TWO_PI, phasorthetas, phasormagnitudes, phasorcolors, phasorlabels); <br> } <br> } <br> } <br> } <br> } <br> } <br> } <br> } <br> } <br> } <br> else if (mode==&quot;Resonance (LC Tank)&quot;) { <br> } <br> else if (mode==&quot;Dual Resonant Air-Core Step-Up Transformer (Tesla Coil)&quot;) { <br> } <br>} <br> <br>void displayTrashCan() { <br> stroke(0); <br> fill(color(100, 100, 100)); <br> rectMode(CORNER); <br> rect(50, 450, 20, 30); <br> rect(48, 445, 24, 5); <br> line(55, 450, 55, 480); <br> line(60, 450, 60, 480); <br> line(65, 450, 65, 480); <br>} <br> <br>class SchemWire { <br> float x1; <br> float y1; <br> float x2; <br> float y2; <br> int id; <br> boolean available; <br> <br> SchemWire(float tx1, float ty1, float tx2, float ty2, int tid) { <br> x1 = tx1; <br> x2 = tx2; <br> y1 = ty1; <br> y2 = ty2; <br> id = tid; <br> available = true; <br> } <br> <br> void display() { <br> fill(color(0, 0, 0)); <br> stroke(color(0, 0, 0)); <br> line(x1, y1, x2, y2); <br> ellipse(x1, y1, 4, 4); <br> ellipse(x2, y2, 4, 4); <br> } <br>} <br>class SchemOUT { <br> float x1; <br> float y1; <br> float x2; <br> float y2; <br> int id; <br> boolean available; <br> <br> SchemOUT(float tx1, float ty1, float tx2, float ty2, int tid) { <br> x1 = tx1; <br> x2 = tx2; <br> y1 = ty1; <br> y2 = ty2; <br> id = tid; <br> available = true; <br> } <br> <br> void display() { <br> fill(color(0, 0, 0)); <br> stroke(color(0, 0, 0)); <br> line(x1, y1, x2, y2); <br> ellipse(x1, y1, 4, 4); <br> textFont(font2); <br> text(&quot;OUT&quot;+str(id), x2, y2); <br> } <br>} <br> <br>class SchemGround { <br> float x1; <br> float y1; <br> float x2; <br> float y2; <br> int id; <br> boolean available; <br> <br> SchemGround(float tx1, float ty1, float tx2, float ty2, int tid) { <br> x1 = tx1; <br> x2 = tx2; <br> y1 = ty1; <br> y2 = ty2; <br> id = tid; <br> available = true; <br> } <br> <br> void display() { <br> fill(color(0, 0, 0)); <br> stroke(color(0, 0, 0)); <br> line(x1, y1, x2, y2); <br> ellipse(x1, y1, 4, 4); <br> line(x2 - 10, y2, x2 + 10, y2); <br> line(x2 - 7, y2 + 5, x2 + 7, y2 + 5); <br> line(x2 - 3, y2 + 10, x2 + 3, y2 + 10); <br> } <br>} <br> <br>class SchemCap { <br> float xpos; <br> float ypos; <br> float cxpos; <br> float cypos; <br> float leadlx; <br> float leadly; <br> float leadrx; <br> float leadry; <br> float value; <br> int id; <br> boolean available; <br> int check; <br> <br> SchemCap(float txpos, float typos, int tid) { <br> xpos = txpos; <br> ypos = typos; <br> cxpos = xpos; <br> cypos = ypos + 15; <br> leadlx = xpos - 5; <br> leadly = ypos + 15; <br> leadrx = xpos + 10; <br> leadry = ypos + 15; <br> id = tid; <br> available = true; <br> } <br> <br> void update() { <br> //value = ((Capacitor) capacitors.get(check)).value; <br> if (available) value = 0; <br> <br> //available = true; <br> //value = 0; <br> for (int i = capacitors.size()-1; i &gt;= 0; i--) { <br> Capacitor testcap = (Capacitor) capacitors.get(i); <br> if (testcap.applied) { <br> if (testcap.held) { <br> available = true; <br> value = 0; <br> testcap.applied = false; <br> } <br> else { <br> value = testcap.value; <br> } <br> } <br> if ((testcap.centerx &gt; cxpos - 15)&amp;&amp;(testcap.centerx &lt; cxpos + 15) <br> &amp;&amp;(testcap.centery &gt; cypos - 15)&amp;&amp;(testcap.centery &lt; cypos + 15) <br> &amp;&amp;(!testcap.held)&amp;&amp;(available)) { <br> testcap.centerx = cxpos; <br> testcap.centery = cypos; <br> value = testcap.value; <br> check = i; <br> available = false; <br> testcap.applied = true; <br> } <br> capacitors.add((Capacitor) testcap); <br> capacitors.remove(i); <br> } <br> display(); <br> <br> /*desunits = &quot;test&quot;; <br> desval = value; <br> description(); <br> */ <br> /* //TEST: <br> if(available) desunits = &quot;true&quot;; <br> else desunits = &quot;false&quot;; <br> description(); */ <br> } <br> <br> void display() { <br> stroke(0, 0, 0); <br> line(xpos - 5, ypos, xpos - 5, ypos + 30); <br> line(xpos + 10, ypos, xpos + 10, ypos + 30); <br> } <br>} <br> <br>class SchemInd { <br> float xpos; <br> float ypos; <br> float leadlx; <br> float leadly; <br> float leadrx; <br> float leadry; <br> float value; <br> int id; <br> boolean available; <br> int check; <br> <br> SchemInd(float txpos, float typos, int tid) { <br> xpos = txpos; <br> ypos = typos; <br> leadlx = xpos - 10; <br> leadly = ypos; <br> leadrx = xpos + 10; <br> leadry = ypos; <br> id = tid; <br> available = true; <br> } <br> <br> void update() { <br> //value = ((Inductor) inductors.get(check)).value; <br> if (available) value = 0; <br> //available = true; <br> //value = 0; <br> <br> for (int i = inductors.size()-1; i &gt;= 0; i--) { <br> Inductor testind = (Inductor) inductors.get(i); <br> if (testind.applied) { <br> if (testind.held) { <br> available = true; <br> value = 0; <br> testind.applied = false; <br> } <br> else { <br> value = testind.value; <br> } <br> } <br> if ((testind.centerx &gt; xpos - 10)&amp;&amp;(testind.centerx &lt; xpos + 10) <br> &amp;&amp;(testind.centery &gt; ypos - 10)&amp;&amp;(testind.centery &lt; ypos + 10) <br> &amp;&amp;(!testind.held)&amp;&amp;(available)) { <br> testind.centerx = xpos; <br> testind.centery = ypos; <br> value = testind.value; <br> check = i; <br> available = false; <br> testind.applied = true; <br> } <br> inductors.add((Inductor) testind); <br> inductors.remove(i); <br> } <br> display(); <br> } <br> <br> void display() { <br> noFill(); <br> stroke(color(0, 0, 0)); <br> for (int i = 0; i &lt; 3; i++) { <br> arc(xpos + (-10 + (10 * i)), ypos, 10, 30, PI, TWO_PI); <br> } <br> } <br>} <br> <br>class SchemRes { <br> float xpos; <br> float ypos; <br> float cxpos; <br> float cypos; <br> float leadlx; <br> float leadly; <br> float leadrx; <br> float leadry; <br> float value; <br> int id; <br> boolean available; <br> int check; <br> <br> SchemRes(float txpos, float typos, int tid) { <br> xpos = txpos; <br> ypos = typos; <br> cxpos = xpos + 15; <br> cypos = ypos; <br> leadlx = xpos; <br> leadly = ypos; <br> leadrx = xpos + 30; <br> leadry = ypos; <br> id = tid; <br> available = true; <br> } <br> <br> void update() { <br> //value = ((Resistor) resistors.get(check)).value; <br> if (available) value = 0; <br> //available = true; <br> //value = 0; <br> <br> for (int i = resistors.size()-1; i &gt;= 0; i--) { <br> Resistor testres = (Resistor) resistors.get(i); <br> if (testres.applied) { <br> if (testres.held) { <br> available = true; <br> value = 0; <br> testres.applied = false; <br> } <br> else { <br> value = testres.value; <br> } <br> } <br> if ((testres.centerx &gt; cxpos - 10)&amp;&amp;(testres.centerx &lt; cxpos + 10) <br> &amp;&amp;(testres.centery &gt; cypos - 10)&amp;&amp;(testres.centery &lt; cxpos + 10) <br> &amp;&amp;(!testres.held)&amp;&amp;(available)) { <br> testres.centerx = cxpos; <br> testres.centery = cypos; <br> value = testres.value; <br> check = i; <br> available = false; <br> testres.applied = true; <br> } <br> resistors.add((Resistor) testres); <br> resistors.remove(i); <br> } <br> display(); <br> } <br> <br> void display() { <br> stroke(color(0, 0, 0)); <br> line(xpos, ypos, xpos+5, ypos-10); <br> line(xpos+5, ypos-10, xpos+10, ypos); <br> line(xpos+10, ypos, xpos+15, ypos-10); <br> line(xpos+15, ypos-10, xpos+20, ypos); <br> line(xpos+20, ypos, xpos+25, ypos-10); <br> line(xpos+25, ypos-10, xpos+30, ypos); <br> } <br>} <br> <br>class SchemACS { <br> float xpos; <br> float ypos; <br> float leadlx; <br> float leadly; <br> float leadrx; <br> float leadry; <br> float value; <br> int id; <br> boolean available; <br> int check; <br> <br> SchemACS(float txpos, float typos, int tid) { <br> xpos = txpos; <br> ypos = typos; <br> leadlx = xpos - 15; <br> leadly = ypos; <br> leadrx = xpos + 15; <br> leadry = ypos; <br> id = tid; <br> available = true; <br> } <br> <br> void update() { <br> //value = ((ACSource) acsources.get(check)).value; <br> if (available) value = 0; <br> //available = true; <br> //value = 0; <br> for (int i = acsources.size()-1; i &gt;= 0; i--) { <br> ACSource testacs = (ACSource) acsources.get(i); <br> if (testacs.applied) { <br> if (testacs.held) { <br> testacs.applied = false; <br> available = true; <br> value = 0; <br> } <br> else { <br> value = testacs.value; <br> } <br> } <br> if ((testacs.centerx &gt; xpos - 10)&amp;&amp;(testacs.centerx &lt; xpos + 10) <br> &amp;&amp;(testacs.centery &gt; ypos - 10)&amp;&amp;(testacs.centery &lt; xpos + 10) <br> &amp;&amp;(!testacs.held)&amp;&amp;(available)) { <br> testacs.centerx = xpos; <br> testacs.centery = ypos; <br> value = testacs.value; <br> check = i; <br> available = false; <br> testacs.applied = true; <br> } <br> acsources.add((ACSource) testacs); <br> acsources.remove(i); <br> } <br> <br> display(); <br> } <br> <br> void display() { <br> noFill(); <br> stroke(color(0, 0, 0)); <br> ellipse(xpos, ypos, 30, 30); <br> for (int i=0;i&lt;20;i++) { <br> set(int(xpos)-10+i, int(ypos)+int((-10*sin((TWO_PI*i)/20))), color(0, 0, 0)); <br> } <br> } <br>} <br> <br>void updateSchemCap() { <br> for (int i = schemcapacitors.size()-1; i &gt;= 0; i--) { <br> SchemCap update = (SchemCap) schemcapacitors.get(i); <br> update.update(); <br> schemcapacitors.add((SchemCap) update); <br> schemcapacitors.remove(i); <br> } <br>} <br> <br>void updateSchemInd() { <br> for (int i = scheminductors.size()-1; i &gt;= 0; i--) { <br> SchemInd update = (SchemInd) scheminductors.get(i); <br> update.update(); <br> scheminductors.add((SchemInd) update); <br> scheminductors.remove(i); <br> } <br>} <br> <br>void updateSchemRes() { <br> for (int i = schemresistors.size()-1; i &gt;= 0; i--) { <br> SchemRes update = (SchemRes) schemresistors.get(i); <br> update.update(); <br> schemresistors.add((SchemRes) update); <br> schemresistors.remove(i); <br> } <br>} <br> <br>void updateSchemACS() { <br> for (int i = schemacsources.size()-1; i &gt;= 0; i--) { <br> SchemACS update = (SchemACS) schemacsources.get(i); <br> update.update(); <br> schemacsources.add((SchemACS) update); <br> schemacsources.remove(i); <br> } <br>} <br>void updateSchemWire() { <br> for (int i = schemwires.size()-1; i &gt;= 0; i--) { <br> SchemWire update = (SchemWire) schemwires.get(i); <br> update.display(); <br> } <br>} <br>void updateSchemOUT() { <br> for (int i = schemouts.size()-1; i &gt;= 0; i--) { <br> SchemOUT update = (SchemOUT) schemouts.get(i); <br> update.display(); <br> } <br>} <br>void updateSchemGround() { <br> for (int i = schemgrounds.size()-1; i &gt;= 0; i--) { <br> SchemGround update = (SchemGround) schemgrounds.get(i); <br> update.display(); <br> } <br>} <br> <br> <br> <br>/***************************************************************************************************/ <br>////////// ///////// // // //////// //////// ////// ////////// /// // ///////// <br>/// // // // // // // // // // // // // // /// <br>////////// // // // // //////// // // // // // // // ///////// <br>/// // ////// // // // // // // // // // // // /// <br>////////// ///////// ///////// // // // ////// ////////// // //// ///////// <br>/***************************************************************************************************/ <br> <br>float impedance(float R, float Xl, float Xc) { <br> return(sqrt(sq(R)+sq(Xl-Xc))); <br>} <br> <br>float inductiveReactance(float L, float f) { <br> return(TWO_PI*f*L); <br>} <br> <br>float capacitiveReactance(float C, float f) { <br> return(1 / (TWO_PI*f*C)); <br>} <br> <br>float resonantFrequency(float L, float C) { <br> return(1 / (TWO_PI*sqrt(L*C))); <br>} <br> <br>float phaseShift(float R, float X) { <br> return atan(X/R); <br>} <br> <br>float voltagePoint(float Vt, float Rt, float R) { <br> return(Vt*(R / Rt)); <br>} <br> <br>boolean bandWidth(float amplitudein, float amplitudeout) { <br> if (amplitudeout &lt; (amplitudein/2)) { <br> return false; <br> } <br> else return true; <br>} <br>
import processing.serial.*; <br>Serial port; <br> <br>String serialdata = &quot;&quot;; <br>String[] serialsplit = { <br> &quot;&quot;, &quot;&quot; <br>}; <br>float lastedit = 0; <br>float editincrement = 1; <br>int keylast; <br>int lastX; <br>int lastY; <br>int currentX; <br>int currentY; <br>int dmouseX; <br>int dmouseY; <br>int tolerance = 0; <br>int particleslastgenerate = 0; <br>int particleslastupdate = 0; <br>boolean mousestatelast; <br>boolean holding = false; <br>boolean editing = false; <br>boolean overduino = false; <br>int arduinoalpha = 0; <br>color graphpointcolor = color(0, 255, 150); <br>float graphdomain = 1; <br>float graphrange = 1; <br>float desval = 0; <br>float phasortime = 0; <br>float phasortimecoefficient = -1; <br>float[] phasorthetas = new float[5]; <br>float[] phasormagnitudes = new float[5]; <br>color[] phasorcolors = new color[5]; <br>String[] phasorlabels = new String[5]; <br>String desunits = &quot;NONE&quot;; <br>String mode = &quot;Low-Pass Filter (RC)&quot;; <br>String modelast = &quot;NONE&quot;; <br> <br>PImage Arduino; <br>PFont font; <br>PFont font2; <br>Button modeswitch; <br>Button addcap; <br>Button addind; <br>Button addres; <br>Button addacs; <br>Button decreasedomain; <br>Button increasedomain; <br>Button decreaserange; <br>Button increaserange; <br>Button increasephasortimecoefficient; <br>Button decreasephasortimecoefficient; <br>Button graphicaldisplay; <br>Capacitor capacitor1; <br>Capacitor capacitor2; <br>Inductor inductor1; <br>ACSource ac1; <br>Resistor resistor1; <br>ArrayList particles; <br>ArrayList capacitors; <br>ArrayList inductors; <br>ArrayList resistors; <br>ArrayList acsources; <br>ArrayList schemwires; <br>ArrayList schemouts; <br>ArrayList schemgrounds; <br>ArrayList schemcapacitors; <br>ArrayList scheminductors; <br>ArrayList schemresistors; <br>ArrayList schemacsources; <br>//SchemInd sind1; <br>//SchemCap scap1; <br>//SchemRes sres1; <br>//SchemACS sacs1; <br>//SchemWire swire1; <br>//SchemOUT sout1; <br> <br>void setup() { <br> size(800, 500); <br> port = new Serial(this, &quot;COM4&quot;, 9600); <br> port.bufferUntil('\n'); <br> Arduino = loadImage(&quot;arduino_icon.png&quot;); <br> Arduino.resize(0, 50); <br> font = loadFont(&quot;EurostileBold-20.vlw&quot;); <br> font2 = loadFont(&quot;EurostileRegular-12.vlw&quot;); <br> textFont(font); <br> <br> modeswitch = new Button(color(150, 100, 0), 200, 400, 100, 30, &quot;NextCircuit&quot;); <br> addcap = new Button(color(0, 0, 120), 100, 15, 30, 30, &quot;C&quot;); <br> addind = new Button(color(200, 100, 0), 200, 15, 30, 30, &quot;L&quot;); <br> addres = new Button(color(200, 0, 0), 300, 15, 30, 30, &quot;R&quot;); <br> addacs = new Button(color(0, 200, 100), 400, 15, 30, 30, &quot;AC&quot;); <br> decreasedomain = new Button(color(0, 255, 150), 550, 340, 90, 30, &quot; -Domain&quot;); <br> increasedomain = new Button(color(0, 255, 150), 640, 340, 90, 30, &quot; +Domain&quot;); <br> decreaserange = new Button(color(0, 255, 150), 550, 370, 90, 30, &quot; -Range&quot;); <br> increaserange = new Button(color(0, 255, 150), 640, 370, 90, 30, &quot; +Range&quot;); <br> increasephasortimecoefficient = new Button(color(0, 255, 150), 640, 370, 90, 30, &quot; +Omega&quot;); <br> decreasephasortimecoefficient = new Button(color(0, 255, 150), 550, 370, 90, 30, &quot; -Omega&quot;); <br> graphicaldisplay = new Button(color(0, 255, 125), 550, 15, 90, 30, &quot;PLOT&quot;); <br> capacitor1 = new Capacitor(color(0, 175, 255), 85, 60, .001); <br> capacitor2 = new Capacitor(color(0, 0, 255), 200, 10, .002); <br> inductor1 = new Inductor(color(255, 125, 0), 200, 60, .001); <br> ac1 = new ACSource(color(200, 200, 200), 400, 60, 1000); <br> resistor1 = new Resistor(color(255, 0, 0), 300, 60, 100); <br> particles = new ArrayList(); <br> capacitors = new ArrayList(); <br> inductors = new ArrayList(); <br> resistors = new ArrayList(); <br> acsources = new ArrayList(); <br> schemwires = new ArrayList(); <br> schemouts = new ArrayList(); <br> schemgrounds = new ArrayList(); <br> schemcapacitors = new ArrayList(); <br> scheminductors = new ArrayList(); <br> schemresistors = new ArrayList(); <br> schemacsources = new ArrayList(); <br> capacitors.add((Capacitor) capacitor1); <br> inductors.add((Inductor) inductor1); <br> resistors.add((Resistor) resistor1); <br> acsources.add((ACSource) ac1); <br> //sind1 = new SchemInd(200, 200, 1); <br> //scap1 = new SchemCap(300, 300, 1); <br> //sres1 = new SchemRes(300, 200, 1); <br> //sacs1 = new SchemACS(400, 300, 1); <br> //swire1 = new SchemWire(100, 200, 100, 250, 1); <br> //sout1 = new SchemOUT(100, 100, 200, 200, 1); <br> //scheminductors.add((SchemInd) sind1); <br> //schemcapacitors.add((SchemCap) scap1); <br> //schemresistors.add((SchemRes) sres1); <br> //schemacsources.add((SchemACS) sacs1); <br> //schemwires.add((SchemWire) swire1); <br>} <br> <br>void draw() { <br> background(255); <br> color(0); <br> //text(serialsplit[0], 100, 100); <br> serialdata = &quot;&quot;; <br> strokeWeight(1); <br> keylast = 0; <br> if (keyPressed) keylast = key; <br> displayAll(); <br> updateAll(); <br> currentX = mouseX; <br> currentY = mouseY; <br> dmouseX = (currentX - lastX); <br> dmouseY = (currentY - lastY); <br> lastX = mouseX; <br> lastY = mouseY; <br> modeswitch.display(); <br> addcap.display(); <br> addind.display(); <br> addres.display(); <br> addacs.display(); <br> if (modeswitch.isPressed() &amp;&amp; !mousestatelast) { <br> if (mode == &quot;Low-Pass Filter (RC)&quot;) mode = &quot;High-Pass Filter (RC)&quot;; <br> else if (mode==&quot;High-Pass Filter (RC)&quot;) { <br> mode = &quot;Low-Pass Filter (RL)&quot;; <br> } <br> else if (mode==&quot;Low-Pass Filter (RL)&quot;) { <br> mode = &quot;High-Pass Filter (RL)&quot;; <br> } <br> else if (mode==&quot;High-Pass Filter (RL)&quot;) { <br> mode = &quot;Band-Reject (Notch): Driven LC Series&quot;; <br> } <br> else if (mode==&quot;Band-Reject (Notch): Driven LC Series&quot;) { <br> mode = &quot;Band-Pass: Driven LC Parallel&quot;; <br> } <br> else if (mode==&quot;Band-Pass: Driven LC Parallel&quot;) { <br> mode = &quot;Resonance (LC Tank)&quot;; <br> } <br> else if (mode==&quot;Resonance (LC Tank)&quot;) { <br> mode = &quot;Dual Resonant Air-Core Step-Up Transformer (Tesla Coil)&quot;; <br> } <br> else if (mode==&quot;Dual Resonant Air-Core Step-Up Transformer (Tesla Coil)&quot;) { <br> mode = &quot;Low-Pass Filter (RC)&quot;; <br> } <br> } <br> if (addcap.isPressed() &amp;&amp; !mousestatelast) capacitors.add(new Capacitor(color(random(0, 100), random(0, 100), 55+random(0, 200)), 85, 60, .001)); <br> if (addind.isPressed() &amp;&amp; !mousestatelast) inductors.add(new Inductor(color(200+random(-50, 50), 100+random(-50, 50), 0), 200, 60, .001)); <br> if (addres.isPressed() &amp;&amp; !mousestatelast) resistors.add(new Resistor(color(100+random(0, 100), random(0, 50), 0), 300, 60, .001)); <br> if (addacs.isPressed() &amp;&amp; !mousestatelast) acsources.add(new ACSource(color(50+random(0, 200), 50+random(0, 200), 50+random(0, 200)), 400, 60, .001)); <br> graphicaldisplay.display(); <br> if (graphicaldisplay.isPressed() &amp;&amp; !mousestatelast) { <br> if (graphicaldisplay.symbol == &quot;PLOT&quot;) graphicaldisplay.symbol = &quot;VECTOR&quot;; <br> else if (graphicaldisplay.symbol == &quot;VECTOR&quot;) graphicaldisplay.symbol = &quot;PHASOR&quot;; <br> else if (graphicaldisplay.symbol == &quot;PHASOR&quot;) graphicaldisplay.symbol = &quot;PLOT&quot;; <br> } <br> if (graphicaldisplay.symbol == &quot;PHASOR&quot;) { <br> phasortime += .000000001; <br> } <br> else phasortime = 0; <br> if (graphicaldisplay.symbol == &quot;PLOT&quot;) { <br> decreasedomain.display(); <br> increasedomain.display(); <br> decreaserange.display(); <br> increaserange.display(); <br> if (decreasedomain.isPressed() &amp;&amp; !mousestatelast) graphdomain = (graphdomain * .1); <br> if (increasedomain.isPressed() &amp;&amp; !mousestatelast) graphdomain = (graphdomain * 10); <br> if (decreaserange.isPressed() &amp;&amp; !mousestatelast) graphrange = (graphrange * .1); <br> if (increaserange.isPressed() &amp;&amp; !mousestatelast) graphrange = (graphrange * 10); <br> } <br> if (graphicaldisplay.symbol == &quot;PHASOR&quot;) { <br> decreasephasortimecoefficient.display(); <br> increasephasortimecoefficient.display(); <br> if (decreasephasortimecoefficient.isPressed() &amp;&amp; !mousestatelast) phasortimecoefficient *= .1; <br> if (increasephasortimecoefficient.isPressed() &amp;&amp; !mousestatelast) phasortimecoefficient *= 10; <br> } <br> if (!holding) { <br> desval = 0; <br> desunits = &quot;NONE&quot;; <br> } <br> description(); <br> updateSchematic(); <br> if(overduino) { <br> arduinoalpha += 10; <br> if(arduinoalpha&gt;250) arduinoalpha = 0; <br> } <br> else { <br> arduinoalpha = 255; <br> } <br> tint(255, arduinoalpha); <br> image(Arduino, 0, 200); <br> overduino = false; <br> mouseStateUpdate(mousePressed); <br>} <br> <br>void serialEvent(Serial port) { <br> serialdata = port.readStringUntil('\n'); <br> serialsplit = (String[])split(serialdata, '_'); <br>} <br>boolean overArduino(float x, float y) { <br> if ((sqrt(sq(25-x)+sq(225-y)))&lt;30) { <br> overduino = true; <br> return true; <br> } <br> else return false; <br>} <br>void requestImport(String units) { <br> port.write(&quot;request&quot;+units); <br> port.write('\n'); <br>} <br>class Button { <br> <br> boolean pressed = false; <br> int lastclicktime = 0; <br> float xpos; <br> float ypos; <br> float widthv; <br> float heightv; <br> float leftbound; <br> float rightbound; <br> float upperbound; <br> float lowerbound; <br> color colorv; <br> String symbol; <br> <br> Button(color Tempcolorv, float Tempxpos, float Tempypos, float Tempwidthv, float Tempheightv, String Tempsymbol) { <br> xpos = Tempxpos; <br> ypos = Tempypos; <br> widthv = Tempwidthv; <br> heightv = Tempheightv; <br> leftbound = xpos - widthv/2; <br> rightbound = xpos + widthv/2; <br> upperbound = ypos - heightv/2; <br> lowerbound = ypos + heightv/2; <br> colorv = Tempcolorv; <br> symbol = Tempsymbol; <br> } <br> <br> void display() { <br> stroke(0); <br> fill(colorv); <br> rectMode(CENTER); <br> rect(xpos, ypos, widthv, heightv); <br> fill(255); <br> textFont(font); <br> text(symbol, leftbound, ypos); <br> } <br> <br> boolean isMouseOver() { <br> if (mouseX &gt; leftbound &amp;&amp; mouseX &lt; rightbound <br> &amp;&amp; mouseY &gt; upperbound &amp;&amp; mouseY &lt; lowerbound) { <br> return true; <br> } <br> else return false; <br> } <br> boolean isPressed() { <br> if (mousePressed &amp;&amp; isMouseOver()) { <br> if (pressed) return true; <br> else if (mousePressed &amp;&amp; mousestatelast == false) { <br> lastclicktime = millis()/100; <br> pressed = true; <br> return true; <br> } <br> else return false; <br> } <br> else return false; <br> } <br>} <br> <br>class Element { <br> String units; <br> float value; <br> color c; <br> float xpos; <br> float ypos; <br> float centerx; <br> float centery; <br> int area = 50; <br> boolean held; <br> boolean edit = false; <br> boolean applied; <br> boolean isfinished = false; <br> <br> <br> <br> void update() { <br> if ((centerx &gt; 50) &amp;&amp; (centerx &lt; 70) &amp;&amp; (centery &gt; 450) &amp;&amp; (centery &lt; 480)) { <br> isfinished = true; <br> held = false; <br> holding = false; <br> } <br> if (held &amp;&amp; !mousePressed) <br> { <br> holding = false; <br> } <br> if (edit &amp;&amp; (keylast == 32)) { <br> <br> editing = false; <br> } <br> if (held &amp;&amp; mousePressed) <br> { <br> <br> centerx = mouseX; <br> centery = mouseY; <br> if (!overArduino(centerx, centery)) { <br> generateSparks(0, .7, .04, .04, 3, color(0, 245, 245)); <br> } <br> else { <br> generateSparks(random(0, 1), random(-1, 1), .10, .10, 3, color(0, 245, 245)); <br> //if (serialsplit[0] == units) { <br> if (units == &quot;Farads&quot; || units == &quot;Henrys&quot;) value = float(serialsplit[0])/1000000000; <br> else value = float(serialsplit[0]); <br> //} <br> requestImport(units); <br> } <br> } <br> else <br> { <br> held = false; <br> } <br> <br> if (edit) { <br> desunits = units; <br> desval = value; <br> description(); <br> stroke(color(0, 255, 55+((sin(float(millis())/1000)+1)*.5)*200)); <br> noFill(); <br> ellipse(centerx, centery, area, area); <br> ellipse(centerx, centery, <br> (area + (3*sin(millis()/100))), <br> (area + (3*cos(millis()/100)))); <br> } <br> <br> if (edit &amp;&amp; (lastedit &lt; ((millis()/10) - 10))) { <br> if (keyPressed) { <br> if (keylast == 100) { <br> value += editincrement; <br> } <br> if (keylast == 97) { <br> value -= editincrement; <br> } <br> if (lastedit &lt; ((millis()/10) - 20)) { <br> if (keylast == 119) { <br> editincrement = (editincrement*10); <br> } <br> if (keylast == 115) { <br> editincrement = (editincrement/10); <br> } <br> } <br> lastedit = (millis()/10); <br> } <br> } <br> <br> <br> if ( mouseX &gt; ((centerx - 15) - tolerance) <br> &amp;&amp; mouseX &lt; ((centerx + 15) + tolerance) <br> &amp;&amp; mouseY &gt; ((centery - 20) - tolerance) <br> &amp;&amp; mouseY &lt; ((centery + 20) + tolerance) <br> &amp;&amp; !held) <br> { <br> noFill(); <br> if (true) { <br> if (keylast == 32) { <br> editing = true; <br> edit = true; <br> } <br> } <br> if (edit) stroke(color(0, 255, 55+((sin(float(millis())/1000)+1)*.5)*200)); <br> else stroke(color(0, 0, 0)); <br> ellipse(centerx, centery, area, area); <br> ellipse(centerx, centery, <br> (area + (3*sin(millis()/100))), <br> (area + (3*cos(millis()/100)))); <br> if (mousePressed &amp;&amp; mousestatelast == false) { <br> if (holding == false) { <br> holding = true; <br> held = true; <br> desval = value; <br> desunits = units; <br> } <br> } <br> } <br> else { <br> if (edit &amp;&amp; keylast == 32) { <br> editing = false; <br> edit = false; <br> } <br> } <br> } <br>} <br> <br> <br> <br> <br> <br> <br> <br> <br>class Capacitor extends Element { <br> <br> Capacitor(color tempC, float tempXpos, float tempYpos, float tempValue) { <br> units = &quot;Farads&quot;; <br> value = tempValue; <br> c = tempC; <br> xpos = tempXpos; <br> ypos = tempYpos; <br> centerx = xpos + 10; <br> centery = ypos; <br> } <br> <br> <br> <br> <br> void display() { <br> //centerx = xpos + 10; <br> //centery = ypos; <br> stroke(0); <br> fill(c); <br> rectMode(CENTER); <br> rect(centerx - 5, centery, 5, 30); <br> rect(centerx - 5 + 15, centery, 5, 30); <br> } <br>} <br> <br>class Inductor extends Element { <br> <br> Inductor(color tempC, float tempXpos, float tempYpos, float tempValue) { <br> units = &quot;Henrys&quot;; <br> value = tempValue; <br> c = tempC; <br> xpos = tempXpos; <br> ypos = tempYpos; <br> centerx = xpos; <br> centery = ypos; <br> } <br> <br> <br> <br> <br> void display() { <br> stroke(0); <br> fill(c); <br> //beginShape(); <br> /* curveVertex(centerx - 20, centery - 10); <br> curveVertex(centerx - 15, centery); <br> curveVertex(centerx - 10, centery - 10); <br> curveVertex(centerx - 5, centery); <br> curveVertex(centerx, centery - 10); <br> curveVertex(centerx + 5, centery); <br> curveVertex(centerx + 10, centery - 10); <br> curveVertex(centerx + 15, centery); <br> curveVertex(centerx + 15, centery + 10); <br> curveVertex(centerx + 10, centery); <br> curveVertex(centerx + 5, centery + 10); <br> curveVertex(centerx, centery); <br> curveVertex(centerx - 5, centery + 10); <br> curveVertex(centerx - 10, centery); <br> curveVertex(centerx - 15, centery + 10); <br> curveVertex(centerx - 20, centery); <br> */ <br> for (int i = 0; i &lt; 3; i++) { <br> fill(c); <br> arc(centerx + (-10 + (10 * i)), centery + 5, 10, 40, PI, TWO_PI); <br> noFill(); <br> arc(centerx + (-10 + (10 * i)), centery + 5, 5, 30, PI, TWO_PI); <br> } <br> //endShape(CLOSE); <br> } <br>} <br> <br>class Resistor extends Element { <br> <br> Resistor(color tempC, float tempXpos, float tempYpos, float tempValue) { <br> units = &quot;Ohms&quot;; <br> value = tempValue; <br> c = tempC; <br> xpos = tempXpos; <br> ypos = tempYpos; <br> centerx = xpos; <br> centery = ypos; <br> } <br> <br> <br> <br> <br> void display() { <br> stroke(0); <br> fill(c); <br> beginShape(); <br> curveVertex(centerx - 20, centery - 10); <br> curveVertex(centerx - 15, centery); <br> curveVertex(centerx - 10, centery - 10); <br> curveVertex(centerx - 5, centery); <br> curveVertex(centerx, centery - 10); <br> curveVertex(centerx + 5, centery); <br> curveVertex(centerx + 10, centery - 10); <br> curveVertex(centerx + 15, centery); <br> curveVertex(centerx + 15, centery + 10); <br> curveVertex(centerx + 10, centery); <br> curveVertex(centerx + 5, centery + 10); <br> curveVertex(centerx, centery); <br> curveVertex(centerx - 5, centery + 10); <br> curveVertex(centerx - 10, centery); <br> curveVertex(centerx - 15, centery + 10); <br> curveVertex(centerx - 20, centery); <br> endShape(CLOSE); <br> } <br>} <br> <br>class ACSource extends Element { <br> <br> ACSource(color tempC, float tempXpos, float tempYpos, float tempValue) { <br> units = &quot;Hertz&quot;; <br> value = tempValue; <br> c = tempC; <br> xpos = tempXpos; <br> ypos = tempYpos; <br> centerx = xpos; <br> centery = ypos; <br> } <br> <br> <br> <br> <br> void display() { <br> //centerx = xpos + 10; <br> //centery = ypos; <br> stroke(0); <br> fill(c); <br> ellipse(centerx, centery, 30, 30); <br> for (int i = 0; i &lt; 20; i++) { <br> /*set(-10 + i + int(centerx), int(((sin((i*TWO_PI)/20) * -10) + int(centery))), color(255*(-1*sin((i*TWO_PI)/20) + 1), 0, 255*(sin((i*TWO_PI)/20) + 1))); <br> set(-10 + i + int(centerx), int(((sin((i*TWO_PI)/20) * -10) + int(centery) - 1)), color(255*(-1*sin((i*TWO_PI)/20) + 1), 0, 255*(sin((i*TWO_PI)/20) + 1))); <br> set(-10 + i + int(centerx), int(((sin((i*TWO_PI)/20) * -10) + int(centery) + 1)), color(255*(-1*sin((i*TWO_PI)/20) + 1), 0, 255*(sin((i*TWO_PI)/20) + 1))); <br> set(-10 + i + int(centerx), int(((sin((i*TWO_PI)/20) * -10) + int(centery) - 2)), color(255*(-1*sin((i*TWO_PI)/20) + 1), 0, 255*(sin((i*TWO_PI)/20) + 1))); <br> set(-10 + i + int(centerx), int(((sin((i*TWO_PI)/20) * -10) + int(centery) + 2)), color(255*(-1*sin((i*TWO_PI)/20) + 1), 0, 255*(sin((i*TWO_PI)/20) + 1))); <br> set(-10 + i + int(centerx), int(((sin((i*TWO_PI)/20) * -10) + int(centery) - 3)), color(255*(-1*sin((i*TWO_PI)/20) + 1), 0, 255*(sin((i*TWO_PI)/20) + 1))); <br> set(-10 + i + int(centerx), int(((sin((i*TWO_PI)/20) * -10) + int(centery) + 3)), color(255*(-1*sin((i*TWO_PI)/20) + 1), 0, 255*(sin((i*TWO_PI)/20) + 1))); <br> */ <br> set(-10 + i + int(centerx), int(((sin((i*TWO_PI)/20) * -10) + int(centery))), color(0, 255, 125)); <br> set(-10 + i + int(centerx), int(((sin((i*TWO_PI)/20) * -10) + int(centery) - 1)), color(0, 255, 125)); <br> set(-10 + i + int(centerx), int(((sin((i*TWO_PI)/20) * -10) + int(centery) + 1)), color(0, 255, 125)); <br> set(-10 + i + int(centerx), int(((sin((i*TWO_PI)/20) * -10) + int(centery) - 2)), color(0, 255, 125)); <br> set(-10 + i + int(centerx), int(((sin((i*TWO_PI)/20) * -10) + int(centery) + 2)), color(0, 255, 125)); <br> set(-10 + i + int(centerx), int(((sin((i*TWO_PI)/20) * -10) + int(centery) - 3)), color(0, 255, 125)); <br> set(-10 + i + int(centerx), int(((sin((i*TWO_PI)/20) * -10) + int(centery) + 3)), color(0, 255, 125)); <br> set(-10 + i + int(centerx), int(((sin((i*TWO_PI)/20) * -10) + int(centery) - 4)), color(0, 0, 0)); <br> set(-10 + i + int(centerx), int(((sin((i*TWO_PI)/20) * -10) + int(centery) + 4)), color(0, 0, 0)); <br> set(-10 + i + int(centerx), int(((sin((i*TWO_PI)/20) * -10) + int(centery) - 5)), color(0, 0, 0)); <br> set(-10 + i + int(centerx), int(((sin((i*TWO_PI)/20) * -10) + int(centery) + 5)), color(0, 0, 0)); <br> } <br> /*ellipse(centerx, centery, 20 <br> arc(centerx - 5, centery, 10, 10, 0, PI); <br> arc(centerx +5, centery, 10, 10, PI, TWO_PI); <br> */ <br> } <br>} <br> <br>class Sparks { <br> <br> PVector location; <br> PVector movement; <br> PVector acceleration; <br> float radiusv[] = new float[6]; <br> float thetav[] = new float[6]; <br> float thetao; <br> float omega; <br> float sizev; <br> color colorv; <br> int birth; <br> int lifetime; <br> <br> Sparks(float dx, float dy, float ddx, float ddy, float sizecoefficient, color sparkcolor) { <br> location = new PVector(mouseX + random(-2, 2), mouseY + random(-2, 2), 0); <br> movement = new PVector(dx + random(-.1, .1), dy + random(-.1, .1), 0); <br> acceleration = new PVector(1 + ddx + random(-.01, .01), 1 + ddy + random(-.01, .01), 0); <br> radiusv[0] = 0; <br> radiusv[1] = 2; <br> radiusv[2] = sqrt(20); <br> radiusv[3] = sqrt(2); <br> radiusv[4] = sqrt(5); <br> radiusv[5] = sqrt(20); <br> thetav[0] = 0; <br> thetav[1] = PI; <br> thetav[2] = atan(2); <br> thetav[3] = QUARTER_PI; <br> thetav[4] = atan(.5); <br> thetav[5] = PI + atan(2); <br> omega = 0; <br> sizev = sizecoefficient; <br> colorv = sparkcolor; <br> birth = millis()/1000; <br> lifetime = 10; <br> } <br> <br> void update() { <br> physics(); <br> } <br> <br> void physics() { <br> location.add(movement); <br> movement.mult(acceleration); <br> omega = constrain(tan((movement.y)*(movement.x)*(acceleration.y)*(acceleration.x)), -.1, .1); <br> thetao = thetao + omega; <br> } <br> <br> void render() { <br> stroke(0); <br> fill(colorv); <br> beginShape(); <br> for (int i = 0; i &lt; 6; i++) { <br> vertex(location.x + (sizev * (cos(thetav[i] + thetao) * radiusv[i])), location.y + (sizev * (sin(thetav[i] + thetao) * radiusv[i]))); <br> } <br> endShape(CLOSE); <br> //ellipse(location.x, location.y, 12, 12); <br> } <br> <br> boolean isFinished() { <br> if (lifetime &lt; ((millis()/1000) - birth)) { <br> return true; <br> } <br> else return false; <br> } <br>} <br> <br> <br>void displayAll() { <br> //capacitor1.display(); <br> // capacitor2.display(); <br> //inductor1.display(); <br> //ac1.display(); <br> //resistor1.display(); <br> renderCapacitors(); <br> renderInductors(); <br> renderResistors(); <br> renderACSources(); <br> renderParticles(); <br> displayTrashCan(); <br>} <br> <br>void updateAll() { <br> // updateSchematic(); <br> updateCapacitors(); <br> updateInductors(); <br> updateResistors(); <br> updateACSources(); <br> updateParticles(); <br> updateSchemCap(); <br> updateSchemInd(); <br> updateSchemRes(); <br> updateSchemACS(); <br> updateSchemWire(); <br> updateSchemOUT(); <br> //capacitor1.update(); <br> //capacitor2.update(); <br> // inductor1.update(); <br> // ac1.update(); <br> //resistor1.update(); <br>} <br>void updateCapacitors() { <br> for (int i = capacitors.size()-1; i &gt;= 0; i--) { <br> Capacitor cap = (Capacitor) capacitors.get(i); <br> if (cap.isfinished) { <br> capacitors.remove(i); <br> } <br> else { <br> cap.update(); <br> capacitors.add((Capacitor) cap); <br> capacitors.remove(i); <br> } <br> } <br>} <br>void updateInductors() { <br> for (int i = inductors.size()-1; i &gt;= 0; i--) { <br> Inductor ind = (Inductor) inductors.get(i); <br> if (ind.isfinished) { <br> inductors.remove(i); <br> } <br> else { <br> ind.update(); <br> inductors.add((Inductor) ind); <br> inductors.remove(i); <br> } <br> } <br>} <br>void updateResistors() { <br> for (int i = resistors.size()-1; i &gt;= 0; i--) { <br> Resistor res = (Resistor) resistors.get(i); <br> if (res.isfinished) { <br> resistors.remove(i); <br> } <br> else { <br> res.update(); <br> resistors.add((Resistor) res); <br> resistors.remove(i); <br> } <br> } <br>} <br>void updateACSources() { <br> for (int i = acsources.size()-1; i &gt;= 0; i--) { <br> ACSource acs = (ACSource) acsources.get(i); <br> if (acs.isfinished) { <br> acsources.remove(i); <br> } <br> else { <br> acs.update(); <br> acsources.add((ACSource) acs); <br> acsources.remove(i); <br> } <br> } <br>} <br>void updateParticles() { <br> if (particleslastupdate &lt; (millis()/10) - 1) { <br> for (int i = particles.size()-1; i &gt;= 0; i--) { <br> Sparks spark = (Sparks) particles.get(i); <br> if (spark.isFinished()) { <br> particles.remove(i); <br> } <br> else { <br> spark.update(); <br> particles.add((Sparks) spark); <br> particles.remove(i); <br> } <br> } <br> particleslastupdate = (millis()/100); <br> } <br>} <br> <br>void renderCapacitors() { <br> for (int i = capacitors.size()-1; i &gt;= 0; i--) { <br> Capacitor cap = (Capacitor) capacitors.get(i); <br> cap.display(); <br> } <br>} <br>void renderInductors() { <br> for (int i = inductors.size()-1; i &gt;= 0; i--) { <br> Inductor ind = (Inductor) inductors.get(i); <br> ind.display(); <br> } <br>} <br>void renderResistors() { <br> for (int i = resistors.size()-1; i &gt;= 0; i--) { <br> Resistor res = (Resistor) resistors.get(i); <br> res.display(); <br> } <br>} <br>void renderACSources() { <br> for (int i = acsources.size()-1; i &gt;= 0; i--) { <br> ACSource acs = (ACSource) acsources.get(i); <br> acs.display(); <br> } <br>} <br>void renderParticles() { <br> for (int i = particles.size()-1; i &gt;= 0; i--) { <br> Sparks spark = (Sparks) particles.get(i); <br> spark.render(); <br> } <br>} <br> <br> <br>void generateSparks(float dx, float dy, float ddx, float ddy, float sizecoefficient, color sparkcolor) { <br> if (particleslastgenerate &lt; (millis()/100) - .25) { <br> particles.add(new Sparks(dx, dy, ddx, ddy, sizecoefficient, sparkcolor)); <br> particleslastgenerate = (millis()/100); <br> } <br>} <br> <br>void mouseStateUpdate(boolean mousestatecurrent) <br>{ <br> mousestatelast = mousestatecurrent; <br>} <br>void description() { <br> if (!(desunits == &quot;NONE&quot;)) { <br> textFont(font); <br> noFill(); <br> rectMode(CORNER); <br> rect(100, 450, 400, 50); <br> fill(color(0, 0, 0)); <br> text(str(desval)+ ' ' + desunits, 100, 475); <br> } <br>} <br>void graph(String xlable, String ylable, float domainmin, float domainmax, float rangemin, float rangemax, float xpoint, float ypoint) { <br> if (graphicaldisplay.symbol == &quot;PLOT&quot;) { <br> stroke(color(0, 255, 150)); <br> fill(color(0, 0, 0)); <br> rectMode(CORNER); <br> rect(500, 100, 200, 200); <br> stroke(0, 255, 255); <br> fill(graphpointcolor); <br> ellipse(constrain((map(xpoint, domainmin, domainmax*graphdomain, 0, 200)+500), 500, 700), constrain((map(ypoint, rangemin, rangemax*graphrange, 0, -200)+300), 100, 300), 10, 10); <br> fill(color(0, 255, 150)); <br> text(str(ypoint) + &quot;V&quot;, 500, 150); <br> text(str(xpoint) + &quot;Hz&quot;, 550, 300); <br> text(xlable + &quot;(0Hz - &quot;+str(10*graphdomain)+&quot;Hz)&quot;, 550, 320); <br> text(ylable + &quot;(0V - &quot;+str(5*graphrange)+&quot;Vss)&quot;, 450, 90); <br> } <br>} <br>void vector(String xlable, String ylabel, PVector vector) { <br> if (graphicaldisplay.symbol == &quot;VECTOR&quot;) { <br> stroke(color(0, 0, 0)); <br> strokeWeight(4); <br> line(500, 200, 500, 200-map(vector.y, 0, 1000, 0, 100)); <br> line(500, 200, 500+map(vector.x, 0, 1000, 0, 100), 200); <br> strokeWeight(2); <br> line(500, 200, 500+map(vector.x, 0, 1000, 0, 100), 200-map(vector.y, 0, 1000, 0, 100)); <br> text(&quot;(X)&quot;+xlable+&quot; &quot;+str(abs(vector.x)), 525, 90); <br> text(&quot;(Y)&quot;+ylabel+&quot; &quot;+str(abs(vector.y)), 525, 100); <br> text(&quot;PhaseShift:&quot;, 525, 125); <br> if ((phaseShift(vector.x, vector.y))&gt;0) { <br> text(&quot;Voltage&quot;+&quot; &quot;+&quot;IN PHASE&quot;, 525, 135); <br> text(&quot;Current&quot;+&quot; &quot;+&quot;LAG&quot;+&quot; &quot;+str(degrees(phaseShift(vector.x, vector.y))*-1)+&quot;degrees&quot;, 525, 145); <br> } <br> else if ((phaseShift(vector.x, vector.y))&lt;0) { <br> text(&quot;Voltage&quot;+&quot; &quot;+&quot;LAG&quot;+&quot; &quot;+str(degrees(phaseShift(vector.x, vector.y))*-1)+&quot;degrees&quot;, 525, 135); <br> text(&quot;Current&quot;+&quot; &quot;+&quot;IN PHASE&quot;, 525, 145); <br> } <br> else { <br> text(&quot;Voltage&quot;+&quot; &quot;+&quot;IN PHASE&quot;, 525, 135); <br> text(&quot;Current&quot;+&quot; &quot;+&quot;IN PHASE&quot;, 525, 145); <br> } <br> strokeWeight(1); <br> } <br>} <br> <br>void phasor(int nphasors, float omega, float[] thetas, float[] magnitudes, color[] colors, String[] labels) { <br> strokeWeight(4); <br> for (int i = 0; i stroke(colors[i]); <br> fill(colors[i]); <br> line(500, 200, 500 + cos(phasortimecoefficient*phasortime*omega + thetas[i])*magnitudes[i]*20, 200 + sin(phasortimecoefficient*phasortime*omega + thetas[i])*magnitudes[i]*20); <br> text(labels[i], 500, 400+10*i); <br> text(&quot;[&quot; + (magnitudes[i]) + &quot;]&quot; + &quot;[&quot; + &quot;e^(j&quot; + (thetas[i]) + &quot;)&quot; + &quot;]&quot; + &quot;e^(j&quot; + (omega) + (phasortimecoefficient*phasortime) + &quot;)&quot; + &quot;]&quot;, 500, 300+10*i); <br> } <br>} <br> <br>void updateSchematic() { <br> updateSchemGround(); <br> updateSchemOUT(); <br> updateSchemWire(); <br> updateSchemCap(); <br> updateSchemInd(); <br> updateSchemRes(); <br> updateSchemACS(); <br> if (mode != modelast) { <br> for (int i=schemwires.size()-1;i&gt;=0;i--) { <br> schemwires.remove(i); <br> } <br> for (int i=schemouts.size()-1;i&gt;=0;i--) { <br> schemouts.remove(i); <br> } <br> for (int i=schemgrounds.size()-1;i&gt;=0;i--) { <br> schemgrounds.remove(i); <br> } <br> for (int i=schemcapacitors.size()-1;i&gt;=0;i--) { <br> schemcapacitors.remove(i); <br> } <br> for (int i=scheminductors.size()-1;i&gt;=0;i--) { <br> scheminductors.remove(i); <br> } <br> for (int i=schemresistors.size()-1;i&gt;=0;i--) { <br> schemresistors.remove(i); <br> } <br> for (int i=schemacsources.size()-1;i&gt;=0;i--) { <br> schemacsources.remove(i); <br> } <br> <br> if (mode==&quot;Low-Pass Filter (RC)&quot;) { <br> graphdomain = 1; <br> graphrange = 1; <br> SchemCap c1 = new SchemCap(200, 300, 1); <br> SchemRes r1 = new SchemRes(300, c1.leadly, 1); <br> SchemACS a1 = new SchemACS(250, 200, 1); <br> schemcapacitors.add((SchemCap) c1); <br> schemresistors.add((SchemRes) r1); <br> schemacsources.add((SchemACS) a1); <br> schemwires.add(new SchemWire(c1.leadrx, c1.leadry, r1.leadlx, r1.leadly, 1)); <br> schemwires.add(new SchemWire((c1.leadlx) - 10, c1.leadly, (c1.leadlx) - 10, a1.leadly, 2)); <br> schemwires.add(new SchemWire((r1.leadrx) + 10, r1.leadry, (r1.leadrx) + 10, a1.leadry, 3)); <br> schemwires.add(new SchemWire((c1.leadlx) - 10, c1.leadly, c1.leadlx, c1.leadly, 4)); <br> schemwires.add(new SchemWire((r1.leadrx) + 10, r1.leadry, r1.leadrx, r1.leadry, 5)); <br> schemwires.add(new SchemWire((c1.leadlx) - 10, a1.leadly, a1.leadlx, a1.leadly, 6)); <br> schemwires.add(new SchemWire((r1.leadrx) + 10, a1.leadry, a1.leadrx, a1.leadry, 7)); <br> schemouts.add(new SchemOUT(((c1.leadrx + r1.leadlx)/2), c1.leadry, ((c1.leadrx+r1.leadlx)/2), c1.leadry + 50, 1)); <br> schemgrounds.add(new SchemGround((c1.leadlx) - 10, c1.leadly, (c1.leadlx) - 10, (c1.leadly) +50, 1)); <br> } <br> else if (mode==&quot;High-Pass Filter (RC)&quot;) { <br> } <br> else if (mode==&quot;Low-Pass Filter (RL)&quot;) { <br> } <br> else if (mode==&quot;High-Pass Filter (RL)&quot;) { <br> } <br> else if (mode==&quot;Band-Reject (Notch): Driven LC Series&quot;) { <br> } <br> else if (mode==&quot;Band-Pass: Driven LC Parallel&quot;) { <br> graphdomain = 1; <br> graphrange = 1; <br> SchemCap c1 = new SchemCap(200, 300, 1); <br> SchemInd i1 = new SchemInd(210, 250, 1); <br> SchemRes r1 = new SchemRes(300, c1.leadly, 1); <br> SchemACS a1 = new SchemACS(250, 200, 1); <br> schemcapacitors.add((SchemCap) c1); <br> scheminductors.add((SchemInd) i1); <br> schemresistors.add((SchemRes) r1); <br> schemacsources.add((SchemACS) a1); <br> schemwires.add(new SchemWire(c1.leadrx, c1.leadry, r1.leadlx, r1.leadly, 1)); <br> schemwires.add(new SchemWire((c1.leadlx) - 10, c1.leadly, (c1.leadlx) - 10, a1.leadly, 2)); <br> schemwires.add(new SchemWire((r1.leadrx) + 10, r1.leadry, (r1.leadrx) + 10, a1.leadry, 3)); <br> schemwires.add(new SchemWire((c1.leadlx) - 10, c1.leadly, c1.leadlx, c1.leadly, 4)); <br> schemwires.add(new SchemWire((r1.leadrx) + 10, r1.leadry, r1.leadrx, r1.leadry, 5)); <br> schemwires.add(new SchemWire((c1.leadlx) - 10, a1.leadly, a1.leadlx, a1.leadly, 6)); <br> schemwires.add(new SchemWire((r1.leadrx) + 10, a1.leadry, a1.leadrx, a1.leadry, 7)); <br> schemwires.add(new SchemWire((i1.leadlx) - 15, i1.leadly, i1.leadlx, i1.leadly, 8)); <br> schemwires.add(new SchemWire(((c1.leadrx + r1.leadlx)/2), c1.leadry, ((c1.leadrx+r1.leadlx)/2), i1.leadry, 9)); <br> schemwires.add(new SchemWire(i1.leadrx, i1.leadry, ((c1.leadrx+r1.leadlx)/2), i1.leadry, 10)); <br> schemouts.add(new SchemOUT(((c1.leadrx + r1.leadlx)/2), c1.leadry, ((c1.leadrx+r1.leadlx)/2), c1.leadry + 50, 1)); <br> schemgrounds.add(new SchemGround((c1.leadlx) - 10, c1.leadly, (c1.leadlx) - 10, (c1.leadly) +50, 1)); <br> } <br> else if (mode==&quot;Resonance (LC Tank)&quot;) { <br> } <br> else if (mode==&quot;Dual Resonant Air-Core Step-Up Transformer (Tesla Coil)&quot;) { <br> } <br> modelast = mode; <br> } <br> <br> <br> if (mode==&quot;Low-Pass Filter (RC)&quot;) { <br> <br> for (int i = schemcapacitors.size()-1; i &gt;= 0; i--) { <br> SchemCap capval = (SchemCap) schemcapacitors.get(i); <br> if (capval.id == 1) { <br> for (int ii = schemresistors.size()-1; ii &gt;= 0; ii--) { <br> SchemRes resval = (SchemRes) schemresistors.get(i); <br> if (resval.id == 1) { <br> for (int iii = schemacsources.size()-1; iii &gt;= 0; iii--) { <br> SchemACS acsval = (SchemACS) schemacsources.get(i); <br> if (acsval.id == 1) { <br> if (graphicaldisplay.symbol == &quot;PLOT&quot;) { <br> if (!bandWidth(5,voltagePoint(5, impedance(resval.value, 0, capacitiveReactance(capval.value, acsval.value)), capacitiveReactance(capval.value, acsval.value)))) { <br> graphpointcolor = color(255, 0, 0); <br> } <br> else { <br> graphpointcolor = color(0, 255, 150); <br> } <br> graph(&quot;Frequency&quot;, &quot;OUT1 Amplitude&quot;, 0, 10, 0, 5, acsval.value, voltagePoint(5, impedance(resval.value, 0, capacitiveReactance(capval.value, acsval.value)), capacitiveReactance(capval.value, acsval.value))); <br> } <br> //vector(new PVector(map(resval.value,0,1000,0,100),map(capacitiveReactance(capval.value, acsval.value),0,1000,0,-100))); <br> else if (graphicaldisplay.symbol == &quot;VECTOR&quot;) vector(&quot;Resistance&quot;, &quot;CapacitiveReactance&quot;, new PVector(resval.value, capacitiveReactance(capval.value, acsval.value)*-1)); <br> else if (graphicaldisplay.symbol == &quot;PHASOR&quot;) { <br> phasorthetas[0] = 0; <br> phasorthetas[1] = phaseShift(resval.value, capacitiveReactance(capval.value, acsval.value)); <br> phasormagnitudes[0] = 5; <br> phasormagnitudes[1] = voltagePoint(5, impedance(resval.value, 0, capacitiveReactance(capval.value, acsval.value)), capacitiveReactance(capval.value, acsval.value)); <br> phasorcolors[0] = color(0,255,100); <br> phasorcolors[1] = color(255,0,255); <br> phasorlabels[0] = &quot;SignalVoltage&quot;; <br> phasorlabels[1] = &quot;OUT1Voltage&quot;; <br> phasor(2, acsval.value*TWO_PI, phasorthetas, phasormagnitudes, phasorcolors, phasorlabels); <br> } <br> } <br> } <br> } <br> } <br> } <br> } <br> } <br> else if (mode==&quot;High-Pass Filter (RC)&quot;) { <br> } <br> else if (mode==&quot;Low-Pass Filter (RL)&quot;) { <br> } <br> else if (mode==&quot;High-Pass Filter (RL)&quot;) { <br> } <br> else if (mode==&quot;Band-Reject (Notch): Driven LC Series&quot;) { <br> } <br> else if (mode==&quot;Band-Pass: Driven LC Parallel&quot;) { <br> for (int i = schemcapacitors.size()-1; i &gt;= 0; i--) { <br> SchemCap capval = (SchemCap) schemcapacitors.get(i); <br> if (capval.id == 1) { <br> for (int ii = scheminductors.size()-1; ii &gt;= 0; ii--) { <br> SchemInd indval = (SchemInd) scheminductors.get(ii); <br> if (indval.id == 1) { <br> for (int iii = schemresistors.size()-1; iii &gt;= 0; iii--) { <br> SchemRes resval = (SchemRes) schemresistors.get(iii); <br> if (resval.id == 1) { <br> for (int iiii = schemacsources.size()-1; iiii &gt;= 0; iiii--) { <br> SchemACS acsval = (SchemACS) schemacsources.get(iiii); <br> if (acsval.id == 1) { <br> if (graphicaldisplay.symbol == &quot;PLOT&quot;) { <br> if (!bandWidth(5,voltagePoint(5, impedance(resval.value, 1/ ((1/inductiveReactance(indval.value, acsval.value))-(1/capacitiveReactance(capval.value, acsval.value))), 0), abs(1/ ((1/inductiveReactance(indval.value, acsval.value))-(1/capacitiveReactance(capval.value, acsval.value))))))) { <br> graphpointcolor = color(255, 0, 0); <br> } <br> else { <br> graphpointcolor = color(0, 255, 150); <br> } <br> if (acsval.value &gt; resonantFrequency(capval.value, indval.value)-.001 &amp;&amp; acsval.value &lt; resonantFrequency(capval.value, indval.value)+.001) graphpointcolor = color(255, 255, 255); <br> graph(&quot;Frequency&quot;, &quot;OUT1 Amplitude&quot;, 0, 10, 0, 5, acsval.value, voltagePoint(5, impedance(resval.value, 1/ ((1/inductiveReactance(indval.value, acsval.value))-(1/capacitiveReactance(capval.value, acsval.value))), 0), abs(1/ ((1/inductiveReactance(indval.value, acsval.value))-(1/capacitiveReactance(capval.value, acsval.value)))))); <br> } <br> //vector(new PVector(map(resval.value,0,1000,0,100),map(capacitiveReactance(capval.value, acsval.value),0,1000,0,-100))); <br> else if (graphicaldisplay.symbol == &quot;VECTOR&quot;) vector(&quot;Resistance&quot;, &quot;Reactance&quot;, new PVector(resval.value, ((1/inductiveReactance(indval.value, acsval.value))-(1/capacitiveReactance(capval.value, acsval.value))))); <br> else if (graphicaldisplay.symbol == &quot;PHASOR&quot;) { <br> phasorthetas[0] = 0; <br> phasorthetas[1] = phaseShift(resval.value, 1/inductiveReactance(indval.value, acsval.value) - 1/capacitiveReactance(capval.value, acsval.value)); <br> phasormagnitudes[0] = 5; <br> phasormagnitudes[1] = voltagePoint(5, impedance(resval.value, 1/ ((1/inductiveReactance(indval.value, acsval.value))-(1/capacitiveReactance(capval.value, acsval.value))), 0), abs(1/ ((1/inductiveReactance(indval.value, acsval.value))-(1/capacitiveReactance(capval.value, acsval.value))))); <br> phasorcolors[0] = color(0,255,100); <br> phasorcolors[1] = color(255,0,255); <br> phasorlabels[0] = &quot;SignalVoltage&quot;; <br> phasorlabels[1] = &quot;OUT1Voltage&quot;; <br> phasor(2, acsval.value*TWO_PI, phasorthetas, phasormagnitudes, phasorcolors, phasorlabels); <br> } <br> } <br> } <br> } <br> } <br> } <br> } <br> } <br> } <br> } <br> else if (mode==&quot;Resonance (LC Tank)&quot;) { <br> } <br> else if (mode==&quot;Dual Resonant Air-Core Step-Up Transformer (Tesla Coil)&quot;) { <br> } <br>} <br> <br>void displayTrashCan() { <br> stroke(0); <br> fill(color(100, 100, 100)); <br> rectMode(CORNER); <br> rect(50, 450, 20, 30); <br> rect(48, 445, 24, 5); <br> line(55, 450, 55, 480); <br> line(60, 450, 60, 480); <br> line(65, 450, 65, 480); <br>} <br> <br>class SchemWire { <br> float x1; <br> float y1; <br> float x2; <br> float y2; <br> int id; <br> boolean available; <br> <br> SchemWire(float tx1, float ty1, float tx2, float ty2, int tid) { <br> x1 = tx1; <br> x2 = tx2; <br> y1 = ty1; <br> y2 = ty2; <br> id = tid; <br> available = true; <br> } <br> <br> void display() { <br> fill(color(0, 0, 0)); <br> stroke(color(0, 0, 0)); <br> line(x1, y1, x2, y2); <br> ellipse(x1, y1, 4, 4); <br> ellipse(x2, y2, 4, 4); <br> } <br>} <br>class SchemOUT { <br> float x1; <br> float y1; <br> float x2; <br> float y2; <br> int id; <br> boolean available; <br> <br> SchemOUT(float tx1, float ty1, float tx2, float ty2, int tid) { <br> x1 = tx1; <br> x2 = tx2; <br> y1 = ty1; <br> y2 = ty2; <br> id = tid; <br> available = true; <br> } <br> <br> void display() { <br> fill(color(0, 0, 0)); <br> stroke(color(0, 0, 0)); <br> line(x1, y1, x2, y2); <br> ellipse(x1, y1, 4, 4); <br> textFont(font2); <br> text(&quot;OUT&quot;+str(id), x2, y2); <br> } <br>} <br> <br>class SchemGround { <br> float x1; <br> float y1; <br> float x2; <br> float y2; <br> int id; <br> boolean available; <br> <br> SchemGround(float tx1, float ty1, float tx2, float ty2, int tid) { <br> x1 = tx1; <br> x2 = tx2; <br> y1 = ty1; <br> y2 = ty2; <br> id = tid; <br> available = true; <br> } <br> <br> void display() { <br> fill(color(0, 0, 0)); <br> stroke(color(0, 0, 0)); <br> line(x1, y1, x2, y2); <br> ellipse(x1, y1, 4, 4); <br> line(x2 - 10, y2, x2 + 10, y2); <br> line(x2 - 7, y2 + 5, x2 + 7, y2 + 5); <br> line(x2 - 3, y2 + 10, x2 + 3, y2 + 10); <br> } <br>} <br> <br>class SchemCap { <br> float xpos; <br> float ypos; <br> float cxpos; <br> float cypos; <br> float leadlx; <br> float leadly; <br> float leadrx; <br> float leadry; <br> float value; <br> int id; <br> boolean available; <br> int check; <br> <br> SchemCap(float txpos, float typos, int tid) { <br> xpos = txpos; <br> ypos = typos; <br> cxpos = xpos; <br> cypos = ypos + 15; <br> leadlx = xpos - 5; <br> leadly = ypos + 15; <br> leadrx = xpos + 10; <br> leadry = ypos + 15; <br> id = tid; <br> available = true; <br> } <br> <br> void update() { <br> //value = ((Capacitor) capacitors.get(check)).value; <br> if (available) value = 0; <br> <br> //available = true; <br> //value = 0; <br> for (int i = capacitors.size()-1; i &gt;= 0; i--) { <br> Capacitor testcap = (Capacitor) capacitors.get(i); <br> if (testcap.applied) { <br> if (testcap.held) { <br> available = true; <br> value = 0; <br> testcap.applied = false; <br> } <br> else { <br> value = testcap.value; <br> } <br> } <br> if ((testcap.centerx &gt; cxpos - 15)&amp;&amp;(testcap.centerx &lt; cxpos + 15) <br> &amp;&amp;(testcap.centery &gt; cypos - 15)&amp;&amp;(testcap.centery &lt; cypos + 15) <br> &amp;&amp;(!testcap.held)&amp;&amp;(available)) { <br> testcap.centerx = cxpos; <br> testcap.centery = cypos; <br> value = testcap.value; <br> check = i; <br> available = false; <br> testcap.applied = true; <br> } <br> capacitors.add((Capacitor) testcap); <br> capacitors.remove(i); <br> } <br> display(); <br> <br> /*desunits = &quot;test&quot;; <br> desval = value; <br> description(); <br> */ <br> /* //TEST: <br> if(available) desunits = &quot;true&quot;; <br> else desunits = &quot;false&quot;; <br> description(); */ <br> } <br> <br> void display() { <br> stroke(0, 0, 0); <br> line(xpos - 5, ypos, xpos - 5, ypos + 30); <br> line(xpos + 10, ypos, xpos + 10, ypos + 30); <br> } <br>} <br> <br>class SchemInd { <br> float xpos; <br> float ypos; <br> float leadlx; <br> float leadly; <br> float leadrx; <br> float leadry; <br> float value; <br> int id; <br> boolean available; <br> int check; <br> <br> SchemInd(float txpos, float typos, int tid) { <br> xpos = txpos; <br> ypos = typos; <br> leadlx = xpos - 10; <br> leadly = ypos; <br> leadrx = xpos + 10; <br> leadry = ypos; <br> id = tid; <br> available = true; <br> } <br> <br> void update() { <br> //value = ((Inductor) inductors.get(check)).value; <br> if (available) value = 0; <br> //available = true; <br> //value = 0; <br> <br> for (int i = inductors.size()-1; i &gt;= 0; i--) { <br> Inductor testind = (Inductor) inductors.get(i); <br> if (testind.applied) { <br> if (testind.held) { <br> available = true; <br> value = 0; <br> testind.applied = false; <br> } <br> else { <br> value = testind.value; <br> } <br> } <br> if ((testind.centerx &gt; xpos - 10)&amp;&amp;(testind.centerx &lt; xpos + 10) <br> &amp;&amp;(testind.centery &gt; ypos - 10)&amp;&amp;(testind.centery &lt; ypos + 10) <br> &amp;&amp;(!testind.held)&amp;&amp;(available)) { <br> testind.centerx = xpos; <br> testind.centery = ypos; <br> value = testind.value; <br> check = i; <br> available = false; <br> testind.applied = true; <br> } <br> inductors.add((Inductor) testind); <br> inductors.remove(i); <br> } <br> display(); <br> } <br> <br> void display() { <br> noFill(); <br> stroke(color(0, 0, 0)); <br> for (int i = 0; i &lt; 3; i++) { <br> arc(xpos + (-10 + (10 * i)), ypos, 10, 30, PI, TWO_PI); <br> } <br> } <br>} <br> <br>class SchemRes { <br> float xpos; <br> float ypos; <br> float cxpos; <br> float cypos; <br> float leadlx; <br> float leadly; <br> float leadrx; <br> float leadry; <br> float value; <br> int id; <br> boolean available; <br> int check; <br> <br> SchemRes(float txpos, float typos, int tid) { <br> xpos = txpos; <br> ypos = typos; <br> cxpos = xpos + 15; <br> cypos = ypos; <br> leadlx = xpos; <br> leadly = ypos; <br> leadrx = xpos + 30; <br> leadry = ypos; <br> id = tid; <br> available = true; <br> } <br> <br> void update() { <br> //value = ((Resistor) resistors.get(check)).value; <br> if (available) value = 0; <br> //available = true; <br> //value = 0; <br> <br> for (int i = resistors.size()-1; i &gt;= 0; i--) { <br> Resistor testres = (Resistor) resistors.get(i); <br> if (testres.applied) { <br> if (testres.held) { <br> available = true; <br> value = 0; <br> testres.applied = false; <br> } <br> else { <br> value = testres.value; <br> } <br> } <br> if ((testres.centerx &gt; cxpos - 10)&amp;&amp;(testres.centerx &lt; cxpos + 10) <br> &amp;&amp;(testres.centery &gt; cypos - 10)&amp;&amp;(testres.centery &lt; cxpos + 10) <br> &amp;&amp;(!testres.held)&amp;&amp;(available)) { <br> testres.centerx = cxpos; <br> testres.centery = cypos; <br> value = testres.value; <br> check = i; <br> available = false; <br> testres.applied = true; <br> } <br> resistors.add((Resistor) testres); <br> resistors.remove(i); <br> } <br> display(); <br> } <br> <br> void display() { <br> stroke(color(0, 0, 0)); <br> line(xpos, ypos, xpos+5, ypos-10); <br> line(xpos+5, ypos-10, xpos+10, ypos); <br> line(xpos+10, ypos, xpos+15, ypos-10); <br> line(xpos+15, ypos-10, xpos+20, ypos); <br> line(xpos+20, ypos, xpos+25, ypos-10); <br> line(xpos+25, ypos-10, xpos+30, ypos); <br> } <br>} <br> <br>class SchemACS { <br> float xpos; <br> float ypos; <br> float leadlx; <br> float leadly; <br> float leadrx; <br> float leadry; <br> float value; <br> int id; <br> boolean available; <br> int check; <br> <br> SchemACS(float txpos, float typos, int tid) { <br> xpos = txpos; <br> ypos = typos; <br> leadlx = xpos - 15; <br> leadly = ypos; <br> leadrx = xpos + 15; <br> leadry = ypos; <br> id = tid; <br> available = true; <br> } <br> <br> void update() { <br> //value = ((ACSource) acsources.get(check)).value; <br> if (available) value = 0; <br> //available = true; <br> //value = 0; <br> for (int i = acsources.size()-1; i &gt;= 0; i--) { <br> ACSource testacs = (ACSource) acsources.get(i); <br> if (testacs.applied) { <br> if (testacs.held) { <br> testacs.applied = false; <br> available = true; <br> value = 0; <br> } <br> else { <br> value = testacs.value; <br> } <br> } <br> if ((testacs.centerx &gt; xpos - 10)&amp;&amp;(testacs.centerx &lt; xpos + 10) <br> &amp;&amp;(testacs.centery &gt; ypos - 10)&amp;&amp;(testacs.centery &lt; xpos + 10) <br> &amp;&amp;(!testacs.held)&amp;&amp;(available)) { <br> testacs.centerx = xpos; <br> testacs.centery = ypos; <br> value = testacs.value; <br> check = i; <br> available = false; <br> testacs.applied = true; <br> } <br> acsources.add((ACSource) testacs); <br> acsources.remove(i); <br> } <br> <br> display(); <br> } <br> <br> void display() { <br> noFill(); <br> stroke(color(0, 0, 0)); <br> ellipse(xpos, ypos, 30, 30); <br> for (int i=0;i&lt;20;i++) { <br> set(int(xpos)-10+i, int(ypos)+int((-10*sin((TWO_PI*i)/20))), color(0, 0, 0)); <br> } <br> } <br>} <br> <br>void updateSchemCap() { <br> for (int i = schemcapacitors.size()-1; i &gt;= 0; i--) { <br> SchemCap update = (SchemCap) schemcapacitors.get(i); <br> update.update(); <br> schemcapacitors.add((SchemCap) update); <br> schemcapacitors.remove(i); <br> } <br>} <br> <br>void updateSchemInd() { <br> for (int i = scheminductors.size()-1; i &gt;= 0; i--) { <br> SchemInd update = (SchemInd) scheminductors.get(i); <br> update.update(); <br> scheminductors.add((SchemInd) update); <br> scheminductors.remove(i); <br> } <br>} <br> <br>void updateSchemRes() { <br> for (int i = schemresistors.size()-1; i &gt;= 0; i--) { <br> SchemRes update = (SchemRes) schemresistors.get(i); <br> update.update(); <br> schemresistors.add((SchemRes) update); <br> schemresistors.remove(i); <br> } <br>} <br> <br>void updateSchemACS() { <br> for (int i = schemacsources.size()-1; i &gt;= 0; i--) { <br> SchemACS update = (SchemACS) schemacsources.get(i); <br> update.update(); <br> schemacsources.add((SchemACS) update); <br> schemacsources.remove(i); <br> } <br>} <br>void updateSchemWire() { <br> for (int i = schemwires.size()-1; i &gt;= 0; i--) { <br> SchemWire update = (SchemWire) schemwires.get(i); <br> update.display(); <br> } <br>} <br>void updateSchemOUT() { <br> for (int i = schemouts.size()-1; i &gt;= 0; i--) { <br> SchemOUT update = (SchemOUT) schemouts.get(i); <br> update.display(); <br> } <br>} <br>void updateSchemGround() { <br> for (int i = schemgrounds.size()-1; i &gt;= 0; i--) { <br> SchemGround update = (SchemGround) schemgrounds.get(i); <br> update.display(); <br> } <br>} <br> <br> <br> <br>/***************************************************************************************************/ <br>////////// ///////// // // //////// //////// ////// ////////// /// // ///////// <br>/// // // // // // // // // // // // // // /// <br>////////// // // // // //////// // // // // // // // ///////// <br>/// // ////// // // // // // // // // // // // /// <br>////////// ///////// ///////// // // // ////// ////////// // //// ///////// <br>/***************************************************************************************************/ <br> <br>float impedance(float R, float Xl, float Xc) { <br> return(sqrt(sq(R)+sq(Xl-Xc))); <br>} <br> <br>float inductiveReactance(float L, float f) { <br> return(TWO_PI*f*L); <br>} <br> <br>float capacitiveReactance(float C, float f) { <br> return(1 / (TWO_PI*f*C)); <br>} <br> <br>float resonantFrequency(float L, float C) { <br> return(1 / (TWO_PI*sqrt(L*C))); <br>} <br> <br>float phaseShift(float R, float X) { <br> return atan(X/R); <br>} <br> <br>float voltagePoint(float Vt, float Rt, float R) { <br> return(Vt*(R / Rt)); <br>} <br> <br>boolean bandWidth(float amplitudein, float amplitudeout) { <br> if (amplitudeout &lt; (amplitudein/2)) { <br> return false; <br> } <br> else return true; <br>} <br>
Is there anyway that I could embed the app on the i'ble page?

About This Instructable