The Angle companion object contains utility methods, predefined constants, and typeclass instances for working with angles. Angles are represented using rational numbers and comply with the algebraic structure of a commutative group.
Attributes
Members list
Grouped members
Typeclass Instances
Provides an implicit conversion instance for transforming an Angle type into another Angle type.
Provides an implicit conversion instance for transforming an Angle type into another Angle type.
This given instance conforms to the Convertible typeclass, offering a no-op conversion logic where the input Angle instance is returned as is without any transformation.
Attributes
- See also
-
Convertible
Provides an implicit conversion instance for transforming an Angle type into another Angle type.
Provides an implicit conversion instance for transforming an Angle type into another Angle type.
This given instance conforms to the Convertible typeclass, offering a no-op conversion logic where the input Angle instance is returned as is without any transformation.
Attributes
- See also
-
Convertible
- Supertypes
- Self type
Type members
Classlikes
Provides an implicit implementation of a commutative group for the Angle type, supporting group operations such as identity, combination, and inversion.
Provides an implicit implementation of a commutative group for the Angle type, supporting group operations such as identity, combination, and inversion.
This allows Angle objects to adhere to the algebraic structure of a commutative group, where the combine operation is associative and commutative, an identity element exists, and each element has an additive inverse.
Attributes
- Supertypes
- Self type
Provides a Convertible instance to allow transformations from Real to Angle.
Provides a Convertible instance to allow transformations from Real to Angle.
This implementation leverages the convert function to create a new Angle instance using a Real value. The conversion relies on the asDouble method of the Real type to extract its numeric representation before constructing the Angle.
Attributes
- Supertypes
- Self type
Value members
Concrete methods
Converts a Value into an Angle instance based on its structure.
Converts a Value into an Angle instance based on its structure.
Value parameters
- value
-
the input
Valuewhich may represent different numeric types;Right(x)is treated as a whole number,Left(Right(x))is treated as a rational number,Left(Left(Some(x)))is treated as a real number, andLeft(Left(None))represents an invalid or undefined angle.
Attributes
- Returns
-
an
Angleinstance corresponding to the structure of the inputValue; returnsAngle.nanif the input represents an undefined value.
Converts the given integer value to an Angle instance.
Converts the given integer value to an Angle instance.
Value parameters
- x
-
the input integer value to be converted into an angle
Attributes
- Returns
-
an
Angleinstance corresponding to the given integer value
Converts the given long value to an Angle instance.
Converts the given long value to an Angle instance.
Value parameters
- x
-
the input long value to be converted into an angle
Attributes
- Returns
-
an
Angleinstance corresponding to the given long value
Converts the given rational value into an Angle.
Converts the given rational value into an Angle.
Value parameters
- rational
-
the
Rationalvalue representing the input to be converted into anAngle
Attributes
- Returns
-
an
Angleinstance corresponding to the givenRationalvalue
Converts the given rational number to an Angle instance by performing modulation and necessary computations. CONSIDER whether we really need this method. The Angle class already has a normalize method that performs modulation and other necessary computations.
Converts the given rational number to an Angle instance by performing modulation and necessary computations. CONSIDER whether we really need this method. The Angle class already has a normalize method that performs modulation and other necessary computations.
Value parameters
- r
-
the input
RationalNumberrepresenting the rational value to be converted into an angle
Attributes
- Returns
-
an
Angleinstance corresponding to the given rational value
Creates an Angle instance based on the input Structure value.
Creates an Angle instance based on the input Structure value.
Converts the input Structure into an Angle, handling various types of numerical structures. If the input is already an Angle, or if the type is unsupported, an exception is thrown.
Value parameters
- s
-
the input
Structureto be converted into anAngle; can represent a whole number, rational number, or real number. Passing an existingAngleor unsupported type results in an exception.
Attributes
- Returns
-
an
Angleinstance corresponding to the inputStructurevalue - Note
-
Throws com.phasmidsoftware.number.algebra.util.AlgebraException if the input is already an
Angleor is of an unsupported type
Converts the given numeric value to an Angle instance represented in degrees.
Converts the given numeric value to an Angle instance represented in degrees.
Value parameters
- x
-
the numeric input value to be converted into an angle in degrees
Attributes
- Returns
-
an
Angleinstance corresponding to the given numeric value in degrees
Converts a Value into an Angle represented as degrees. CONSIDER invoking degrees(Number) instead.
Converts a Value into an Angle represented as degrees. CONSIDER invoking degrees(Number) instead.
Value parameters
- x
-
the input
Valueto be converted to an angle in degrees; the type of value can represent various numeric structures such as whole numbers, rational numbers, or real numbers.
Attributes
- Returns
-
an
Angleinstance representing the givenValuein degrees.
Converts the given integer to an Angle instance represented in degrees.
Converts the given integer to an Angle instance represented in degrees.
Value parameters
- x
-
the integer value to be converted into an angle in degrees
Attributes
- Returns
-
an
Angleinstance corresponding to the given integer value in degrees
Concrete fields
Represents an angle equivalent to mathematical π radians.
Represents an angle equivalent to mathematical π radians.
The value pi is an instance of the Angle class initialized with the RationalNumber.one, which corresponds to the rational representation of π in the specific context of the Angle implementation.
Attributes
Represents an angle equivalent to π/2 radians.
Represents an angle equivalent to π/2 radians.
The value piBy2 is a constant instance of the Angle class initialized using a RationalNumber constructed with a value of 1/2. This corresponds to π/2 radians in mathematical terms.
Attributes
Represents the additive identity for angles.
Represents the additive identity for angles.
This value denotes an angle of zero radians, serving as the identity element in the group structure of angles. It is constructed using the Angle companion object initialized with the additive identity of RationalNumber.
Attributes
Alias for the pi value, representing an angle equivalent to mathematical π radians.
Alias for the pi value, representing an angle equivalent to mathematical π radians.
This value is a symbolic representation of π radians, reused from the Angle.pi value. It is denoted by the Greek mathematical symbol 𝛑 and can be used interchangeably with pi.
Attributes
Givens
Givens
Provides a Convertible instance to allow transformations from Real to Angle.
Provides a Convertible instance to allow transformations from Real to Angle.
This implementation leverages the convert function to create a new Angle instance using a Real value. The conversion relies on the asDouble method of the Real type to extract its numeric representation before constructing the Angle.
Attributes
Provides a DyadicOperator instance for the type Angle.
Provides a DyadicOperator instance for the type Angle.
This implementation defines a binary operation (op) that operates on two angles and applies a user-defined function f to the inputs. The resulting computation is encapsulated in a Try to handle potential failures.
Attributes
- Returns
-
A
DyadicOperator[Angle]instance that allows performing binary operations onAnglevalues using a functionf.
Provides an instance of equality comparison (Eq) for the Angle type.
Provides an instance of equality comparison (Eq) for the Angle type.
Compares two Angle instances for equivalence based on their internal equality logic. The method delegates to the eqv method of one Angle instance and processes the result. If the equivalence check returns None, the method defaults to false.
Attributes
- Returns
-
an
Eq[Angle]instance that defines equality behavior forAngle
Provides an instance of FuzzyEq[Angle] that defines fuzzy equality for angles.
Provides an instance of FuzzyEq[Angle] that defines fuzzy equality for angles.
Fuzzy equality is determined by checking if two angles are exactly equal (===) or approximately equal based on a given probability p.
Attributes
- Returns
-
an instance of
FuzzyEq[Angle]that implements fuzzy equality logic for comparingAnglevalues.
Implicits
Implicits
Provides an implicit Show instance for the Angle class, enabling conversion of an Angle instance to a string representation using its render method.
Provides an implicit Show instance for the Angle class, enabling conversion of an Angle instance to a string representation using its render method.
This allows the Angle class to integrate seamlessly with libraries or frameworks requiring a Show typeclass instance for displaying or logging purposes.