Skip to main content

axiolid_surface/
elementary.rs

1//! Elementary analytic surfaces.
2
3use axiolid_core::{Frame3, Scalar};
4
5/// Infinite plane.
6#[derive(Debug, Clone, Copy, PartialEq)]
7#[cfg_attr(
8    feature = "serde",
9    derive(serde::Serialize, serde::Deserialize),
10    serde(deny_unknown_fields)
11)]
12pub struct Plane {
13    /// Local frame; `z` is the normal.
14    pub frame: Frame3,
15}
16
17/// Infinite circular cylinder.
18#[derive(Debug, Clone, Copy, PartialEq)]
19#[cfg_attr(
20    feature = "serde",
21    derive(serde::Serialize, serde::Deserialize),
22    serde(deny_unknown_fields)
23)]
24pub struct Cylinder {
25    /// Local frame; `z` is the axis.
26    pub frame: Frame3,
27    /// Radius.
28    pub radius: Scalar,
29}
30
31/// Infinite elliptical cylinder.
32///
33/// Distinct from [`Cylinder`] rather than a special case of it: a circular
34/// cylinder's outward normal is its radial direction, and for an ellipse that
35/// is only true at the four axis points -- elsewhere the two disagree by up to
36/// 53 degrees for a 3:1 ellipse. Anything that assumes radial normals is wrong
37/// here, so the type is separate and forces the question.
38#[derive(Debug, Clone, Copy, PartialEq)]
39#[cfg_attr(
40    feature = "serde",
41    derive(serde::Serialize, serde::Deserialize),
42    serde(deny_unknown_fields)
43)]
44pub struct EllipticalCylinder {
45    /// Local frame; `z` is the axis, `x` and `y` the semi-axis directions.
46    pub frame: Frame3,
47    /// Semi-axis along local `x`.
48    pub semi_axis_x: Scalar,
49    /// Semi-axis along local `y`.
50    pub semi_axis_y: Scalar,
51}
52
53/// Infinite right circular cone.
54#[derive(Debug, Clone, Copy, PartialEq)]
55#[cfg_attr(
56    feature = "serde",
57    derive(serde::Serialize, serde::Deserialize),
58    serde(deny_unknown_fields)
59)]
60pub struct Cone {
61    /// Local frame; `z` is the axis.
62    pub frame: Frame3,
63    /// Radius at the local origin plane.
64    pub radius: Scalar,
65    /// Semi-angle in radians.
66    pub semi_angle: Scalar,
67}
68
69/// Sphere.
70#[derive(Debug, Clone, Copy, PartialEq)]
71#[cfg_attr(
72    feature = "serde",
73    derive(serde::Serialize, serde::Deserialize),
74    serde(deny_unknown_fields)
75)]
76pub struct Sphere {
77    /// Local frame.
78    pub frame: Frame3,
79    /// Radius.
80    pub radius: Scalar,
81}
82
83/// Torus.
84#[derive(Debug, Clone, Copy, PartialEq)]
85#[cfg_attr(
86    feature = "serde",
87    derive(serde::Serialize, serde::Deserialize),
88    serde(deny_unknown_fields)
89)]
90pub struct Torus {
91    /// Local frame; `z` is the revolution axis.
92    pub frame: Frame3,
93    /// Radius from frame origin to tube center.
94    pub major_radius: Scalar,
95    /// Tube radius.
96    pub minor_radius: Scalar,
97}