mirror of
https://github.com/ahwootech/BRUTAL.git
synced 2026-11-25 20:48:24 +01:00
samples: add Hello/Demo samples for most BRUTAL packages (#19)
Add samples/, a collection of single-file .NET 10 apps run with `dotnet run <file>.cs`. Hello/ has one minimal sample per package that has a public API, many of them headless; Demo/ has fuller programs that combine packages into a more interesting application. samples/README.md indexes every sample and covers the layout, error handling and per-OS requirements.
This commit is contained in:
parent
4ac91e105e
commit
7a3b72d843
1 changed files with 4599 additions and 1 deletions
24
samples/Hello/HelloMaths.cs
Normal file
24
samples/Hello/HelloMaths.cs
Normal file
|
|
@ -0,0 +1,24 @@
|
|||
/*
|
||||
* HelloMaths
|
||||
*
|
||||
* Uses the Random extensions to generate numbers, points in shapes and random directions.
|
||||
*/
|
||||
|
||||
#:package Ahwoo.Brutal.Maths@2026.10.1
|
||||
#:package Ahwoo.Brutal.Numerics@2026.10.1
|
||||
|
||||
// RIAN: This library will be expanded in a future release, once the System.Numerics mirror is pulled out of Brutal.Numerics into its own flavor package
|
||||
// We don't actually like the System.Numerics functions all that much, we only have them as compatibility at this stage.
|
||||
|
||||
using Brutal.Maths;
|
||||
using Brutal.Numerics;
|
||||
|
||||
var random = new Random(1234); // Fixed seed so every run prints the same values.
|
||||
|
||||
Console.WriteLine($"Float in [5, 10): {random.NextSingle(5f, 10f)}");
|
||||
Console.WriteLine($"Point in 4x2 rect: {random.NextSinglePointInRectangle(4f, 2f)}");
|
||||
Console.WriteLine($"Point in unit circle: {random.NextSinglePointInCircle(1f)}");
|
||||
Console.WriteLine($"Point in unit sphere: {random.NextSinglePointInSphere(1f)}");
|
||||
|
||||
var direction = random.NextSingleUnit3();
|
||||
Console.WriteLine($"Random direction: {direction} (length {direction.Length()})");
|
||||
Loading…
Reference in a new issue