Table of Contents

Struct Radius

Namespace
Thunder.UnitsNET.Vectors.Geometry
Assembly
Thunder.UnitsNET.Vectors.Geometry.dll

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

value Length

The radius length. Must be zero or positive.

Exceptions

ArgumentException

Thrown when value is 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

double

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

Diameter

A Diameter equal to 2 × Value.

Feet

Gets the radius value in feet.

public double Feet { get; }

Property Value

double

Inches

Gets the radius value in inches.

public double Inches { get; }

Property Value

double

Kilometers

Gets the radius value in kilometres.

public double Kilometers { get; }

Property Value

double

Meters

Gets the radius value in metres.

public double Meters { get; }

Property Value

double

Millimeters

Gets the radius value in millimetres.

public double Millimeters { get; }

Property Value

double

Value

The radius length.

public Length Value { get; }

Property Value

Length

Zero

A Radius of zero.

public static Radius Zero { get; }

Property Value

Radius

Methods

FromMeters(double)

Creates a Radius from a value in metres.

public static Radius FromMeters(double meters)

Parameters

meters double

The radius in metres. Must be non-negative.

Returns

Radius

A Radius with the specified length.

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

radius Radius

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

scalar double

The scaling factor.

radius Radius

The radius to scale.

Returns

Radius

A new Radius scaled by scalar.

operator *(Radius, double)

Scales this radius by a dimensionless factor.

public static Radius operator *(Radius radius, double scalar)

Parameters

radius Radius

The radius to scale.

scalar double

The scaling factor. Must be non-negative to keep the result valid.

Returns

Radius

A new Radius scaled by scalar.

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

r1 Radius

The first radius.

r2 Radius

The second radius.

Returns

Area

The product as an Area (r₁ × r₂ in square metres).

v0.7.0 ▼