1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
// Copyright (c) 2024-2026 The Regents of the University of Michigan.
// Part of hoomd-rs, released under the BSD 3-Clause License.
//! Implement [`Sphero`]
use ;
use crate::;
use PositiveReal;
use InnerProduct;
/// Round a shape with a given radius.
///
/// [`Sphero`] modifies a given shape by sweeping it with a hypersphere of the
/// given radius. The resulting [`Sphero<S>`] type is a shape itself. If `S`
/// implements [`crate::SupportMapping`], then [`Sphero<S>`] can be used in
/// [`IntersectsAt`](crate::IntersectsAt) tests with other convex shapes. See
/// the full list of implementations below to see what other traits [`Sphero<S>`]
/// implements for a given `S`.
///
/// # Example
///
/// Test if a circle overlaps with a rounded rectangle:
/// ```
/// use hoomd_geometry::{
/// Convex, IntersectsAt,
/// shape::{Circle, Rectangle, Sphero},
/// };
/// use hoomd_vector::{Angle, Cartesian};
/// use std::f64::consts::PI;
///
/// # fn main() -> Result<(), Box<dyn std::error::Error>> {
/// let circle = Convex(Circle {
/// radius: 0.5.try_into()?,
/// });
/// let rectangle = Rectangle {
/// edge_lengths: [3.0.try_into()?, 2.0.try_into()?],
/// };
/// let rounded_rectangle = Convex(Sphero {
/// shape: rectangle,
/// rounding_radius: 0.5.try_into()?,
/// });
///
/// assert!(rounded_rectangle.intersects_at(
/// &circle,
/// &[2.4, 0.0].into(),
/// &Angle::default()
/// ));
/// assert!(!rounded_rectangle.intersects_at(
/// &circle,
/// &[0.0, 2.4].into(),
/// &Angle::default()
/// ));
/// assert!(circle.intersects_at(
/// &rounded_rectangle,
/// &[0.0, 2.4].into(),
/// &Angle::from(PI / 2.0)
/// ));
/// # Ok(())
/// # }
/// ```