|
6 | 6 | <title>Vector Sum Plotter</title>
|
7 | 7 | <script src="https://cdn.plot.ly/plotly-latest.min.js"></script>
|
8 | 8 | <style>
|
9 |
| - #plot { |
| 9 | + body { |
| 10 | + font-family: 'Arial', sans-serif; |
| 11 | + background-color: #f9f9f9; |
| 12 | + color: #333; |
| 13 | + margin: 0; |
| 14 | + padding: 0; |
| 15 | + display: flex; |
| 16 | + flex-direction: column; |
| 17 | + align-items: center; |
| 18 | + min-height: 100vh; |
| 19 | + } |
| 20 | + h1 { |
| 21 | + text-align: center; |
| 22 | + margin-top: 20px; |
| 23 | + color: #444; |
| 24 | + } |
| 25 | + #intro { |
| 26 | + max-width: 800px; |
| 27 | + margin: 20px auto; |
| 28 | + padding: 20px; |
| 29 | + background-color: #fff; |
| 30 | + border-radius: 10px; |
| 31 | + box-shadow: 0 4px 6px rgba(0,0,0,0.1); |
| 32 | + } |
| 33 | + #container { |
| 34 | + display: flex; |
| 35 | + flex-direction: row; |
| 36 | + align-items: flex-start; |
| 37 | + justify-content: center; |
| 38 | + max-width: 1200px; |
| 39 | + margin: 20px auto; |
| 40 | + gap: 20px; |
10 | 41 | width: 100%;
|
| 42 | + } |
| 43 | + #vector-input { |
| 44 | + display: flex; |
| 45 | + flex-direction: column; |
| 46 | + flex: 1; |
| 47 | + } |
| 48 | + textarea { |
11 | 49 | height: 600px;
|
| 50 | + padding: 10px; |
| 51 | + border-radius: 5px; |
| 52 | + border: 1px solid #ccc; |
| 53 | + font-size: 16px; |
| 54 | + resize: none; |
| 55 | + } |
| 56 | + #plot { |
| 57 | + flex: 1; |
| 58 | + height: 600px; |
| 59 | + } |
| 60 | + #instructions { |
| 61 | + max-width: 800px; |
| 62 | + margin: 20px auto; |
| 63 | + padding: 20px; |
| 64 | + background-color: #fff; |
| 65 | + border-radius: 10px; |
| 66 | + box-shadow: 0 4px 6px rgba(0,0,0,0.1); |
| 67 | + } |
| 68 | + ul { |
| 69 | + padding-left: 20px; |
| 70 | + } |
| 71 | + li { |
| 72 | + margin-bottom: 10px; |
| 73 | + } |
| 74 | + @media (max-width: 768px) { |
| 75 | + #container { |
| 76 | + flex-direction: column; |
| 77 | + align-items: center; |
| 78 | + } |
| 79 | + textarea { |
| 80 | + width: 100%; |
| 81 | + } |
12 | 82 | }
|
13 | 83 | </style>
|
14 | 84 | </head>
|
15 | 85 | <body>
|
16 |
| - <h1>Vector Plotter</h1> |
17 |
| - <p>Enter a sequence of 2D vectors in the format:</p> |
18 |
| - <p>[x1, y1]<br>[x2, y2]<br>…</p> |
19 |
| - <p>The plot will show how to find the sum of the vectors by concatenating vectors such that the tail of each vector is at the head of the previous vector. The orange, dashed vector represents the resulting sum of all entered vectors.</p> |
20 |
| - <textarea id="vector-plot" rows="10" cols="50" placeholder="Enter vectors here"></textarea> |
21 |
| - <div id="plot"></div> |
| 86 | + <h1>Vector Sum Plotter</h1> |
| 87 | + <div id="intro"> |
| 88 | + <p>Use this interactive tool to visualize how to find the sum of a sequence of vectors.</p> |
| 89 | + <p>Enter a sequence of 2D vectors in the format:</p> |
| 90 | + <p>[x1, y1]<br>[x2, y2]<br>…</p> |
| 91 | + <p>The sum can be found by concatenating vectors such that the tail of each vector is at the head of the previous vector. The sum of the vectors has its head at the head of the last of these concatenated vectors, and its tail at the origin. The sum is shown as an orange, dashed vector.</p> |
| 92 | + <p> </p> |
| 93 | + <p> See below the plot for things to try.</p> |
| 94 | + </div> |
| 95 | + <div id="container"> |
| 96 | + <div id="vector-input"> |
| 97 | + <textarea id="vector-plot" placeholder="Enter vectors here"></textarea> |
| 98 | + </div> |
| 99 | + <div id="plot"></div> |
| 100 | + </div> |
| 101 | + <div id="instructions"> |
| 102 | + <p><b>Things to try:</b></p> |
| 103 | + <ul> |
| 104 | + <li>Start with a pair of vectors like [1, 1] and [4, 1].</li> |
| 105 | + <li>Compare the sum if you enter the vectors in different orders!</li> |
| 106 | + <li>What happens if you enter vectors that are scaled versions of each other, like [1, 1] and [3, 3]?</li> |
| 107 | + <li>Try entering vectors with zero components</li> |
| 108 | + <li>Try entering vectors with negative components</li> |
| 109 | + <li>Does the sum of two long vectors always yield a long vector? What is the longest possible vector you can create from two vectors of given lengths? What is the shortest possible vector?</li> |
| 110 | + <li>Try entering more than two vectors.</li> |
| 111 | + </ul> |
| 112 | + </div> |
22 | 113 |
|
23 | 114 | <script src="vector-addition.js"></script>
|
24 | 115 | </body>
|
|
0 commit comments