Skip to content

A Modern C++ project to calculate and visualize triangles using Heron's Formula, offering an intuitive GUI powered by ImGui and OpenGL.

License

Notifications You must be signed in to change notification settings

Moderrek/HeronTriangle

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

34 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Heron Triangle

Linux Windows OpenGL MIT License GitHub Downloads (all assets, all releases)

Heron's Formula is a method for calculating the area of a triangle when the lengths of all three sides are known. This formula is attributed to Heron of Alexandria.

Download Heron Triangle Visualizer (Linux, Windows) HERE

image


Formula Overview

Given the three side lengths of a triangle:

  • a = first side
  • b = second side
  • c = third side

Step 1: Calculate the Semi-Perimeter s

The semi-perimeter is half the perimeter of the triangle and is calculated as:

$$s = \frac{a + b + c}{2}$$

Step 2: Calculate the Area A

The area of the triangle is determined using the following formula:

$$A = \sqrt{s(s - a)(s - b)(s - c)}$$

Example

Input:

Let the sides of the triangle be:

  • a = 5
  • b = 6
  • c = 7

Calculation:

  1. Compute the semi-perimeter:

    $$s = \frac{5 + 6 + 7}{2} = 9$$
  2. Compute the area:

    $$A = \sqrt{9(9 - 5)(9 - 6)(9 - 7)}$$ $$A = \sqrt{9 \cdot 4 \cdot 3 \cdot 2} = \sqrt{216} \approx 14.7$$

Output:

The area of the triangle is approximately 14.7 square units.


Applications

  • Geometry and trigonometry problems
  • Engineering and architecture
  • Computational graphics and simulations
  • Heron's Formula works for any triangle, as long as the sum of any two sides is greater than the third side (triangle inequality).

To learn more about Heron's formula, click here.

Table of Contents

Features

  • Cross-platform support: Linux & Windows
  • Real-time rendering with OpenGL 3.3+
  • Vertex dragging
  • Lightweight and optimized for performance
  • MIT License: Open for contributions

How to Compile

Requirements

  • CMake (version 3.16 or higher)
  • C++ Compiler with support for C++20
  • Git for cloning the repository
  • OpenGL 3.3+

Steps to Compile

  1. Clone the repository with submodules:

    git clone --recursive https://github.com/Moderrek/HeronTriangle.git
    cd HeronTriangle
  2. Configure the project using CMake:

    • For Windows
      ./scripts/windows_setup_project.bat
    • For Linux
      ./scripts/linux_setup_project.sh
  3. Build the project:

    • For Windows
      ./scripts/windows_build_debug.bat
    • For Linux
      ./scripts/linux_build_debug.sh
  4. Run the game:

    • On Windows: Open executable in the build/bin or build/bin directory.
    • On Linux: Run executable
      ./build/bin/HeronTriangle

Notes

  • Ensure all dependencies are correctly installed before starting the build process.
  • If you encounterr errors, consult the project's issue tracker.

License

This project is licensed under the MIT License. See the LICENSE file for details.

Contributing

Contributions are welcome! Please fork the repository and submit a pull request. For major changes, please open an issue first to discuss what you would like to change.

Authors

  • Tymon Woźniak - Creator and Maintainer