diff --git a/Cargo.lock b/Cargo.lock index cf2a989..9e9807b 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -311,7 +311,7 @@ checksum = "f1bddf1187be692e79c5ffeab891132dfb0f236ed36a43c7ed39f1165ee20191" [[package]] name = "voxelmap" -version = "0.6.0" +version = "0.6.1" dependencies = [ "clap", "lodepng", diff --git a/Cargo.toml b/Cargo.toml index 3b8eb4f..a473136 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "voxelmap" -version = "0.6.0" +version = "0.6.1" authors = ["raffitz "] edition = "2018" description = "Creates voxel maps to build voxelised objects" diff --git a/src/star.rs b/src/star.rs index 06e60de..934c4c4 100644 --- a/src/star.rs +++ b/src/star.rs @@ -58,7 +58,13 @@ pub fn generate + Clone, S: Into + Copy>( let angle_offset_label = format!("@{}innernangle0", prefix); let outer_prefix = format!("{}outer", prefix); - let outer_scale = star_scale.map(|s| s.into()).unwrap_or(2_f64) * new_scale.unwrap_or(1_f64); + let recip_n: f64 = (n as f64).recip(); + let scale_angle = recip_n * std::f64::consts::PI; + let double_scale_angle = scale_angle + scale_angle; + let default_scale = scale_angle.sin() * double_scale_angle.tan() + scale_angle.cos(); + + let outer_scale = + star_scale.map(|s| s.into()).unwrap_or(default_scale) * new_scale.unwrap_or(1_f64); let (definitive_labels, boundaries, _) = ngon::generate( n,