Table of Contents

Struct Diameter

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

A non-negative scalar wrapper over UnitsNet.Length representing a circle's diameter.

A Diameter is the full width of a circle: exactly twice the Radius. Like Radius, it enforces the non-negative constraint at construction time.

It implicitly converts to UnitsNet.Length for compatibility with APIs that accept raw lengths, and can be converted to a Radius via the Radius property.

public readonly record struct Diameter : IEquatable<Diameter>
Implements
Inherited Members

Examples

var d = new Diameter(Length.FromMeters(10));
Radius r = d.Radius; // 5 m
Length l = d;        // 10 m (implicit conversion)

Constructors

Diameter(Length)

Initialises a Diameter with the given length.

public Diameter(Length value)

Parameters

value Length

The diameter length. Must be zero or positive.

Exceptions

ArgumentException

Thrown when value is negative.

Properties

Radius

Returns the corresponding Radius (half this diameter).

public Radius Radius { get; }

Property Value

Radius

A Radius equal to Value / 2.

Value

The diameter length.

public Length Value { get; }

Property Value

Length

Zero

A Diameter of zero.

public static Diameter Zero { get; }

Property Value

Diameter

Methods

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(Diameter)

Allows a Diameter to be used wherever a UnitsNet.Length is expected.

public static implicit operator Length(Diameter diameter)

Parameters

diameter Diameter

Returns

Length

operator *(double, Diameter)

Scales a diameter by a dimensionless factor. Operands may be supplied in either order.

public static Diameter operator *(double scalar, Diameter diameter)

Parameters

scalar double

The scaling factor.

diameter Diameter

The diameter to scale.

Returns

Diameter

A new Diameter scaled by scalar.

operator *(Diameter, double)

Scales this diameter by a dimensionless factor.

public static Diameter operator *(Diameter diameter, double scalar)

Parameters

diameter Diameter

The diameter to scale.

scalar double

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

Returns

Diameter

A new Diameter scaled by scalar.

latest ▼