
Library facilitates mathematical operations and utilities, including angle representation in degrees or radians with conversion, normalization, and arithmetic capabilities, along with trigonometric functions.
A Kotlin multiplatform library for mathematical operations and utilities.
To use ltmath in your Kotlin Multiplatform project, add the following dependency to your build.gradle.kts file:
dependencies {
implementation("top.ltfan.math:math:<version>")
}Or if you are using Gradle Version Catalogs, add the following to your gradle/libs.versions.toml:
[versions]
ltmath = "<version>"
[libraries]
ltmath = { module = "top.ltfan.math:math", version.ref = "math" }Make sure your settings.gradle.kts includes the repository:
dependencyResolutionManagement {
repositories {
mavenCentral()
}
}Represents an angle in degrees or radians, providing conversion, normalization, and arithmetic operations.
Here's a quick example of how to use the Angle class:
// Basic usage of the Angle class
val a = 180.degrees
val b = Angle.fromRadians(PI)
val c = 1.piRadians// Angle operations
val sum = a + b // Adds two angles, result in the type of the first operand (Degrees)
val normalized = sum.normalized // Normalizes the angle to the range [0, 360) for degrees or [0, 2π) for radians
val radians = a.radians // Converts degrees to radians, resulting in a `Double`
val degrees = b.degrees // Converts radians to degrees, resulting in a `Double`
val value = c.radians // Gets the value in radians, which is a `Double`// Trigonometric functions. Shortcuts of `kotlin.math` functions for `Angle` type.
val sineValue = a.sin // Computes the sine of the angle, resulting in a `Double`
val angleFromAtan2 =
atan2(1.0, 1.0) // Computes the angle from the arctangent of two values, resulting in an `Angle.Radians`For more details, see the Kotlin Multiplatform documentation.
For Kotlin/Native support, see the Kotlin/Native documentation.
We welcome contributions! Please submit issues or pull requests for any bugs, features, or improvements.
This project is licensed under the MIT License. See the LICENSE file for details.
A Kotlin multiplatform library for mathematical operations and utilities.
To use ltmath in your Kotlin Multiplatform project, add the following dependency to your build.gradle.kts file:
dependencies {
implementation("top.ltfan.math:math:<version>")
}Or if you are using Gradle Version Catalogs, add the following to your gradle/libs.versions.toml:
[versions]
ltmath = "<version>"
[libraries]
ltmath = { module = "top.ltfan.math:math", version.ref = "math" }Make sure your settings.gradle.kts includes the repository:
dependencyResolutionManagement {
repositories {
mavenCentral()
}
}Represents an angle in degrees or radians, providing conversion, normalization, and arithmetic operations.
Here's a quick example of how to use the Angle class:
// Basic usage of the Angle class
val a = 180.degrees
val b = Angle.fromRadians(PI)
val c = 1.piRadians// Angle operations
val sum = a + b // Adds two angles, result in the type of the first operand (Degrees)
val normalized = sum.normalized // Normalizes the angle to the range [0, 360) for degrees or [0, 2π) for radians
val radians = a.radians // Converts degrees to radians, resulting in a `Double`
val degrees = b.degrees // Converts radians to degrees, resulting in a `Double`
val value = c.radians // Gets the value in radians, which is a `Double`// Trigonometric functions. Shortcuts of `kotlin.math` functions for `Angle` type.
val sineValue = a.sin // Computes the sine of the angle, resulting in a `Double`
val angleFromAtan2 =
atan2(1.0, 1.0) // Computes the angle from the arctangent of two values, resulting in an `Angle.Radians`For more details, see the Kotlin Multiplatform documentation.
For Kotlin/Native support, see the Kotlin/Native documentation.
We welcome contributions! Please submit issues or pull requests for any bugs, features, or improvements.
This project is licensed under the MIT License. See the LICENSE file for details.