Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: adds dynamically calculated polygons
- Loading branch information
1 parent
3cdbf2a
commit 713db8d
Showing
6 changed files
with
952 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
<!DOCTYPE html> | ||
<head> | ||
<link | ||
rel="stylesheet" | ||
href="https://unpkg.com/leaflet@1.9.3/dist/leaflet.css" | ||
integrity="sha256-kLaT2GOSpHechhsozzB+flnD+zUyjE2LlfWPgU04xyI=" | ||
crossorigin="" | ||
/> | ||
<!-- Make sure you put this AFTER Leaflet's CSS --> | ||
<script | ||
src="https://unpkg.com/leaflet@1.9.3/dist/leaflet.js" | ||
integrity="sha256-WBkoXOwTeyKclOHuWtc+i2uENFpDZ9YPdf5Hf+D7ewM=" | ||
crossorigin="" | ||
></script> | ||
<script src="https://unpkg.com/@turf/turf@6/turf.min.js"></script> | ||
<script | ||
src="https://cdnjs.cloudflare.com/ajax/libs/PapaParse/5.4.1/papaparse.min.js" | ||
integrity="sha512-dfX5uYVXzyU8+KHqj8bjo7UkOdg18PaOtpa48djpNbZHwExddghZ+ZmzWT06R5v6NSk3ZUfsH6FNEDepLx9hPQ==" | ||
crossorigin="anonymous" | ||
referrerpolicy="no-referrer" | ||
></script> | ||
<script src="lib/vector2js.js"></script> | ||
<script defer type="module" src="main.js"></script> | ||
<link rel="stylesheet" href="styles.css" /> | ||
<body> | ||
<h1>Prototype Schutz und Rettung: Daten retten Leben</h1> | ||
<div id="container"> | ||
<div id="map"></div> | ||
</div> | ||
</body> | ||
</head> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
/** | ||
* | ||
* @param {[number, number]} origin | ||
* @param {[number, number]} windVector | ||
* @param {number} time | ||
*/ | ||
export function createWindPolygon(origin, windVector, time) { | ||
const vOrigin = new Vector(...origin); | ||
const vWind = new Vector(...windVector).sub(vOrigin); | ||
console.log(vOrigin, vWind); | ||
const rotWind = vWind.rotateDegrees(90); | ||
// WindShift | ||
const windShift = rotWind.clone().rotateDegrees(180).mulScalarSelf(0.5); | ||
// FIRST BASEPOINT | ||
const basePoint1 = vOrigin.clone().addSelf(windShift); | ||
// SECOND BASEPOINT | ||
const basePoint2 = vOrigin.clone().addSelf(windShift).addSelf(rotWind); | ||
const targetPoint1 = basePoint1.add(vWind.mulScalar(time)); | ||
const targetPoint2 = basePoint2.add(vWind.mulScalar(time)); | ||
const polygon = [ | ||
basePoint2.toArray(), | ||
basePoint1.toArray(), | ||
targetPoint1.toArray(), | ||
targetPoint2.toArray(), | ||
]; | ||
console.log(polygon); | ||
return polygon; | ||
} |
Oops, something went wrong.