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
28
samples/Hello/HelloNumerics.cs
Normal file
28
samples/Hello/HelloNumerics.cs
Normal file
|
|
@ -0,0 +1,28 @@
|
|||
/*
|
||||
* HelloNumerics
|
||||
*
|
||||
* Vector and matrix basics: float3 arithmetic, dot/cross products and transforming by a float4x4.
|
||||
*/
|
||||
|
||||
#:package Ahwoo.Brutal.Numerics@2026.10.1
|
||||
|
||||
// RIAN: This package current contains a mirror of the System.Numerics math library for compatibility in porting, but will be reduced
|
||||
// to only the types in a future release. Math libraries are opinionated and should be picked by the developer, not the framework.
|
||||
|
||||
using Brutal.Numerics;
|
||||
|
||||
var a = new float3(1, 0, 0);
|
||||
var b = new float3(0, 1, 0);
|
||||
|
||||
Console.WriteLine($"a + b = {a + b}");
|
||||
Console.WriteLine($"a * 3 = {a * 3}");
|
||||
Console.WriteLine($"dot(a, b) = {float3.Dot(a, b)}");
|
||||
Console.WriteLine($"cross(a, b) = {float3.Cross(a, b)}");
|
||||
Console.WriteLine($"|a + b| = {(a + b).Length()}");
|
||||
|
||||
// Rotate 90 degrees around Z, then move 10 units along X.
|
||||
var transform = float4x4.CreateRotationZ(MathF.PI / 2) * float4x4.CreateTranslation(10, 0, 0);
|
||||
Console.WriteLine($"transformed = {float3.Transform(a, transform)}");
|
||||
|
||||
var size = new int2(640, 480);
|
||||
Console.WriteLine($"int2 size = {size}");
|
||||
Loading…
Reference in a new issue