Skip to content

Commit 661a6f3

Browse files
authored
Merge pull request #1 from zigurous/release/1.2.0
Release/1.2.0
2 parents 2cf6d1c + 57d11c8 commit 661a6f3

24 files changed

+762
-169
lines changed
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
name: Generate Docs
2+
3+
on:
4+
push:
5+
branches:
6+
- main
7+
workflow_dispatch:
8+
9+
concurrency:
10+
group: ${{ github.workflow }}-${{ github.ref }}
11+
cancel-in-progress: true
12+
13+
jobs:
14+
generate:
15+
name: Docs
16+
uses: zigurous/docs/.github/workflows/unity-package.yml@main
17+
with:
18+
package_title: "Math Utils"
19+
package_base_path: com.zigurous.math
20+
package_workflow: generate-docs.yml
21+
package_artifact: docs
22+
secrets:
23+
token: ${{ secrets.DOCS_TOKEN }}

.github/workflows/generate_docs.yml

Lines changed: 0 additions & 99 deletions
This file was deleted.

CHANGELOG.md

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,35 @@ All notable changes to this project will be documented in this file.
55
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
66
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
77

8+
## [1.2.0] - 2023/06/20
9+
10+
### Added
11+
12+
- Constructors to specify the amount of digits on `FloatEqualityComparer` and `DoubleEqualityComparer`
13+
- Overloads for `short` and `long` number abbreviations
14+
- New `ComparisonSign` enum
15+
- New `Bounds` extensions
16+
- `Lerp`
17+
- `LerpUnclamped`
18+
- `InverseLerp`
19+
- `CalculateScale`
20+
- New `Rect` extensions
21+
- `Contains`
22+
- `Encapsulate`
23+
- `Lerp`
24+
- `LerpUnclamped`
25+
- `InverseLerp`
26+
- New `Transform` extensions
27+
- `AveragePositionOfChildren`
28+
- `CenterPositionOfChildren`
29+
- `Reset`
30+
- `ResetLocal`
31+
- `SetPosition`
32+
- `SetLocalPosition`
33+
- `SetEulerAngles`
34+
- `SetLocalEulerAngles`
35+
- `SetLocalScale`
36+
837
## [1.1.1] - 2022/05/19
938

1039
### Fixed

Documentation~/articles/extensions.md

Lines changed: 33 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -6,20 +6,36 @@ slug: "/manual/extensions"
66

77
A large majority of the functionality provided by the **Math Utils** package comes from extension methods. All of the extension methods found throughout the project are focused around numbers, whether it be arithmetic operations, bitwise operations, math algorithms, and other utilities of varying complexity. Extensions are available for the following types:
88

9-
- [Array](/api/Zigurous.Math/ArrayExtensions)
10-
- [Bounds](/api/Zigurous.Math/BoundsExtensions)
11-
- [Collider](/api/Zigurous.Math/ColliderExtensions)
12-
- [Double](/api/Zigurous.Math/DoubleExtensions)
13-
- [Float](/api/Zigurous.Math/FloatExtensions)
14-
- [IComparable](/api/Zigurous.Math/ComparableExtensions)
15-
- [Int](/api/Zigurous.Math/IntExtensions)
16-
- [List](/api/Zigurous.Math/ListExtensions)
17-
- [Long](/api/Zigurous.Math/LongExtensions)
18-
- [Quaternion](/api/Zigurous.Math/QuaternionExtensions)
19-
- [Short](/api/Zigurous.Math/ShortExtensions)
20-
- [UInt](/api/Zigurous.Math/UIntExtensions)
21-
- [Vector2](/api/Zigurous.Math/Vector2Extensions)
22-
- [Vector2Int](/api/Zigurous.Math/Vector2IntExtensions)
23-
- [Vector3](/api/Zigurous.Math/Vector3Extensions)
24-
- [Vector3Int](/api/Zigurous.Math/Vector3IntExtensions)
25-
- [Vector4](/api/Zigurous.Math/Vector4Extensions)
9+
#### [Array](/api/Zigurous.Math/ArrayExtensions)
10+
11+
#### [Bounds](/api/Zigurous.Math/BoundsExtensions)
12+
13+
#### [Collider](/api/Zigurous.Math/ColliderExtensions)
14+
15+
#### [Double](/api/Zigurous.Math/DoubleExtensions)
16+
17+
#### [Float](/api/Zigurous.Math/FloatExtensions)
18+
19+
#### [IComparable](/api/Zigurous.Math/ComparableExtensions)
20+
21+
#### [Int](/api/Zigurous.Math/IntExtensions)
22+
23+
#### [List](/api/Zigurous.Math/ListExtensions)
24+
25+
#### [Long](/api/Zigurous.Math/LongExtensions)
26+
27+
#### [Quaternion](/api/Zigurous.Math/QuaternionExtensions)
28+
29+
#### [Short](/api/Zigurous.Math/ShortExtensions)
30+
31+
#### [UInt](/api/Zigurous.Math/UIntExtensions)
32+
33+
#### [Vector2](/api/Zigurous.Math/Vector2Extensions)
34+
35+
#### [Vector2Int](/api/Zigurous.Math/Vector2IntExtensions)
36+
37+
#### [Vector3](/api/Zigurous.Math/Vector3Extensions)
38+
39+
#### [Vector3Int](/api/Zigurous.Math/Vector3IntExtensions)
40+
41+
#### [Vector4](/api/Zigurous.Math/Vector4Extensions)

Documentation~/articles/index.md

Lines changed: 16 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -8,18 +8,24 @@ The **Math Utils** package provides extensions and utilities for working with nu
88

99
<hr/>
1010

11-
## 📌 Overview
11+
## Overview
1212

13-
- [Scripting API](/api/Zigurous.Math)
14-
- [Installation](/manual/installation)
15-
- [Changelog](/changelog)
16-
- [License](/license)
13+
#### ⚙️ [Installation](/installation)
14+
15+
#### 🧰 [Scripting API](/api/Zigurous.Math)
16+
17+
#### 📋 [Changelog](/changelog)
18+
19+
#### ⚖️ [License](/license)
1720

1821
<hr/>
1922

20-
## 📖 Reference
23+
## Reference
24+
25+
#### 🔢 [Input Processors](/manual/processors)
26+
27+
#### 🎲 [Random Values](/manual/random)
28+
29+
#### 💯 [Number Abbreviations](/manual/abbreviations)
2130

22-
- [Input Processors](/manual/processors)
23-
- [Random Chance](/manual/chance)
24-
- [Number Abbreviations](/manual/abbreviations)
25-
- [Extension Methods](/manual/extensions)
31+
#### 🔌 [Extension Methods](/manual/extensions)

Documentation~/articles/chance.md renamed to Documentation~/articles/random.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
---
2-
slug: "/manual/chance"
2+
slug: "/manual/random"
33
---
44

5-
# Random Chance
5+
# Random
66

7-
The **Math Utils** package contains several functions for generating random chance values, including rolling dice, picking random playing cards, and other utility functions.
7+
The **Math Utils** package contains several functions for generating random values, including rolling dice, picking random playing cards, and other utility functions.
88

99
<hr/>
1010

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ The **Math Utils** package provides extensions and utilities for working with nu
77
## Reference
88

99
- [Input Processors](https://docs.zigurous.com/com.zigurous.math/manual/processors)
10-
- [Random Chance](https://docs.zigurous.com/com.zigurous.math/manual/chance)
10+
- [Random Values](https://docs.zigurous.com/com.zigurous.math/manual/random)
1111
- [Number Abbreviations](https://docs.zigurous.com/com.zigurous.math/manual/abbreviations)
1212
- [Extension Methods](https://docs.zigurous.com/com.zigurous.math/manual/extensions)
1313

Runtime/ComparisonSign.cs

Lines changed: 69 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,69 @@
1+
namespace Zigurous.Math
2+
{
3+
/// <summary>
4+
/// A mathematical sign that can be used to compare two values.
5+
/// </summary>
6+
public enum ComparisonSign
7+
{
8+
/// <summary>
9+
/// <c>a == b</c>
10+
/// </summary>
11+
Equal,
12+
13+
/// <summary>
14+
/// <c>a != b</c>
15+
/// </summary>
16+
NotEqual,
17+
18+
/// <summary>
19+
/// <c>a &gt; b</c>
20+
/// </summary>
21+
GreaterThan,
22+
23+
/// <summary>
24+
/// <c>a &gt;= b</c>
25+
/// </summary>
26+
GreaterThanOrEqual,
27+
28+
/// <summary>
29+
/// <c>a &lt; b</c>
30+
/// </summary>
31+
LessThan,
32+
33+
/// <summary>
34+
/// <c>a &lt;= b</c>
35+
/// </summary>
36+
LessThanOrEqual,
37+
}
38+
39+
/// <summary>
40+
/// Extension methods for <see cref="ComparisonSign"/>.
41+
/// </summary>
42+
public static class ComparisonSignExtensions
43+
{
44+
/// <summary>
45+
/// Compares two values using the comparison sign.
46+
/// </summary>
47+
/// <typeparam name="T">The type of values to compare.</typeparam>
48+
/// <param name="sign">The comparison sign.</param>
49+
/// <param name="a">The first value to compare.</param>
50+
/// <param name="b">The second value to compare.</param>
51+
/// <returns>The result of the comparison, either true or false.</returns>
52+
public static bool Compare<T>(this ComparisonSign sign, T a, T b)
53+
where T : System.IComparable<T>
54+
{
55+
switch (sign)
56+
{
57+
case ComparisonSign.Equal: return a.CompareTo(b) == 0;
58+
case ComparisonSign.NotEqual: return a.CompareTo(b) != 0;
59+
case ComparisonSign.GreaterThan: return a.CompareTo(b) > 0;
60+
case ComparisonSign.GreaterThanOrEqual: return a.CompareTo(b) >= 0;
61+
case ComparisonSign.LessThan: return a.CompareTo(b) < 0;
62+
case ComparisonSign.LessThanOrEqual: return a.CompareTo(b) <= 0;
63+
default: return false;
64+
}
65+
}
66+
67+
}
68+
69+
}

Runtime/ComparisonSign.cs.meta

Lines changed: 11 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Runtime/EqualityComparers/DoubleEqualityComparer.cs

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,25 @@ public sealed class DoubleEqualityComparer : IEqualityComparer<double>
1111
/// <summary>
1212
/// The number of decimal digits to compare when determining equality.
1313
/// </summary>
14-
public int digits = 3;
14+
public int digits;
15+
16+
/// <summary>
17+
/// Creates a new DoubleEqualityComparer with a default of 3 decimal
18+
/// digits to compare when determining equality.
19+
/// </summary>
20+
public DoubleEqualityComparer()
21+
{
22+
this.digits = 3;
23+
}
24+
25+
/// <summary>
26+
/// Creates a new DoubleEqualityComparer with the specified number of
27+
/// decimal digits to compare when determining equality.
28+
/// </summary>
29+
public DoubleEqualityComparer(int digits)
30+
{
31+
this.digits = digits;
32+
}
1533

1634
/// <summary>
1735
/// Checks the equality of two double values.

0 commit comments

Comments
 (0)