[95] Taschen-Schiebetür: Tasche auch in Bogenwänden (3D je Sehne, Schnitt entlang des Bogens) und unter schräger Oberkante (3D-Teile behalten die Dachebene)
This commit is contained in:
3 files changed
+180
-22
No files matched your search
@@ -1498,9 +1498,7 @@ fn subtract_pockets_in_section(cuts: Vec<Cut>, p: &Project, base: (f64, f64), u:
|
||||
let mut rects: Vec<Vec<[f64; 2]>> = Vec::new();
|
||||
for w in &p.walls {
|
||||
let Some(ops) = by_wall.get(w.id.as_str()) else { continue };
|
||||
if crate::wall_arc::WallArc::of_wall(w).is_some() {
|
||||
continue;
|
||||
}
|
||||
let arc = crate::wall_arc::WallArc::of_wall(w);
|
||||
let (dx, dy) = (w.end.x - w.start.x, w.end.y - w.start.y);
|
||||
let l = hypot2(dx, dy);
|
||||
if !(l > 1e-9) {
|
||||
@@ -1508,9 +1506,20 @@ fn subtract_pockets_in_section(cuts: Vec<Cut>, p: &Project, base: (f64, f64), u:
|
||||
}
|
||||
let (ux, uy) = (dx / l, dy / l);
|
||||
for [u0, u1, n0, n1, z0, z1] in model3d::wall_pocket_cuts(p, w, ops) {
|
||||
let at = |a: f64, n: f64| [w.start.x + ux * a - uy * n, w.start.y + uy * a + ux * n];
|
||||
let mut pts = vec![4.0];
|
||||
for q in [at(u0, n0), at(u1, n0), at(u1, n1), at(u0, n1)] {
|
||||
// Grundriss der Tasche; Bogenwand ([T2]): Ring entlang des Bogens (Achsmass = Bogenlänge).
|
||||
let ring: Vec<[f64; 2]> = match arc {
|
||||
Some(a) => {
|
||||
let st = a.stations(u0, u1, a.r_max(n0, n1));
|
||||
let side = |n: f64| st.iter().map(move |&s| a.point(s, n)).map(|q| [q.x, q.y]);
|
||||
side(n0).chain(side(n1).rev()).collect()
|
||||
}
|
||||
None => {
|
||||
let at = |a: f64, n: f64| [w.start.x + ux * a - uy * n, w.start.y + uy * a + ux * n];
|
||||
vec![at(u0, n0), at(u1, n0), at(u1, n1), at(u0, n1)]
|
||||
}
|
||||
};
|
||||
let mut pts = vec![ring.len() as f64];
|
||||
for q in ring {
|
||||
pts.extend(q);
|
||||
}
|
||||
let f = crate::voids::section_rects_flat(&pts, &[base.0, base.1, u.0, u.1]);
|
||||
@@ -2764,6 +2773,41 @@ mod tests {
|
||||
assert!((full - wall_area(&p, 0.5)).abs() < 1e-4);
|
||||
}
|
||||
|
||||
/// [95][T2] Schnitt durch die Tasche in der Bogenwand (radial) und unter schräger Oberkante.
|
||||
#[test]
|
||||
fn schnitt_durch_die_tasche_bogen_und_dach() {
|
||||
use crate::plan::walls::tests::{pocket_project_with, POCKET_BULGE};
|
||||
let wall_area = |p: &Project, a: Vec2, b: Vec2| {
|
||||
let l = LevelSpec { kind: "section".into(), line: Some([a, b]), ..Default::default() };
|
||||
let out = compute_section(p, &l, &[]).unwrap().unwrap();
|
||||
out.cuts
|
||||
.iter()
|
||||
.filter(|c| c.kind == Kind::Wall)
|
||||
.map(|c| {
|
||||
let n = c.pts.len();
|
||||
(0..n).map(|i| c.pts[i][0] * c.pts[(i + 1) % n][1] - c.pts[(i + 1) % n][0] * c.pts[i][1]).sum::<f64>().abs() / 2.0
|
||||
})
|
||||
.sum::<f64>()
|
||||
};
|
||||
let arc = crate::wall_arc::WallArc::of(kernel2d::Vec2::new(0.0, 0.0), kernel2d::Vec2::new(4.0, 0.0), Some(POCKET_BULGE)).unwrap();
|
||||
let radial = |s: f64| {
|
||||
let (c, n) = (arc.point(s, 0.0), arc.normal(s));
|
||||
(Vec2 { x: c.x - n.x, y: c.y - n.y }, Vec2 { x: c.x + n.x, y: c.y + n.y })
|
||||
};
|
||||
let flat = |x: f64| (Vec2 { x, y: -1.0 }, Vec2 { x, y: 1.0 });
|
||||
for (bulge, roof) in [(Some(POCKET_BULGE), false), (None, true)] {
|
||||
let line = |s: f64| if bulge.is_some() { radial(s) } else { flat(s) };
|
||||
let full = pocket_project_with(DoorTypeKind::Schiebe, None, 1.0, bulge, roof);
|
||||
let p = pocket_project_with(DoorTypeKind::Tasche, None, 1.0, bulge, roof);
|
||||
for (s, k) in [(0.5, 0.07 * 2.0), (3.5, 0.0)] {
|
||||
let (a, b) = line(s);
|
||||
let (fa, pa) = (wall_area(&full, a, b), wall_area(&p, a, b));
|
||||
assert!(fa > 0.3, "{bulge:?} {roof} {fa}");
|
||||
assert!((fa - pa - k).abs() < 1e-3, "{bulge:?} {roof} s={s}: {fa} {pa}");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn beispiel_schnitt_mit_pick_ids() {
|
||||
let p = sample();
|
||||
|
||||
@@ -1068,6 +1068,23 @@ pub(crate) mod tests {
|
||||
p
|
||||
}
|
||||
|
||||
/// Bogen von 90° (Bulge tan 22.5°) über dieselbe Sehne 0..4: Achsmass = Bogenlänge ([T2]).
|
||||
pub(crate) const POCKET_BULGE: f64 = 0.414_213_562_373_095_1;
|
||||
|
||||
/// [95] Wie [`pocket_project`], Wand als Bogen (`bulge`) oder unter einem Satteldach mit First quer
|
||||
/// zur Wand (`roof`: Wand an Dach angeschlossen, schräge Oberkante, Tür bleibt darunter).
|
||||
pub(crate) fn pocket_project_with(kind: DoorTypeKind, hinge: Option<OpeningHinge>, leaves: f64, bulge: Option<f64>, roof: bool) -> Project {
|
||||
let mut p = pocket_project(kind, hinge, leaves);
|
||||
p.walls[0].bulge = bulge;
|
||||
if roof {
|
||||
p.walls[0].roof_attach = Some(true);
|
||||
let rect = serde_json::json!([{"x":-0.5,"y":-2},{"x":4.5,"y":-2},{"x":4.5,"y":2},{"x":-0.5,"y":2}]);
|
||||
p.roofs = Some(vec![serde_json::from_value(serde_json::json!({"id": "R", "type": "roof", "floorId": "eg", "categoryCode": "35",
|
||||
"outline": rect, "shape": "sattel", "pitchDeg": 30, "overhang": 0, "ridgeAxis": "y", "baseElevation": 2.4, "thickness": 0.2})).unwrap()]);
|
||||
}
|
||||
p
|
||||
}
|
||||
|
||||
fn wall_prims(p: &Project) -> Vec<Primitive> {
|
||||
let t = serde_json::json!({ "floor": "eg", "show": ["20"], "grey": [] }).to_string();
|
||||
super::super::domains::plan_domains(p, &super::super::domains::PlanArgs::parse(1.0, &t).unwrap()).unwrap().walls
|
||||
@@ -1146,4 +1163,38 @@ pub(crate) mod tests {
|
||||
let (a, _) = hatched(&wall_prims(&pocket_project(DoorTypeKind::Tasche, None, 2.0)));
|
||||
assert!((full - a - 2.0 * (0.45 + 0.05) * 0.07).abs() < 1e-5, "{full} {a}");
|
||||
}
|
||||
|
||||
/// [95][T2] Bogenwand: die Tasche folgt dem Bogen (Länge entlang der Achse); unter schräger
|
||||
/// Oberkante wie gerade.
|
||||
#[test]
|
||||
fn tasche_in_bogenwand_und_unter_dach_ausgespart() {
|
||||
let cavity = (0.9 + 0.05) * 0.07;
|
||||
for (bulge, roof) in [(Some(POCKET_BULGE), false), (None, true)] {
|
||||
for (hinge, leaves, k) in [(None, 1.0, cavity), (Some(OpeningHinge::End), 1.0, cavity), (None, 2.0, 2.0 * (0.45 + 0.05) * 0.07)] {
|
||||
let (full, _) = hatched(&wall_prims(&pocket_project_with(DoorTypeKind::Schiebe, hinge, leaves, bulge, roof)));
|
||||
let (a, _) = hatched(&wall_prims(&pocket_project_with(DoorTypeKind::Tasche, hinge, leaves, bulge, roof)));
|
||||
assert!((full - a - k).abs() < 2e-4, "{bulge:?} {roof} {hinge:?} {leaves}: {full} {a} {k}");
|
||||
}
|
||||
}
|
||||
// Bogen: die Wandmitte am Taschenpunkt (Achsmass 0.5) ist hohl, an der Gegenseite (3.5) massiv.
|
||||
let arc = crate::wall_arc::WallArc::of(kernel2d::Vec2::new(0.0, 0.0), kernel2d::Vec2::new(4.0, 0.0), Some(POCKET_BULGE)).unwrap();
|
||||
let (_, polys) = hatched(&wall_prims(&pocket_project_with(DoorTypeKind::Tasche, None, 1.0, Some(POCKET_BULGE), false)));
|
||||
let inside = |q: kernel2d::Vec2| {
|
||||
let q = v2(q.x, q.y);
|
||||
polys.iter().any(|pts| {
|
||||
let n = pts.len();
|
||||
let mut c = false;
|
||||
for i in 0..n {
|
||||
let (a, b) = (pts[i], pts[(i + 1) % n]);
|
||||
if (a.y > q.y) != (b.y > q.y) && q.x < (b.x - a.x) * (q.y - a.y) / (b.y - a.y) + a.x {
|
||||
c = !c;
|
||||
}
|
||||
}
|
||||
c
|
||||
})
|
||||
};
|
||||
assert!(!inside(arc.point(0.5, 0.001)));
|
||||
assert!(inside(arc.point(3.5, 0.001)));
|
||||
assert!(inside(arc.point(0.5, 0.05)) && inside(arc.point(0.5, -0.07)));
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user