{"id":90,"date":"2026-10-13T01:52:47","date_gmt":"2026-10-13T01:52:47","guid":{"rendered":"https:\/\/ledrum.is\/?page_id=90"},"modified":"2026-10-13T09:28:35","modified_gmt":"2026-10-13T09:28:35","slug":"straumthrihyrningur","status":"publish","type":"page","link":"https:\/\/ledrum.is\/?page_id=90","title":{"rendered":"Current triangle"},"content":{"rendered":"\n<p class=\"wp-block-paragraph\">H\u00e9r er einfaldur straum\u00fer\u00edhyrningsreikningur \u00far siglingafr\u00e6\u00f0i ger\u00f0ur \u00ed Python. <br>Mi\u00f0a\u00f0 er vi\u00f0 punkt sex sj\u00f3m\u00edlur fr\u00e1 landi \u00ed mi\u00f0inu &#8220;Vitarnir saman&#8221; \u00e1 Gar\u00f0skaga.Vindhra\u00f0i og stefna er s\u00f3tt til Ve\u00f0urstofu \u00cdslands, straumur og stefna s\u00f3tt til Copernicus Marine.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Teki\u00f0 skal fram a\u00f0 ekki skal sigla eftir \u00feessu, eing\u00f6ngu sett upp til gamans.<br><br>This is a simple current triangle calculation from navigation, done in Python.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">The reference point is six nautical miles offshore, on the old &#8220;Vitarnir saman&#8221; transit (the two Gar\u00f0skagi lighthouses in line) at Gar\u00f0skagi.<br>Wind speed and direction come from the Icelandic Meteorological Office, and current speed and direction from Copernicus Marine.<br>Please note that this must not be used for navigation. It was made purely for fun.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><\/p>\n\n\n\n<div id=\"straum\">\n  <p>Stefna b\u00e1tsins (\u00b0): <input id=\"st-stefna\" type=\"number\" value=\"90\" style=\"width:5em\"><\/p>\n  <p>Hra\u00f0i b\u00e1tsins \u00ed sj\u00f3 (kt): <input id=\"st-hradi\" type=\"number\" step=\"0.1\" value=\"6\" style=\"width:5em\"><\/p>\n  <pre id=\"st-gogn\">S\u00e6ki g\u00f6gn\u2026<\/pre>\n  <pre id=\"st-nidurstada\"><\/pre>\n<\/div>\n<script>\n(function () {\n  const SLOD = \"\/wp-content\/straumur\/data.json\";\n  const K = 0.03; \/\/ drift-stu\u00f0ull (hluti af hli\u00f0arvindi)\n  const vek = (h, s) => { const a = s * Math.PI \/ 180; return [h * Math.sin(a), h * Math.cos(a)]; };\n  const stefnaV = (x, y) => ((Math.atan2(x, y) * 180 \/ Math.PI) % 360 + 360) % 360;\n  const $ = id => document.getElementById(id);\n  let d = null;\n\n  function reikna() {\n    if (!d) return;\n    const s = parseFloat($(\"st-stefna\").value), b = parseFloat($(\"st-hradi\").value);\n    if (isNaN(s) || isNaN(b)) { $(\"st-nidurstada\").textContent = \"\"; return; }\n    const [hx, hy] = vek(b, s);\n    const [vx, vy] = vek(d.vindur.hradi_kt, d.vindur.att + 180);\n    const [ex, ey] = vek(1, s);\n    const langs = vx * ex + vy * ey;\n    const cx = hx + K * (vx - langs * ex), cy = hy + K * (vy - langs * ey);\n    const sjo = stefnaV(cx, cy);\n    const drift = ((sjo - s + 180) % 360 + 360) % 360 - 180;\n    const [sx, sy] = vek(d.straumur.hradi_kt, d.straumur.att_til);\n    const rx = cx + sx, ry = cy + sy;\n    $(\"st-nidurstada\").textContent =\n      \"Drift: \" + (drift >= 0 ? \"+\" : \"\") + drift.toFixed(1) + \"\u00b0\\n\" +\n      \"Stefna \u00ed sj\u00f3: \" + sjo.toFixed(0) + \"\u00b0\\n\" +\n      \"Raunstefna: \" + stefnaV(rx, ry).toFixed(0) + \"\u00b0\\n\" +\n      \"Hra\u00f0i yfir botn: \" + Math.hypot(rx, ry).toFixed(1) + \" kt\";\n  }\n\n  fetch(SLOD, { cache: \"no-store\" })\n    .then(r => r.json())\n    .then(j => {\n      d = j;\n      $(\"st-gogn\").textContent =\n        \"Vindur: \" + j.vindur.hradi_ms + \" m\/s \u00far \" + j.vindur.att + \"\u00b0\\n\" +\n        \"Straumur: \" + j.straumur.hradi_kt.toFixed(2) + \" kt \u00ed \" + j.straumur.att_til.toFixed(0) + \"\u00b0\\n\" +\n        \"Uppf\u00e6rt: \" + j.uppfaert;\n      reikna();\n    })\n    .catch(() => { $(\"st-gogn\").textContent = \"T\u00f3kst ekki a\u00f0 s\u00e6kja g\u00f6gn.\"; });\n\n  $(\"st-stefna\").addEventListener(\"input\", reikna);\n  $(\"st-hradi\").addEventListener(\"input\", reikna);\n})();\n<\/script>\n<p>Views: 0<\/p>","protected":false},"excerpt":{"rendered":"<p>H\u00e9r er einfaldur straum\u00fer\u00edhyrningsreikningur \u00far siglingafr\u00e6\u00f0i ger\u00f0ur \u00ed Python. Mi\u00f0a\u00f0 er vi\u00f0 punkt sex sj\u00f3m\u00edlur fr\u00e1 landi \u00ed mi\u00f0inu &#8220;Vitarnir saman&#8221; \u00e1 Gar\u00f0skaga.Vindhra\u00f0i og stefna er s\u00f3tt til Ve\u00f0urstofu \u00cdslands, straumur og stefna s\u00f3tt til Copernicus Marine. Teki\u00f0 skal fram a\u00f0 ekki skal sigla eftir \u00feessu, eing\u00f6ngu sett upp til gamans. This is a simple [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"parent":0,"menu_order":0,"comment_status":"closed","ping_status":"closed","template":"","meta":{"footnotes":""},"class_list":["post-90","page","type-page","status-publish","hentry"],"_links":{"self":[{"href":"https:\/\/ledrum.is\/index.php?rest_route=\/wp\/v2\/pages\/90","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/ledrum.is\/index.php?rest_route=\/wp\/v2\/pages"}],"about":[{"href":"https:\/\/ledrum.is\/index.php?rest_route=\/wp\/v2\/types\/page"}],"author":[{"embeddable":true,"href":"https:\/\/ledrum.is\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/ledrum.is\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=90"}],"version-history":[{"count":4,"href":"https:\/\/ledrum.is\/index.php?rest_route=\/wp\/v2\/pages\/90\/revisions"}],"predecessor-version":[{"id":96,"href":"https:\/\/ledrum.is\/index.php?rest_route=\/wp\/v2\/pages\/90\/revisions\/96"}],"wp:attachment":[{"href":"https:\/\/ledrum.is\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=90"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}