Skip to content

Commit

Permalink
Merge pull request #2 from bretleasure/main
Browse files Browse the repository at this point in the history
Updated Readme and added IntelliSense to functions
  • Loading branch information
Growler authored Jul 10, 2024
2 parents d91930b + 09e7916 commit e588079
Show file tree
Hide file tree
Showing 4 changed files with 549 additions and 137 deletions.
85 changes: 60 additions & 25 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,49 +1,84 @@
# SohCahToa

[![NuGet version (iAutomateDesign.AutodeskAppStore)](https://buildstats.info/nuget/SohCahToa)](https://www.nuget.org/packages/SohCahToa)
[![NuGet version (SohCahToa)](https://buildstats.info/nuget/SohCahToa)](https://www.nuget.org/packages/SohCahToa)

Simplifies performing Trig calculations by providing descriptive function names. No more having to remember whether Sin, Cos, or Tan need to be used to get the value you are needing.
`SohCahToa` is a powerful C# library designed to simplify trigonometric calculations, making it an essential tool for engineering, educational software, and any application dealing with geometric data. With its focus on ease of use and precision, `SohCahToa` helps developers perform complex trigonometric calculations with minimal effort.

## How to Use
## Features

* Add a using statement for `SohCahToa`
* Call static functions within the `Trig` class
- **High Precision Calculations**: Utilize double precision (`Trig`) or single precision (`TrigF`) for trigonometric operations.
- **Static Methods**: Direct access to trigonometric calculations without needing to instantiate classes.
- **Comprehensive Coverage**: Methods for calculating side lengths, primary and complimentary angles in right triangles.
- **Ease of Use**: Intuitive method naming convention for quick understanding and implementation.

## Installation

To integrate `SohCahToa` into your project, use the following NuGet command:

```bash
Install-Package SohCahToa
```

## Quick Start

Calculate the length of the opposite side of a right triangle given the adjacent side and the angle:

```csharp
var run = 10;
var rise = 15;
var hypotenuse = Trig.Hypotenuse_RiseRun(rise, run);
double run = 5;
double primaryAngle = 30;
double rise = Trig.Rise_RunPrimaryAngle(run, primaryAngle);
Console.WriteLine($"Rise: {rise}");
```

## API Overview

### `Trig` Class

- **Double Precision**: For applications requiring high accuracy.
- Methods include `Rise_RunPrimaryAngle`, `PrimaryAngle_RiseRun`, `ComplimentaryAngle_PrimaryAngle`, etc.

### `TrigF` Class

### Triangle Side/Angle Nomenclature:
- **Single Precision**: Optimized for performance and memory efficiency.
- Methods mirror those of `Trig` but use `float` types, e.g., `Rise_RunPrimaryAngle(float run, float primaryAngle)`.

![Triangle Labels](https://i.imgur.com/EUrjY2m.png)
### Method Naming Convention

* Hypotenuse = c
* Run = b
* Rise = a
* Primary Angle = AA
* Complimentary Angle = BB
- **Descriptive Prefix**: The primary output or focus of the method (e.g., `Rise`, `Run`, `PrimaryAngle`).
- **Underscore Separator**: Enhances readability and method parsing.
- **Input Parameters**: Inputs or known quantities used for calculation.

**Angles are in degrees**
## Examples

### Function names follow the following structure:
### Calculate Side Lengths

**[Value to be Calculated]_[Input 1][Input 2]**
```csharp
double run = 5;
double primaryAngle = 30;
double rise = Trig.Rise_RunPrimaryAngle(run, primaryAngle);
```

For Example:
### Calculate Angles

The function to use for calculating the hypotenuse of a triangle using the Rise and Run values would be `Hypotenuse_RiseRun()`
```csharp
double rise = 3;
double run = 4;
double primaryAngle = Trig.PrimaryAngle_RiseRun(rise, run);
```

### Short Method Naming:
### Comprehensive Calculations

```csharp
double run = 5;
double primaryAngle = 30;
double rise = Trig.Rise_RunPrimaryAngle(run, primaryAngle);
double complimentaryAngle = Trig.ComplimentaryAngle_PrimaryAngle(primaryAngle);
```

Alternatively, there are functions that reference the values shown in the image above that could be used instead of using the descriptive names.
## Contributing

* Sides are named with lower case letters (a,b,c)
Contributions are welcome! Please submit pull requests or open issues to discuss proposed changes or report bugs.

* Angles are named with upper case double letters (AA, BB)
## License

The same calculated from above, calculating the hypotenuse using the Rise and Run values would be `c_ab()`
`SohCahToa` is released under the MIT License. See the LICENSE file in the repository for more details.
2 changes: 1 addition & 1 deletion src/SohCahToa/SohCahToa.csproj
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>netstandard2.0</TargetFramework>
<TargetFramework>netstandard2.1</TargetFramework>
<Authors>Growler</Authors>
<Copyright>2023</Copyright>
<PackageRequireLicenseAcceptance>true</PackageRequireLicenseAcceptance>
Expand Down
Loading

0 comments on commit e588079

Please sign in to comment.