Updated descriptions for some geometric primitives to include more detail (#13937)

This is an attempt to address issue #13725, which was about the
geometric primitives in the bevy_math crate lacking some detail in the
docs.

# Objective

Fixes #13725

## Solution

Added details to the docstrings. Mostly this consisted of specifying
that the primitives are centered on the origin, or describing how
they're defined (e.g., a circle is the set of all points some distance
from the origin).

## Testing

No testing, since the only changes were to docs.
This commit is contained in:
Octorine 2024-06-20 07:16:27 -05:00 committed by GitHub
parent 8635a0f916
commit dcb191bb18
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 16 additions and 12 deletions

View file

@ -8,7 +8,7 @@ use bevy_reflect::{std_traits::ReflectDefault, Reflect};
#[cfg(all(feature = "serialize", feature = "bevy_reflect"))]
use bevy_reflect::{ReflectDeserialize, ReflectSerialize};
/// A circle primitive
/// A circle primitive, representing the set of points some distance from the origin
#[derive(Clone, Copy, Debug, PartialEq)]
#[cfg_attr(feature = "serialize", derive(serde::Serialize, serde::Deserialize))]
#[cfg_attr(
@ -741,7 +741,7 @@ mod arc_tests {
}
}
/// An ellipse primitive
/// An ellipse primitive, which is like a circle, but the width and height can be different
#[derive(Clone, Copy, Debug, PartialEq)]
#[cfg_attr(feature = "serialize", derive(serde::Serialize, serde::Deserialize))]
#[cfg_attr(
@ -989,6 +989,8 @@ impl Measured2d for Annulus {
}
/// A rhombus primitive, also known as a diamond shape.
/// A four sided polygon, centered on the origin, where opposite sides are parallel but without
/// requiring right angles.
#[derive(Clone, Copy, Debug, PartialEq)]
#[cfg_attr(feature = "serialize", derive(serde::Serialize, serde::Deserialize))]
#[cfg_attr(
@ -1163,7 +1165,7 @@ impl Plane2d {
}
}
/// An infinite line along a direction in 2D space.
/// An infinite line going through the origin along a direction in 2D space.
///
/// For a finite line: [`Segment2d`]
#[derive(Clone, Copy, Debug, PartialEq)]
@ -1180,7 +1182,7 @@ pub struct Line2d {
}
impl Primitive2d for Line2d {}
/// A segment of a line along a direction in 2D space.
/// A segment of a line going through the origin along a direction in 2D space.
#[derive(Clone, Copy, Debug, PartialEq)]
#[cfg_attr(feature = "serialize", derive(serde::Serialize, serde::Deserialize))]
#[cfg_attr(feature = "bevy_reflect", derive(Reflect), reflect(Debug, PartialEq))]
@ -1472,7 +1474,7 @@ impl Measured2d for Triangle2d {
}
}
/// A rectangle primitive
/// A rectangle primitive, which is like a square, except that the width and height can be different
#[derive(Clone, Copy, Debug, PartialEq)]
#[cfg_attr(feature = "serialize", derive(serde::Serialize, serde::Deserialize))]
#[cfg_attr(
@ -1626,7 +1628,7 @@ impl BoxedPolygon {
}
}
/// A polygon where all vertices lie on a circle, equally far apart.
/// A polygon centered on the origin where all vertices lie on a circle, equally far apart.
#[derive(Clone, Copy, Debug, PartialEq)]
#[cfg_attr(feature = "serialize", derive(serde::Serialize, serde::Deserialize))]
#[cfg_attr(

View file

@ -8,7 +8,7 @@ use bevy_reflect::{std_traits::ReflectDefault, Reflect};
#[cfg(all(feature = "serialize", feature = "bevy_reflect"))]
use bevy_reflect::{ReflectDeserialize, ReflectSerialize};
/// A sphere primitive
/// A sphere primitive, representing the set of all points some distance from the origin
#[derive(Clone, Copy, Debug, PartialEq)]
#[cfg_attr(feature = "serialize", derive(serde::Serialize, serde::Deserialize))]
#[cfg_attr(
@ -216,7 +216,7 @@ impl InfinitePlane3d {
}
}
/// An infinite line along a direction in 3D space.
/// An infinite line going through the origin along a direction in 3D space.
///
/// For a finite line: [`Segment3d`]
#[derive(Clone, Copy, Debug, PartialEq)]
@ -232,7 +232,7 @@ pub struct Line3d {
}
impl Primitive3d for Line3d {}
/// A segment of a line along a direction in 3D space.
/// A segment of a line going through the origin along a direction in 3D space.
#[doc(alias = "LineSegment3d")]
#[derive(Clone, Copy, Debug, PartialEq)]
#[cfg_attr(feature = "serialize", derive(serde::Serialize, serde::Deserialize))]
@ -353,7 +353,8 @@ impl BoxedPolyline3d {
}
}
/// A cuboid primitive, more commonly known as a box.
/// A cuboid primitive, which is like a cube, except that the x, y, and z dimensions are not
/// required to be the same.
#[derive(Clone, Copy, Debug, PartialEq)]
#[cfg_attr(feature = "serialize", derive(serde::Serialize, serde::Deserialize))]
#[cfg_attr(
@ -445,7 +446,7 @@ impl Measured3d for Cuboid {
}
}
/// A cylinder primitive
/// A cylinder primitive centered on the origin
#[derive(Clone, Copy, Debug, PartialEq)]
#[cfg_attr(feature = "serialize", derive(serde::Serialize, serde::Deserialize))]
#[cfg_attr(
@ -522,7 +523,7 @@ impl Measured3d for Cylinder {
}
}
/// A 3D capsule primitive.
/// A 3D capsule primitive centered on the origin
/// A three-dimensional capsule is defined as a surface at a distance (radius) from a line
#[derive(Clone, Copy, Debug, PartialEq)]
#[cfg_attr(feature = "serialize", derive(serde::Serialize, serde::Deserialize))]
@ -723,6 +724,7 @@ pub enum TorusKind {
}
/// A torus primitive, often representing a ring or donut shape
/// The set of points some distance from a circle centered at the origin
#[derive(Clone, Copy, Debug, PartialEq)]
#[cfg_attr(feature = "serialize", derive(serde::Serialize, serde::Deserialize))]
#[cfg_attr(