https://github.com/forkercat/mathlib
A simple math library written in Swift 🧮
https://github.com/forkercat/mathlib
math simple swift
Last synced: 5 months ago
JSON representation
A simple math library written in Swift 🧮
- Host: GitHub
- URL: https://github.com/forkercat/mathlib
- Owner: forkercat
- License: mit
- Created: 2021-12-22T06:02:06.000Z (about 4 years ago)
- Default Branch: main
- Last Pushed: 2022-01-15T07:09:15.000Z (about 4 years ago)
- Last Synced: 2025-10-13T15:48:35.472Z (5 months ago)
- Topics: math, simple, swift
- Language: Swift
- Homepage:
- Size: 19.5 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# MathLib
[](https://github.com/forkercat/MathLib/actions/workflows/ci-macos.yml)
[](https://github.com/forkercat/MathLib/actions/workflows/ci-linux.yml)
[](https://github.com/forkercat/MathLib/actions/workflows/ci-windows.yml)
[](LICENSE)
[](https://swiftpackageindex.com/forkercat/MathLib)
[](https://swiftpackageindex.com/forkercat/MathLib)
A simple math library written in Swift. Still in development...
## 🔧 Install
You package file would be like:
```swift
let package = Package(
name: "YourPackageName",
dependencies: [
.package(url: "https://github.com/forkercat/MathLib.git", .branch("main")),
],
targets: [
// For Swift 5.5, use .executableTarget
.target(
name: "YourPackageName",
dependencies: [
.product(name: "MathLib", package: "MathLib")
]),
]
)
```
## 🥲 Usage
```swift
import MathLib
let v1 = Float3(x: 1, y: 2, z: 3)
let v2 = Float3(x: 300, y: 20, z: 1)
let v3 = Float4(xyz: v2, w: 4)
let v4 = Float4(1, 123.123, 25, 1344)
print(v1.str)
print(v2.str)
print(v3.str3f)
print(v4.str3f)
// Output
Float3 [ 1.0, 2.0, 3.0 ]
Float3 [ 300.0, 20.0, 1.0 ]
Float4 [ 300.000, 20.000, 1.000, 4.000 ]
Float4 [ 1.000, 123.123, 25.000, 1344.000 ]
Float4x4 [[ 1.0, 0.0, 0.0, 0.0 ],
[ 0.0, 1.0, 0.0, 0.0 ],
[ 0.0, 0.0, 1.0, 0.0 ],
[ 0.0, 0.0, 0.0, 1.0 ]]
```