Skip to main content

Crate use_trigonometry

Crate use_trigonometry 

Source
Expand description

§use-trigonometry

Small angle and trigonometry helpers for `RustUse`.
Explicit degree/radian handling, normalization, and direct sine, cosine, and tangent helpers.

Rust 1.95.0+ Edition 2024 Angle helpers License MIT or Apache-2.0

§Install

[dependencies]
use-trigonometry = "0.0.1"

§Foundation

use-trigonometry provides a deliberately small trigonometry surface around explicit angle units. The crate exposes an Angle type stored in radians, conversion helpers for degrees and radians, normalization helpers for wrapped inputs, and direct sin, cos, and tan utilities for degree-based call sites. The first slice stays close to ordinary f64 values instead of introducing a larger symbolic or identity-heavy framework.

Explicit units
Angle, degrees_to_radians, and radians_to_degrees keep unit intent visible at the call site.
Wrapping helpers
normalized, normalized_signed, normalize_degrees, and normalize_radians handle wrapped inputs directly.
Basic trig evaluation
sin, cos, tan, sin_deg, cos_deg, and tan_deg cover the common numeric cases.
Helper groupPrimary itemsBest fit
Angle values and unit conversionAngle, degrees_to_radians, radians_to_degreesCode that should stay explicit about whether an input is degrees or radians
NormalizationAngle::normalized, Angle::normalized_signed, normalize_degrees, normalize_radiansHandling wrapped or cyclic inputs before downstream math
Direct trig helpersAngle::sin, Angle::cos, Angle::tan, sin_deg, cos_deg, tan_degSmall apps and utilities that want direct numeric trig without a larger abstraction

§When to use directly

Choose use-trigonometry directly when angle or trigonometric utilities are the only surface you need and you want to keep that concern narrower than the full facade.

ScenarioUse use-trigonometry directly?Why
You need explicit degree/radian handling without a broader math facadeYesThe crate keeps unit intent local and direct
You need wrapped-angle normalization and basic trig evaluationYesThe current surface already covers those cases with a small API
You also need geometry, calculus, or other math domainsUsually nouse-math can compose the concrete surfaces behind features

§Scope

  • The current surface is intentionally small and concrete.
  • Helpers stay numeric and explicit instead of introducing symbolic identities or generalized expression trees.
  • Geometry-specific orientation and calculus-specific analytic helpers belong in adjacent focused crates.

§Examples

§Angle conversion and normalization

use use_trigonometry::{Angle, degrees_to_radians, normalize_degrees, radians_to_degrees};

let acute = Angle::from_degrees(30.0);
let wrapped = Angle::from_degrees(765.0).normalized();

assert!((acute.radians() - degrees_to_radians(30.0)).abs() < 1.0e-12);
assert!((acute.degrees() - radians_to_degrees(acute.radians())).abs() < 1.0e-12);
assert!((wrapped.degrees() - 45.0).abs() < 1.0e-12);
assert!((normalize_degrees(-90.0) - 270.0).abs() < 1.0e-12);

§Direct trig helpers

use use_trigonometry::{Angle, cos_deg, sin_deg, tan_deg};

let acute = Angle::from_degrees(30.0);

assert!((acute.sin() - 0.5).abs() < 1.0e-12);
assert!((acute.cos() - cos_deg(30.0)).abs() < 1.0e-12);
assert!((sin_deg(30.0) - 0.5).abs() < 1.0e-12);
assert!((tan_deg(45.0) - 1.0).abs() < 1.0e-12);

§Status

use-trigonometry is a concrete pre-1.0 crate in the RustUse docs surface. The API remains intentionally small while adjacent geometry and calculus crates continue to grow around it. Trigonometric utilities for RustUse.

Modules§

prelude
Common ergonomic imports for use-trigonometry.

Structs§

Angle
Explicit angle value stored in radians.

Functions§

cos_deg
Evaluates cos for a degrees input.
degrees_to_radians
Converts a degrees value into radians.
normalize_degrees
Normalizes a degrees value into the interval [0, 360).
normalize_radians
Normalizes a radians value into the interval [0, 2π).
radians_to_degrees
Converts a radians value into degrees.
sin_deg
Evaluates sin for a degrees input.
tan_deg
Evaluates tan for a degrees input.