Applets:Periodendauer periodischer Signale: Difference between revisions

From LNTwww
No edit summary
No edit summary
Line 1: Line 1:
<!DOCTYPE html>
 
<html lang="de">
<html>
<head>
<head>
  <title>CSS Grid</title>
      <meta charset="utf-8" />
  <style>
      <script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/jsxgraph/0.99.6/jsxgraphcore.js"></script>
    .wrapper{
<style>
      display:grid;
        .wrapper1{
 
          display:grid;
      grid-auto-rows:minmax(100px, auto);
          grid-row-gap:1em;
      grid-gap:1em;
       justify-items:stretch;
       justify-items:stretch;
       align-items:stretch;
       align-items:stretch;
      grid-template-columns: 70% 30%;
        }


    }
        .wrapper1 >div{
          padding:0em;
          border: 1px solid black;
        }
        .wrapper1 >div:nth-child(odd){
        }
        .wrapper2{
          display:grid;
          grid-row-gap:1em;
                grid-template-columns:70% 30%;
                justify-items:stretch;
                align-items:stretch;


    .wrapper > div{
        }
      padding:1em;
    }
    .wrapper > div:nth-child(odd){


    }
        .wrapper2 >div{
 
          padding:0em;
    .box1{
          border: 1px solid black;
      /*align-self:start;*/
     grid-template-columns:repeat(2);
      grid-column:1/3;
              grid-row-gap:1em;
      grid-row:/4;
        }
      border: 1px solid black;
        .wrapper2 >div:nth-child(odd){
     }
        }
 
    .box2{
      /*align-self:end;*/
      grid-column:1/3;
      grid-row:2/4;
      border: 1px solid black;
 
    }
 
    .box3{
      /*justify-self:end;*/
      grid-column:1/3;
      grid-row:3/4;
      border: 1px solid black;
    }


     .box4{
     .box4{
Line 55: Line 47:
     }
     }


        .button {
    .button {
            background-color: black;
        background-color: black;
            border: none;
        border: none;
            color: white;
        color: white;
            font-family: arial;
        font-family: arial;
            padding: 8px 20px;
        padding: 8px 20px;
            text-align: center;
        text-align: center;
            text-decoration: none;
        text-decoration: none;
            display: inline-block;
        display: inline-block;
            font-size: 16px;
        font-size: 16px;
            border-radius: 15px;
        border-radius: 15px;
        }
    }
        .button:active {
    .button:active {
            background-color: #939393;
        background-color: #939393;
        }
    }
        table {
</style>
            border-collapse: separate;
</head>
            border-spacing: 20px 0;
<body onload="drawNow()">
        }
 
 
 
 
<div class="wrapper1">
 
  <div id="container1">
 
formel
 
</div>
 
  <div id="container2">
 
<div id="cnfBoxHtml" class="jxgbox" style="width:600px; height:100px;border:1px solid black;"></div>
 
  </div>
 
  <div id="container3">
 
<div id="pltBoxHtml" class="jxgbox" style="width:600px; height:600px; border:1px solid black;"></div>
 
  </div>
 
  <div id="leerraum">
  </div>
</div>


  </style>
</head>


<body onload="drawNow()">


<script type="text/javascript">
<div class="wrapper2">
function drawNow() {
        // Grundeinstellungen der beiden Applets
        JXG.Options.text.useMathJax = true;
        cnfBox = JXG.JSXGraph.initBoard('cnfBoxHtml', {
            showCopyright: false, showNavigation: false, axis: false,
            grid: false, zoom: { enabled: false }, pan: { enabled: false },
            boundingbox: [-1, 2.2, 12.4, -2.2]
        });
        pltBox = JXG.JSXGraph.initBoard('pltBoxHtml', {
            showCopyright: false, axis: false,
            zoom: { factorX: 1.1, factorY: 1.1, wheel: true, needshift: true, eps: 0.1 },
            grid: false, boundingbox: [-0.5, 2.2, 12.4, -2.2]
        });
        cnfBox.addChild(pltBox);
        // Einstellungen der Achsen
        xaxis = pltBox.create('axis', [[0, 0], [1, 0]], {
            name: '$\\dfrac{t}{T}$',
            withLabel: true, label: { position: 'rt', offset: [-25, -10] }
        });
        yaxis = pltBox.create('axis', [[0, 0], [0, 1]], {
            name: '$x(t)$',
            withLabel: true, label: { position: 'rt', offset: [10, -5] }
        });
        // Erstellen der Schieberegler
        sldA1 = cnfBox.create('slider', [ [-0.7, 1.5], [3, 1.5], [0, 0.5, 1] ], {
            suffixlabel: '$A_1=$',
            unitLabel: 'V', snapWidth: 0.01
            }),
        sldF1 = cnfBox.create('slider', [ [-0.7, 0.5], [3, 0.5], [0, 1, 10] ], {
            suffixlabel: '$f_1=$',
            unitLabel: 'kHz', snapWidth: 0.1
        }),
        sldPHI1 = cnfBox.create('slider', [ [-0.7, -0.5], [3, -0.5], [-180, 0, 180] ], {
            suffixlabel: '$\\phi_1=$',
            unitLabel: 'Grad', snapWidth: 5
        }),
        sldA2 = cnfBox.create('slider', [ [6, 1.5], [9.7, 1.5], [0, 0.5, 1] ], {
            suffixlabel: '$A_2=$',
            unitLabel: 'V', snapWidth: 0.01
        }),
        sldF2 = cnfBox.create('slider', [ [6, 0.5], [9.7, 0.5], [0, 2, 10] ], {
            suffixlabel: '$f_2=$',
            unitLabel: 'kHz', snapWidth: 0.1
        }),
        sldPHI2 = cnfBox.create('slider', [ [6, -0.5], [9.7, -0.5], [-180, 90, 180] ], {
            suffixlabel: '$\\phi_2=$',
            unitLabel: 'Grad', snapWidth: 5
        }),
        sldT = cnfBox.create('slider', [ [-0.7, -1.5], [3, -1.5], [0, 0, 10] ], {
            suffixlabel: '$t=$',
            unitLabel: 's', snapWidth: 0.2
        }),
        // Definition der Funktion
        signaldarstellung = pltBox.create('functiongraph', [function(x) {
            return (sldA1.Value() * Math.cos(2 * Math.PI * sldF1.Value() * x - 2 * Math.PI * sldPHI1.Value() / 360) + sldA2.Value() * Math.cos(2 * Math.PI * sldF2.Value() * x - 2 * Math.PI * sldPHI2.Value() / 360))
        }], {
            strokeColor: "red"
        });
        // Definition des Punktes p_T0, des Hilfspunktes p_T0h und der Geraden l_T0 für Periodendauer T_0
        p_T0 = pltBox.create('point', [
            function() {
                return (Math.round(getT0() * 100) / 100);
            },
            function() {
                return sldA1.Value() * Math.cos(2 * Math.PI * sldF1.Value() * (Math.round(getT0() * 100) / 100) - 2 * Math.PI * sldPHI1.Value() / 360) +
                    sldA2.Value() * Math.cos(2 * Math.PI * sldF2.Value() * (Math.round(getT0() * 100) / 100) - 2 * Math.PI * sldPHI2.Value() / 360);
            }],
            { color: "blue", fixed: true, label: false, size: 1, name: '' }
        );
        p_T0h = pltBox.create('point',
            [function() { return (Math.round(getT0() * 100) / 100); }, 2],
            { visible: false, color: "blue", fixed: true, label: false, size: 1, name: '' }
        );
        l_T0 = pltBox.create('line', [p_T0, p_T0h])
        // Bestimmung des Wertes T_0 mit der Funktion von Siebenwirth
        setInterval(function() {
            document.getElementById("T_0").innerHTML = Math.round(getT0() * 100) / 100;
          }, 50);
        function isInt(n) {
            return n % 1 === 0;
        }
        function getT0() {
            var A, B, C, Q;
            if (sldF1.Value() < sldF2.Value()) {
                A = sldF1.Value();
                B = sldF2.Value();
            } else {
                B = sldF1.Value();
                A = sldF2.Value();
            }
            // console.log('Berechne T0 mit A=' + A, 'B=' + B);
            for (var x = 1; x <= 100; x++) {
                C = A / x;
                Q = B / C;
                // console.log(x + '. Durchgang: C = ' + C, 'Q = ' + Q);
                if (isInt(Q)) {
                    // console.log('Q ist eine Ganzzahl!!! T0 ist damit ', 1 / C);
                    return 1 / C;
                }
                if (x === 10) {
                    return 10;
                }
                if ((1 / C) > 10)
                    return 10
            }
        }
        // Ausgabe des Wertes x(t)
        setInterval(function() {
            document.getElementById("x(t)").innerHTML = Math.round((sldA1.Value() * Math.cos(2 * Math.PI * sldF1.Value() * sldT.Value() - 2 * Math.PI * sldPHI1.Value() / 360) + sldA2.Value() * Math.cos(2 * Math.PI * sldF2.Value() * sldT.Value() - 2 * Math.PI * sldPHI2.Value() /
                360)) * 1000) / 1000;
        }, 50);
        // Ausgabe des Wertes x(t+T_0)
        setInterval(function() {
            document.getElementById("x(t+T_0)").innerHTML = Math.round((sldA1.Value() * Math.cos(2 * Math.PI * sldF1.Value() * (sldT.Value() + Math.round(getT0() * 1000) / 1000) - sldPHI1.Value()) + sldA2.Value() * Math.cos(2 * Math.PI * sldF2.Value() * (sldT.Value() +
                Math.round(getT0() * 1000) / 1000) - sldPHI2.Value())) * 1000) / 1000;
        }, 50);
        // Ausgabe des Wertes x(t+2T_0)
        setInterval(function() {
            document.getElementById("x(t+2T_0)").innerHTML = Math.round((sldA1.Value() * Math.cos(2 * Math.PI * sldF1.Value() * (sldT.Value() + 2 * Math.round(getT0() * 1000) / 1000) - sldPHI1.Value()) + sldA2.Value() * Math.cos(2 * Math.PI * sldF2.Value() * (sldT.Value() +
                2 * Math.round(getT0() * 1000) / 1000) - sldPHI2.Value())) * 1000) / 1000;
        }, 50);
        // Ausgabe des Wertes x_max
        setInterval(function() {
            var x = new Array(50000);
            for (var i = 0; i < 50001; i++) {
                x[i] = Math.round((sldA1.Value() * Math.cos(2 * Math.PI * sldF1.Value() * (i / 1000) - 2 * Math.PI * sldPHI1.Value() / 360) + sldA2.Value() * Math.cos(2 * Math.PI * sldF2.Value() * (i / 1000) - 2 * Math.PI * sldPHI2.Value() / 360)) * 1000) / 1000;
            }
            document.getElementById("x_max").innerHTML = Math.max.apply(Math, x);
        }, 50);
    };
    // Definition der Funktion zum An- und Ausschalten des Koordinatengitters
    function showgrid() {
        if (gridbox.checked) {
            xaxis = pltBox.create('axis', [ [0, 0], [1, 0] ], {});
            yaxis = pltBox.create('axis', [ [0, 0], [0, 1] ], {});
        } else {
            xaxis.removeTicks(xaxis.defaultTicks);
            yaxis.removeTicks(yaxis.defaultTicks);
        }
        pltBox.fullUpdate();
    };
</script>


   <div class="wrapper">
   <div >
    <div class="box box1">Box 1


    </div>
    <div class="box box2">
<div id="cnfBoxHtml" class="jxgbox" style="width:600px; height:150px;  float:top; margin:-10px 20px 100px 0px;"></div>


</div>
  <div >


    </div>
    <div class="box box3">
<div id="pltBoxHtml" class="jxgbox" style="width:600px; height:600px; border:1px solid black; margin:-100px 20px 10px 0px;"></div>
    </div>
    <div class="box box4">
  <tr>
      <td>$x(t)$= <span id="x(t)"></span>  $\quad$ </td>
      <td>$x(t+ T_0)$= <span id="x(t+T_0)"></span>  $\quad$ </td>
      <td>$x(t+2T_0)$= <span id="x(t+2T_0)"></span>  $\quad$ </td>
      <td>$x_{\text{max}}$= <span id="x_max"></span>  $\quad$ </td>
      <td style="color:blue;">$T_0$= <span id="T_0"></span>  $\quad$ </td>
  </tr>
    </div>
    <div class="box box5">
<p>
<p>
     <input type="checkbox" id="gridbox" onclick="showgrid();" checked> <label for="gridbox">Gitterlinien Zeigen</label>
     <input type="checkbox" id="gridbox" onclick="showgrid();" checked> <label for="gridbox">Gitterlinien zeigen</label>
     <button class="button" onclick="drawNow();">Reset</button>
     <button class="button" onclick="drawNow();">Reset</button>
</p>
</p>
</div>
</div>




    </div>
  </div>
</body>
</body>
</html>
</html>


{{Display}}
{{Display}}

Revision as of 22:13, 18 September 2017

formel