Struct Radius
A non-negative scalar wrapper over UnitsNet.Length representing a circle's radius.
Unlike a raw UnitsNet.Length, a Radius enforces the physical constraint that a radius cannot be negative. It also provides computed circle geometry (Circumference and Area) so you do not need a separate unpositioned "circle" type — the radius carries those properties directly.
Use Radius anywhere an API specifically expects a radial measurement (e.g. constructing a Circle2). It implicitly converts to UnitsNet.Length so it is interchangeable with raw lengths where needed.
public readonly record struct Radius : IEquatable<Radius>
- Implements
- Inherited Members
Examples
var r = new Radius(Length.FromMeters(5));
Console.WriteLine(r.Circumference); // ≈ 31.42 m
Console.WriteLine(r.Area); // ≈ 78.54 m²
var circle = new Circle2(LengthPoint2.FromMeters(0, 0), r);
Constructors
Radius(Length)
Initialises a Radius with the given length.
public Radius(Length value)
Parameters
valueLengthThe radius length. Must be zero or positive.
Exceptions
- ArgumentException
Thrown when
valueis negative.
Properties
Area
Returns the area enclosed by the circle with this radius (A = π·r²).
public Area Area { get; }
Property Value
- Area
The circle area in Area (square metres when in SI).
Examples
var r = new Radius(Length.FromMeters(1));
Area a = r.Area; // ≈ 3.14159 m²
Centimeters
Gets the radius value in centimetres.
public double Centimeters { get; }
Property Value
Circumference
Returns the circumference of the circle with this radius (C = 2π·r).
public Length Circumference { get; }
Property Value
- Length
The circumference as a UnitsNet.Length.
Examples
var r = new Radius(Length.FromMeters(1));
Length c = r.Circumference; // ≈ 6.2832 m
Diameter
Returns the corresponding Diameter (twice this radius).
public Diameter Diameter { get; }
Property Value
Feet
Gets the radius value in feet.
public double Feet { get; }
Property Value
Inches
Gets the radius value in inches.
public double Inches { get; }
Property Value
Kilometers
Gets the radius value in kilometres.
public double Kilometers { get; }
Property Value
Meters
Gets the radius value in metres.
public double Meters { get; }
Property Value
Millimeters
Gets the radius value in millimetres.
public double Millimeters { get; }
Property Value
Value
The radius length.
public Length Value { get; }
Property Value
- Length
Zero
A Radius of zero.
public static Radius Zero { get; }
Property Value
Methods
FromMeters(double)
Creates a Radius from a value in metres.
public static Radius FromMeters(double meters)
Parameters
metersdoubleThe radius in metres. Must be non-negative.
Returns
ToString()
Returns the fully qualified type name of this instance.
public override string ToString()
Returns
- string
The fully qualified type name.
Operators
implicit operator Length(Radius)
Allows a Radius to be used wherever a UnitsNet.Length is expected.
public static implicit operator Length(Radius radius)
Parameters
radiusRadius
Returns
- Length
operator *(double, Radius)
Scales a radius by a dimensionless factor. Operands may be supplied in either order.
public static Radius operator *(double scalar, Radius radius)
Parameters
Returns
operator *(Radius, double)
Scales this radius by a dimensionless factor.
public static Radius operator *(Radius radius, double scalar)
Parameters
radiusRadiusThe radius to scale.
scalardoubleThe scaling factor. Must be non-negative to keep the result valid.
Returns
operator *(Radius, Radius)
Multiplies two radii to produce an area (r₁ × r₂), useful for expressing r² as an area.
public static Area operator *(Radius r1, Radius r2)
Parameters
Returns
- Area
The product as an Area (r₁ × r₂ in square metres).