Initial WORKING prototype of new algorithm
This commit is contained in:
parent
0af37741aa
commit
e5d010ee5d
48
Cargo.lock
generated
48
Cargo.lock
generated
@ -1,8 +1,10 @@
|
|||||||
|
# This file is automatically @generated by Cargo.
|
||||||
|
# It is not intended for manual editing.
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "aufgabe2"
|
name = "aufgabe2"
|
||||||
version = "0.1.0"
|
version = "0.1.0"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"geo 0.12.0",
|
"geo 0.12.0 (git+https://github.com/FliegendeWurst/geo)",
|
||||||
"svg 0.5.12 (registry+https://github.com/rust-lang/crates.io-index)",
|
"svg 0.5.12 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
]
|
]
|
||||||
|
|
||||||
@ -13,15 +15,15 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "backtrace"
|
name = "backtrace"
|
||||||
version = "0.3.14"
|
version = "0.3.15"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"autocfg 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)",
|
"autocfg 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
"backtrace-sys 0.1.28 (registry+https://github.com/rust-lang/crates.io-index)",
|
"backtrace-sys 0.1.28 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
"cfg-if 0.1.7 (registry+https://github.com/rust-lang/crates.io-index)",
|
"cfg-if 0.1.7 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
"libc 0.2.50 (registry+https://github.com/rust-lang/crates.io-index)",
|
"libc 0.2.51 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
"rustc-demangle 0.1.13 (registry+https://github.com/rust-lang/crates.io-index)",
|
"rustc-demangle 0.1.13 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
"winapi 0.3.6 (registry+https://github.com/rust-lang/crates.io-index)",
|
"winapi 0.3.7 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
@ -29,13 +31,13 @@ name = "backtrace-sys"
|
|||||||
version = "0.1.28"
|
version = "0.1.28"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"cc 1.0.31 (registry+https://github.com/rust-lang/crates.io-index)",
|
"cc 1.0.35 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
"libc 0.2.50 (registry+https://github.com/rust-lang/crates.io-index)",
|
"libc 0.2.51 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "cc"
|
name = "cc"
|
||||||
version = "1.0.31"
|
version = "1.0.35"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
@ -48,7 +50,7 @@ name = "failure"
|
|||||||
version = "0.1.5"
|
version = "0.1.5"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"backtrace 0.3.14 (registry+https://github.com/rust-lang/crates.io-index)",
|
"backtrace 0.3.15 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
"failure_derive 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)",
|
"failure_derive 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
]
|
]
|
||||||
|
|
||||||
@ -59,23 +61,25 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
|
|||||||
dependencies = [
|
dependencies = [
|
||||||
"proc-macro2 0.4.27 (registry+https://github.com/rust-lang/crates.io-index)",
|
"proc-macro2 0.4.27 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
"quote 0.6.11 (registry+https://github.com/rust-lang/crates.io-index)",
|
"quote 0.6.11 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
"syn 0.15.29 (registry+https://github.com/rust-lang/crates.io-index)",
|
"syn 0.15.30 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
"synstructure 0.10.1 (registry+https://github.com/rust-lang/crates.io-index)",
|
"synstructure 0.10.1 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "geo"
|
name = "geo"
|
||||||
version = "0.12.0"
|
version = "0.12.0"
|
||||||
|
source = "git+https://github.com/FliegendeWurst/geo#2a0e2f4147acc09a22ea2a504b58b3389ef8179c"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"failure 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)",
|
"failure 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
"geo-types 0.4.0",
|
"geo-types 0.4.1 (git+https://github.com/FliegendeWurst/geo)",
|
||||||
"num-traits 0.2.6 (registry+https://github.com/rust-lang/crates.io-index)",
|
"num-traits 0.2.6 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
"rstar 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
"rstar 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "geo-types"
|
name = "geo-types"
|
||||||
version = "0.4.0"
|
version = "0.4.1"
|
||||||
|
source = "git+https://github.com/FliegendeWurst/geo#2a0e2f4147acc09a22ea2a504b58b3389ef8179c"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"num-traits 0.2.6 (registry+https://github.com/rust-lang/crates.io-index)",
|
"num-traits 0.2.6 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
"rstar 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
"rstar 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
@ -83,7 +87,7 @@ dependencies = [
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "libc"
|
name = "libc"
|
||||||
version = "0.2.50"
|
version = "0.2.51"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
@ -96,7 +100,7 @@ name = "num_cpus"
|
|||||||
version = "1.10.0"
|
version = "1.10.0"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"libc 0.2.50 (registry+https://github.com/rust-lang/crates.io-index)",
|
"libc 0.2.51 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
@ -142,7 +146,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "syn"
|
name = "syn"
|
||||||
version = "0.15.29"
|
version = "0.15.30"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"proc-macro2 0.4.27 (registry+https://github.com/rust-lang/crates.io-index)",
|
"proc-macro2 0.4.27 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
@ -157,7 +161,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
|
|||||||
dependencies = [
|
dependencies = [
|
||||||
"proc-macro2 0.4.27 (registry+https://github.com/rust-lang/crates.io-index)",
|
"proc-macro2 0.4.27 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
"quote 0.6.11 (registry+https://github.com/rust-lang/crates.io-index)",
|
"quote 0.6.11 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
"syn 0.15.29 (registry+https://github.com/rust-lang/crates.io-index)",
|
"syn 0.15.30 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
"unicode-xid 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
"unicode-xid 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
]
|
]
|
||||||
|
|
||||||
@ -176,7 +180,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "winapi"
|
name = "winapi"
|
||||||
version = "0.3.6"
|
version = "0.3.7"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"winapi-i686-pc-windows-gnu 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
"winapi-i686-pc-windows-gnu 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
@ -195,13 +199,15 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
|
|||||||
|
|
||||||
[metadata]
|
[metadata]
|
||||||
"checksum autocfg 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)" = "a6d640bee2da49f60a4068a7fae53acde8982514ab7bae8b8cea9e88cbcfd799"
|
"checksum autocfg 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)" = "a6d640bee2da49f60a4068a7fae53acde8982514ab7bae8b8cea9e88cbcfd799"
|
||||||
"checksum backtrace 0.3.14 (registry+https://github.com/rust-lang/crates.io-index)" = "cd5a90e2b463010cd0e0ce9a11d4a9d5d58d9f41d4a6ba3dcaf9e68b466e88b4"
|
"checksum backtrace 0.3.15 (registry+https://github.com/rust-lang/crates.io-index)" = "f106c02a3604afcdc0df5d36cc47b44b55917dbaf3d808f71c163a0ddba64637"
|
||||||
"checksum backtrace-sys 0.1.28 (registry+https://github.com/rust-lang/crates.io-index)" = "797c830ac25ccc92a7f8a7b9862bde440715531514594a6154e3d4a54dd769b6"
|
"checksum backtrace-sys 0.1.28 (registry+https://github.com/rust-lang/crates.io-index)" = "797c830ac25ccc92a7f8a7b9862bde440715531514594a6154e3d4a54dd769b6"
|
||||||
"checksum cc 1.0.31 (registry+https://github.com/rust-lang/crates.io-index)" = "c9ce8bb087aacff865633f0bd5aeaed910fe2fe55b55f4739527f2e023a2e53d"
|
"checksum cc 1.0.35 (registry+https://github.com/rust-lang/crates.io-index)" = "5e5f3fee5eeb60324c2781f1e41286bdee933850fff9b3c672587fed5ec58c83"
|
||||||
"checksum cfg-if 0.1.7 (registry+https://github.com/rust-lang/crates.io-index)" = "11d43355396e872eefb45ce6342e4374ed7bc2b3a502d1b28e36d6e23c05d1f4"
|
"checksum cfg-if 0.1.7 (registry+https://github.com/rust-lang/crates.io-index)" = "11d43355396e872eefb45ce6342e4374ed7bc2b3a502d1b28e36d6e23c05d1f4"
|
||||||
"checksum failure 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)" = "795bd83d3abeb9220f257e597aa0080a508b27533824adf336529648f6abf7e2"
|
"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 failure_derive 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)" = "ea1063915fd7ef4309e222a5a07cf9c319fb9c7836b1f89b85458672dbb127e1"
|
||||||
"checksum libc 0.2.50 (registry+https://github.com/rust-lang/crates.io-index)" = "aab692d7759f5cd8c859e169db98ae5b52c924add2af5fbbca11d12fefb567c1"
|
"checksum geo 0.12.0 (git+https://github.com/FliegendeWurst/geo)" = "<none>"
|
||||||
|
"checksum geo-types 0.4.1 (git+https://github.com/FliegendeWurst/geo)" = "<none>"
|
||||||
|
"checksum libc 0.2.51 (registry+https://github.com/rust-lang/crates.io-index)" = "bedcc7a809076656486ffe045abeeac163da1b558e963a31e29fbfbeba916917"
|
||||||
"checksum num-traits 0.2.6 (registry+https://github.com/rust-lang/crates.io-index)" = "0b3a5d7cc97d6d30d8b9bc8fa19bf45349ffe46241e8816f50f62f6d6aaabee1"
|
"checksum num-traits 0.2.6 (registry+https://github.com/rust-lang/crates.io-index)" = "0b3a5d7cc97d6d30d8b9bc8fa19bf45349ffe46241e8816f50f62f6d6aaabee1"
|
||||||
"checksum num_cpus 1.10.0 (registry+https://github.com/rust-lang/crates.io-index)" = "1a23f0ed30a54abaa0c7e83b1d2d87ada7c3c23078d1d87815af3e3b6385fbba"
|
"checksum num_cpus 1.10.0 (registry+https://github.com/rust-lang/crates.io-index)" = "1a23f0ed30a54abaa0c7e83b1d2d87ada7c3c23078d1d87815af3e3b6385fbba"
|
||||||
"checksum pdqselect 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)" = "4ec91767ecc0a0bbe558ce8c9da33c068066c57ecc8bb8477ef8c1ad3ef77c27"
|
"checksum pdqselect 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)" = "4ec91767ecc0a0bbe558ce8c9da33c068066c57ecc8bb8477ef8c1ad3ef77c27"
|
||||||
@ -210,10 +216,10 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
|
|||||||
"checksum rstar 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)" = "120bfe4837befb82c5a637a5a8c490a27d25524ac19fffec5b4e555ca6e36ee8"
|
"checksum rstar 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)" = "120bfe4837befb82c5a637a5a8c490a27d25524ac19fffec5b4e555ca6e36ee8"
|
||||||
"checksum rustc-demangle 0.1.13 (registry+https://github.com/rust-lang/crates.io-index)" = "adacaae16d02b6ec37fdc7acfcddf365978de76d1983d3ee22afc260e1ca9619"
|
"checksum rustc-demangle 0.1.13 (registry+https://github.com/rust-lang/crates.io-index)" = "adacaae16d02b6ec37fdc7acfcddf365978de76d1983d3ee22afc260e1ca9619"
|
||||||
"checksum svg 0.5.12 (registry+https://github.com/rust-lang/crates.io-index)" = "a863ec1f8e7cfd4ea449f77445cca06aac240b9a677ccf12b0f65ef020db52c7"
|
"checksum svg 0.5.12 (registry+https://github.com/rust-lang/crates.io-index)" = "a863ec1f8e7cfd4ea449f77445cca06aac240b9a677ccf12b0f65ef020db52c7"
|
||||||
"checksum syn 0.15.29 (registry+https://github.com/rust-lang/crates.io-index)" = "1825685f977249735d510a242a6727b46efe914bb67e38d30c071b1b72b1d5c2"
|
"checksum syn 0.15.30 (registry+https://github.com/rust-lang/crates.io-index)" = "66c8865bf5a7cbb662d8b011950060b3c8743dca141b054bf7195b20d314d8e2"
|
||||||
"checksum synstructure 0.10.1 (registry+https://github.com/rust-lang/crates.io-index)" = "73687139bf99285483c96ac0add482c3776528beac1d97d444f6e91f203a2015"
|
"checksum synstructure 0.10.1 (registry+https://github.com/rust-lang/crates.io-index)" = "73687139bf99285483c96ac0add482c3776528beac1d97d444f6e91f203a2015"
|
||||||
"checksum threadpool 1.7.1 (registry+https://github.com/rust-lang/crates.io-index)" = "e2f0c90a5f3459330ac8bc0d2f879c693bb7a2f59689c1083fc4ef83834da865"
|
"checksum threadpool 1.7.1 (registry+https://github.com/rust-lang/crates.io-index)" = "e2f0c90a5f3459330ac8bc0d2f879c693bb7a2f59689c1083fc4ef83834da865"
|
||||||
"checksum unicode-xid 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)" = "fc72304796d0818e357ead4e000d19c9c174ab23dc11093ac919054d20a6a7fc"
|
"checksum unicode-xid 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)" = "fc72304796d0818e357ead4e000d19c9c174ab23dc11093ac919054d20a6a7fc"
|
||||||
"checksum winapi 0.3.6 (registry+https://github.com/rust-lang/crates.io-index)" = "92c1eb33641e276cfa214a0522acad57be5c56b10cb348b3c5117db75f3ac4b0"
|
"checksum winapi 0.3.7 (registry+https://github.com/rust-lang/crates.io-index)" = "f10e386af2b13e47c89e7236a7a14a086791a2b88ebad6df9bf42040195cf770"
|
||||||
"checksum winapi-i686-pc-windows-gnu 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)" = "ac3b87c63620426dd9b991e5ce0329eff545bccbbb34f3be09ff6fb6ab51b7b6"
|
"checksum winapi-i686-pc-windows-gnu 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)" = "ac3b87c63620426dd9b991e5ce0329eff545bccbbb34f3be09ff6fb6ab51b7b6"
|
||||||
"checksum winapi-x86_64-pc-windows-gnu 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)" = "712e227841d057c1ee1cd2fb22fa7e5a5461ae8e48fa2ca79ec42cfc1931183f"
|
"checksum winapi-x86_64-pc-windows-gnu 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)" = "712e227841d057c1ee1cd2fb22fa7e5a5461ae8e48fa2ca79ec42cfc1931183f"
|
||||||
|
@ -5,5 +5,5 @@ authors = ["Arne Keller <arne.keller01@yahoo.de>"]
|
|||||||
edition = "2018"
|
edition = "2018"
|
||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
geo = { path = "../../../Code/Github/geo/geo" }
|
geo = { git = "https://github.com/FliegendeWurst/geo" }
|
||||||
svg = "0.5.12"
|
svg = "0.5.12"
|
||||||
|
@ -28,7 +28,7 @@ pub(crate) fn save_world(filename: &str, world: &World) {
|
|||||||
pub(crate) fn generate_svg(tris: &[Triangle]) -> String {
|
pub(crate) fn generate_svg(tris: &[Triangle]) -> String {
|
||||||
let mut document = Document::new()
|
let mut document = Document::new()
|
||||||
// view box at (x,y), (w,h)
|
// view box at (x,y), (w,h)
|
||||||
.set("viewBox", (-350.0, -150.0, 360.0, 150.0))
|
.set("viewBox", (-20.0, -20.0, 30.0, 20.0))
|
||||||
.set("xmlns:xlink", "http://www.w3.org/1999/xlink");
|
.set("xmlns:xlink", "http://www.w3.org/1999/xlink");
|
||||||
|
|
||||||
for tri in tris {
|
for tri in tris {
|
||||||
|
83
src/main.rs
83
src/main.rs
@ -35,6 +35,7 @@ impl cmp::PartialOrd for World {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[allow(clippy::cyclomatic_complexity)]
|
||||||
fn main() {
|
fn main() {
|
||||||
let tris = input::read_input();
|
let tris = input::read_input();
|
||||||
let count_tris = tris.len();
|
let count_tris = tris.len();
|
||||||
@ -171,7 +172,7 @@ fn main() {
|
|||||||
let mut counter = 0;
|
let mut counter = 0;
|
||||||
while !worlds.is_empty() {
|
while !worlds.is_empty() {
|
||||||
counter += 1;
|
counter += 1;
|
||||||
if counter % 10000 == 0 {
|
if counter % 1000 == 0 {
|
||||||
println!("{}/∞", counter);
|
println!("{}/∞", counter);
|
||||||
}
|
}
|
||||||
let w = worlds.pop().unwrap();
|
let w = worlds.pop().unwrap();
|
||||||
@ -194,6 +195,83 @@ fn main() {
|
|||||||
.filter(|(idx1, _tri)| w.tris.iter().all(|(idx2, _tri)| idx1 != idx2))
|
.filter(|(idx1, _tri)| w.tris.iter().all(|(idx2, _tri)| idx1 != idx2))
|
||||||
{
|
{
|
||||||
let next_tri = *next_tri;
|
let next_tri = *next_tri;
|
||||||
|
for (idx, &(_base_idx, base_tri)) in w.tris.iter().enumerate() {
|
||||||
|
let base_tris = &w.tris[0..=idx];
|
||||||
|
let mut w = w.clone();
|
||||||
|
let free_angle = right_of(base_tri);
|
||||||
|
let next_angle = left_of(next_tri);
|
||||||
|
let target = next_angle - PI + free_angle;
|
||||||
|
let mut next_tri = rotate(next_tri, target);
|
||||||
|
if save_counter == 254 {
|
||||||
|
println!("inserting after {:?} in {:?}", idx, w.tris);
|
||||||
|
}
|
||||||
|
if next_tri.0.y < 0.0 || next_tri.1.y < 0.0 || next_tri.2.y < 0.0 {
|
||||||
|
let miny = min(next_tri.0.y, min(next_tri.1.y, next_tri.2.y));
|
||||||
|
next_tri.0.y -= miny;
|
||||||
|
next_tri.1.y -= miny;
|
||||||
|
next_tri.2.y -= miny;
|
||||||
|
}
|
||||||
|
for &delta in &[
|
||||||
|
/*80.0, 30.0, 10.0, 5.0,*/ 1.0, 0.6, 0.32, 0.18, 0.1, 0.06, 0.03, 0.01,
|
||||||
|
0.003,
|
||||||
|
] {
|
||||||
|
let initial_state = base_tris.iter().any(|(_, x)| x.intersects(&next_tri));
|
||||||
|
let dx = if initial_state { delta } else { -delta };
|
||||||
|
while base_tris.iter().any(|(_, x)| x.intersects(&next_tri)) == initial_state {
|
||||||
|
next_tri.0.x += dx;
|
||||||
|
next_tri.1.x += dx;
|
||||||
|
next_tri.2.x += dx;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
w.tris.insert(idx+1, (*next_idx, next_tri));
|
||||||
|
if save_counter == 254 {
|
||||||
|
println!("right {:?}", 0);
|
||||||
|
}
|
||||||
|
if idx + 1 != w.tris.len() - 1 {
|
||||||
|
for &delta in &[
|
||||||
|
/*80.0, 30.0, 10.0, 5.0,*/ 1.0, 0.6, 0.32, 0.18, 0.1, 0.06, 0.03, 0.01,
|
||||||
|
0.003,
|
||||||
|
] {
|
||||||
|
let initial_state = w.tris[0..=idx+1].iter().any(|(_, x)| w.tris[idx+2..].iter().any(|(_, y)| x.intersects(y)));
|
||||||
|
let dx = if initial_state { delta } else { -delta };
|
||||||
|
while w.tris[0..=idx+1].iter().any(|(_, x)| w.tris[idx+2..].iter().any(|(_, y)| x.intersects(y))) == initial_state {
|
||||||
|
for (_, tri) in &mut w.tris[idx+2..] {
|
||||||
|
tri.0.x += dx;
|
||||||
|
tri.1.x += dx;
|
||||||
|
tri.2.x += dx;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
w.normalize();
|
||||||
|
w.calc_width();
|
||||||
|
if save_iterations {
|
||||||
|
display::save_world(&format!("{}b_{}.svg", save_prefix, save_counter), &w);
|
||||||
|
}
|
||||||
|
if w.tris.len() == count_tris {
|
||||||
|
if w.width < best.width {
|
||||||
|
println!("[{}] new best: {}", save_counter, w.width);
|
||||||
|
//println!("{:?}", w.tris);
|
||||||
|
display::save_world(
|
||||||
|
&format!("{}best_{}.svg", save_prefix, save_counter),
|
||||||
|
&w,
|
||||||
|
);
|
||||||
|
best = w;
|
||||||
|
}
|
||||||
|
} else if w.width < best.width {
|
||||||
|
//w.width -= (2.0 * PI - free_angle - next_angle) * 0.01;
|
||||||
|
//if (angle > 50 && angle < 55) || (angle > 88 && angle < 92) {
|
||||||
|
//println!("{:?} -> {:?}", angle, w.width);
|
||||||
|
//}
|
||||||
|
new.push(w);
|
||||||
|
}
|
||||||
|
save_counter += 1;
|
||||||
|
|
||||||
|
let free_angle = left_of(base_tri);
|
||||||
|
let next_angle = right_of(next_tri);
|
||||||
|
let target = (free_angle - next_angle).to_degrees();
|
||||||
|
}
|
||||||
|
/*
|
||||||
//println!("trying {:?}", next_idx);
|
//println!("trying {:?}", next_idx);
|
||||||
let (last_idx, last_tri) = *w.tris.last().unwrap();
|
let (last_idx, last_tri) = *w.tris.last().unwrap();
|
||||||
|
|
||||||
@ -248,6 +326,7 @@ fn main() {
|
|||||||
}
|
}
|
||||||
save_counter += 1;
|
save_counter += 1;
|
||||||
}
|
}
|
||||||
|
*/
|
||||||
}
|
}
|
||||||
worlds.extend(new);
|
worlds.extend(new);
|
||||||
}
|
}
|
||||||
@ -287,6 +366,7 @@ fn right_of(tri: Triangle) -> f32 {
|
|||||||
free_angle
|
free_angle
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
fn main2() {
|
fn main2() {
|
||||||
let tris = input::read_input();
|
let tris = input::read_input();
|
||||||
let count_tris = tris.len();
|
let count_tris = tris.len();
|
||||||
@ -558,6 +638,7 @@ fn main2() {
|
|||||||
println!("best width = {:?}", best.width);
|
println!("best width = {:?}", best.width);
|
||||||
display::save_world("world_best.svg", &best);
|
display::save_world("world_best.svg", &best);
|
||||||
}
|
}
|
||||||
|
*/
|
||||||
|
|
||||||
impl World {
|
impl World {
|
||||||
fn normalize(&mut self) {
|
fn normalize(&mut self) {
|
||||||
|
Loading…
Reference in New Issue
Block a user