Skip to content

Math tools: a solver of triangles - #42

Open
simonebortolin wants to merge 1 commit into
ccr-f0e25fb4-eczbl3-unitsfrom
ccr-f0e25fb4-eczbl3-triangles
Open

simonebortolin wants to merge 1 commit into
ccr-f0e25fb4-eczbl3-unitsfrom
ccr-f0e25fb4-eczbl3-triangles

Conversation

@simonebortolin

Copy link
Copy Markdown
Owner

Stacked on #41. This is the last page of the math tools (#39–#41): it adds a solver of triangles.

What it does

You give three of a, b, c, α, β and γ, at least one of them a side. The page finds:

  • the other sides and angles;
  • the area, the perimeter, and the radii of the circumscribed and inscribed circles;
  • the laws it used, written in UnicodeMath and drawn by a MathView;
  • a drawing of the triangle to scale.

It handles every case:

Case Values given
SSS three sides; the triangle inequality is checked
SAS two sides and the angle between them
SSA two sides and an angle not between them; it gives two triangles, one (including the right-angle limit), or none
ASA, AAS two angles and a side

When there is no triangle, the page says why: three angles alone, the wrong number of values, angles of 180° or more, a side too long, or text that is not a number. The example buttons fill in each case.

Code

  • Triangles.cs is the model, with no user interface.
  • TrianglePage.cs is the page. It is wired in as the "Triangles" tab.

Tests

  • TrianglesTests:
    • every case;
    • the ambiguous case with 2, 1 (one of them the right-angle limit) or 0 triangles;
    • the errors;
    • for three triangles, every choice of three values (at least one a side) gives the triangle back, across all five cases;
    • the laws and values written as UnicodeMath parse with no merror and round-trip.
  • The window test TrianglesSolve covers the example, the ambiguous case and a value that is not a number.
  • Local results: 248/248 on net10.0, 123/123 on net8.0.

Generated by Claude Code

Three of the sides and angles, at least one of them a side, give the others (SSS, SAS,
SSA with its two triangles, one or none, ASA, AAS), the area, the perimeter and the
radii of the circles, with the laws used written in UnicodeMath and the triangle drawn
to scale.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01SyVio8afJsGwHW9i5v5HDs
@github-actions

Copy link
Copy Markdown

Pre-release 1.1.0-pr.42.112 is ready: https://github.com/simonebortolin/SharpEquations/releases/tag/pr-42-112-1

NuGet package of 96d6d7f. Updated on every push, deleted when this PR is closed.

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants