Skip to content

PanicMike-9/Cpp-Math

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

193 Commits
 
 
 
 

Repository files navigation

math equations in c++

quadratic equation

  • in mathematics, a quadratic equation is an equation that can be rearranged in standardform as:

$$x = \frac{-b \pm \sqrt{b^2 - 4ac}}{2a}$$

  • where the variable $$x$$ represents an unknown number, and $$a, b, c$$ represents know numbers, where $$a!=0$$.

  • for more info on quadratic equation visit: definition of quadratic equation

compile and run

g++ quadratic_equation.cpp -o quadratic && ./quadratic 

pythagorean theorem

  • in mathematics, the pythagorean theorem or pythagoras's theorem is a fundamental relation in euclidean geometry between the three sides of a right triangle. it states that the area of the square whose side is the hypotenuse is equal to the sum of the areas of the squares on the other two sides. the theorem can be written as an equation:

$$a^{2}+b^{2}=c^{2}$$

compile and run

g++ pythagorean_theorem.cpp -o pythagorean && ./pythagorean 

circle solver

  • π is commonly defined as the ratio of a circle's circumference $$c$$ to its diameter $$d$$:

  • the program provides the diameter, circumference, and area using:

$$d = 2r$$ $$c = 2\pi r$$ $$a = \pi r{2}$$

compile and run

g++ circle_solver.cpp -o circlesolver && ./circlesolver 

Vector2

  • A lightweight, header-only C++ class for handling 2D vectors. This class provides the basic functions to understand how the Vector2 class works with basic functions like distance and distance squared to dot product and similar

Quick Test

//main.cpp
#include <iostream>
#include "vector2.hpp"

int main()
{
    Vector2 test_vec(3.0f, 4.0f);
    std::cout << "Test length\n"
              << "x: " << test_vec.x << '\n'
              << "y: " << test_vec.y << '\n'
              << "Length: " << test_vec.length() << '\n'
              << "Length squared: " << test_vec.length_squared() << '\n';
    
    return 0;
} 

compile and run

g++ -std=c++20 main.cpp -o run && ./run

About

An educational Math library in C++, made to learn real math equations, and how to use them.

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages