This commit is contained in:
arnekeller 2019-02-09 16:18:58 +01:00
parent 01b5037ed8
commit 6a29ec6223
5 changed files with 22 additions and 16 deletions

10
Cargo.lock generated
View File

@ -1,9 +1,11 @@
# This file is automatically @generated by Cargo.
# It is not intended for manual editing.
[[package]]
name = "aufgabe1"
version = "0.1.0"
dependencies = [
"chrono 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)",
"geo 0.11.0",
"geo 0.11.0 (git+https://github.com/georust/geo)",
"svg 0.5.12 (registry+https://github.com/rust-lang/crates.io-index)",
]
@ -77,9 +79,10 @@ dependencies = [
[[package]]
name = "geo"
version = "0.11.0"
source = "git+https://github.com/georust/geo#96c7846d703a74f59ba68e68929415cbce4a68d9"
dependencies = [
"failure 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)",
"geo-types 0.3.0",
"geo-types 0.3.0 (git+https://github.com/georust/geo)",
"num-traits 0.2.6 (registry+https://github.com/rust-lang/crates.io-index)",
"rstar 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)",
]
@ -87,6 +90,7 @@ dependencies = [
[[package]]
name = "geo-types"
version = "0.3.0"
source = "git+https://github.com/georust/geo#96c7846d703a74f59ba68e68929415cbce4a68d9"
dependencies = [
"num-traits 0.2.6 (registry+https://github.com/rust-lang/crates.io-index)",
"rstar 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)",
@ -219,6 +223,8 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
"checksum chrono 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)" = "45912881121cb26fad7c38c17ba7daa18764771836b34fab7d3fbd93ed633878"
"checksum failure 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)" = "795bd83d3abeb9220f257e597aa0080a508b27533824adf336529648f6abf7e2"
"checksum failure_derive 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)" = "ea1063915fd7ef4309e222a5a07cf9c319fb9c7836b1f89b85458672dbb127e1"
"checksum geo 0.11.0 (git+https://github.com/georust/geo)" = "<none>"
"checksum geo-types 0.3.0 (git+https://github.com/georust/geo)" = "<none>"
"checksum libc 0.2.47 (registry+https://github.com/rust-lang/crates.io-index)" = "48450664a984b25d5b479554c29cc04e3150c97aa4c01da5604a2d4ed9151476"
"checksum num-integer 0.1.39 (registry+https://github.com/rust-lang/crates.io-index)" = "e83d528d2677f0518c570baf2b7abdcf0cd2d248860b68507bdcb3e91d4c0cea"
"checksum num-traits 0.2.6 (registry+https://github.com/rust-lang/crates.io-index)" = "0b3a5d7cc97d6d30d8b9bc8fa19bf45349ffe46241e8816f50f62f6d6aaabee1"

View File

@ -9,6 +9,6 @@ codegen-units = 1
opt-level = 3
[dependencies]
geo = { path = "/home/arne/Documents/Code/Github/geo/geo" }
geo = { git = "https://github.com/georust/geo" }
svg = "0.5.11"
chrono = "0.4.6"

View File

@ -66,7 +66,7 @@
\tableofcontents
\section{Lösungsidee}
Zunächst kann man feststellen, dass der letzte Abschnitt jeder Route zum Bus immer exakt gerade ist. In einer Kurve würde Lisa weiter laufen, ohne am Ende auf der y-Achse weiter zu sein. Es gibt keinen, einen oder zwei Treffpunkte, bei denen Lisa (ohne zu warten) den Bus erwischt:
Zunächst kann man feststellen, dass der letzte Abschnitt jeder Route zum Bus immer exakt gerade ist. In einer Kurve würde Lisa länger laufen, ohne am Ende auf der y-Achse weiter zu sein. Es gibt keinen, einen oder zwei Treffpunkte, bei denen Lisa (ohne zu warten) den Bus erwischt:
\begin{figure}[H]
\centering

View File

@ -13,7 +13,7 @@ pub(crate) fn dump_latex_code(route: &[RunState], polys: &[Polygon]) {
let mut xmax = 0.0;
let mut ymax = 0.0;
for poly in polys {
for point in poly.exterior.points_iter() {
for point in poly.exterior().points_iter() {
let x = point.x() / SCALE;
let y = point.y() / SCALE;
if x > xmax {
@ -33,11 +33,11 @@ pub(crate) fn dump_latex_code(route: &[RunState], polys: &[Polygon]) {
println!("\\tkzGrid");
for (idx, poly) in polys.iter().enumerate() {
print!("\\tkzDefPoints{{");
for (poly_idx, point) in poly.exterior.points_iter().enumerate() {
for (poly_idx, point) in poly.exterior().points_iter().enumerate() {
let x = point.x() / SCALE;
let y = point.y() / SCALE;
print!("{}/{}/P{}_{}", x, y, idx, poly_idx);
if poly_idx != poly.exterior.0.len() - 1 {
if poly_idx != poly.exterior().0.len() - 1 {
print!(",");
}
if x > xmax {
@ -49,9 +49,9 @@ pub(crate) fn dump_latex_code(route: &[RunState], polys: &[Polygon]) {
}
println!("}}");
print!("\\tkzDrawPolygon[fill=black,line width=1pt,opacity=0.5](");
for (poly_idx, _) in poly.exterior.points_iter().enumerate() {
for (poly_idx, _) in poly.exterior().points_iter().enumerate() {
print!("P{}_{}", idx, poly_idx);
if poly_idx != poly.exterior.0.len() - 1 {
if poly_idx != poly.exterior().0.len() - 1 {
print!(",");
}
}
@ -163,7 +163,7 @@ pub(crate) fn generate_svg(
}
for path in polys.iter().map(|poly| {
let coords = &poly.exterior.0;
let coords = &poly.exterior().0;
let first = coords[0].x_y();
let mut first: (f64, f64) = (first.0.into(), first.1.into());
first.1 *= -1.0;

View File

@ -55,7 +55,7 @@ fn main() {
// alle Ecken der Hindernisse bestimmen
let points = polys
.iter()
.map(|x| x.exterior.0.clone())
.map(|x| x.exterior().0.clone())
.flatten()
.collect::<Vec<_>>();
@ -181,7 +181,7 @@ fn main() {
"Polygon {:02}: ",
polys
.iter()
.position(|p| p.exterior.0.contains(&s.pos.into()))
.position(|p| p.exterior().0.contains(&s.pos.into()))
.unwrap() + 1
);
}
@ -193,7 +193,7 @@ fn main() {
let seconds = length / (15.0 / 3.6);
eprintln!("Dauer: {:02.0}:{:02.0}", seconds / 60.0, seconds % 60.0);
// beste Route grafisch ausgeben
display::dump_svg(&route, &polys);
display::dump_latex_code(&route, &polys);
}
fn none_intersect(polys: &[Polygon], line: &Line) -> bool {
@ -202,9 +202,9 @@ fn none_intersect(polys: &[Polygon], line: &Line) -> bool {
middle.y += line.dy() / 2.0;
let middle: Point = middle.into();
'poly: for p in polys {
for l in p.exterior.lines().chain(vec![Line::new(
p.exterior.0[0],
*p.exterior.0.last().unwrap(),
for l in p.exterior().lines().chain(vec![Line::new(
p.exterior().0[0],
*p.exterior().0.last().unwrap(),
)]) {
if (l.start == line.start && l.end == line.end)
|| (l.start == line.end && l.end == line.start)