Code Monkey home page Code Monkey logo

calgeo's Introduction

calgeo

Hello there! A repository you're currently looking at was created for fun, but then we realized how useful it can be in the future for the developer's community! Once in a while we make some minor changes to this library :). With your help we can make it great!

Idea belongs to CalculusEnjoyer and stupidcucumber

Features

Our library contain functionality to deal with:

  1. Complex numbers
  2. Matrices
  3. Vectors
  4. Primitive geometry objects, such as: points, lines, planes of any dimension
  5. Limited functionality for curves in 2D-space

Complex numbers

Our library adds a new ComplexNumber class, which contains all the necessary methods for working with complex numbers.

getRealPart() ⟹ long double

returns the real part of a complex number.

getImaginaryPart() ⟹ long double

returns the imaginary part of a complex number.

setRealPart(long double a) ⟹ void

sets the real part of a complex number.

setImaginaryPart(long double b) ⟹ void

sets the imaginary part of a complex number.

length() ⟹ long double

returns the magnitude of a complex number.

showNumber() ⟹ void

sends a complex number to the standard output.

root(long long int r) ⟹ vector<ComplexNumber>

returns all roots of a given complex number. not implemented

operators

a bunch of methods to make work with complex numbers easier.

The library also provides some useful global functions:

multiplyComplexNumber(ComplexNumber z, long double coefficient) ⟹ ComplexNumber

multiplies a complex number by a given real coefficient.

complexConjugate(ComplexNumber z) ⟹ ComplexNumber

returns the conjugate of a complex number.

multiplicativeInverse(ComplexNumber z) ⟹ ComplexNumber

returns the multiplicative inverse version of a complex number.

Matrices

Provides two different classes for work with complex Matrix cMatrix and real Matrix Matrix. They contain the following methods:

showMatrix() ⟹ void

sends the matrix to the standard output.

clearMatrix() ⟹ void

clears the matrix.

getRows() / getColumns() ⟹ long long int

returns the number of rows and columns accordingly.

getMatrix() ⟹ vector<vector<long double>>&

returns the matrix by reference.

rank(), cRank() ⟹ unsigned int

returns the rank of a real / complex matrix.

rankofExtended(vector v) / cRankOfExtended(vector v) ⟹ unsigned int

returns the rank of an extended matrix.

randValues(long double min, long double max) ⟹ void

assigns random values to a matrix between minimum and maximum values.

setMatrix(vector<vector<long double/int/float/double/long long int>> v) ⟹ void

assigns specific values to a matrix.

changeColumns(long long int prevColumn, long long int nextColumn) ⟹ void

swaps columns.

changeRows(long long int previousRow, long long int nextRow) ⟹ void

swaps rows.

addColumns(long double coefficient, long long int targetRow, long long int additionRow) ⟹ void

addRows(long double coefficient, long long int targetColumn, long long int additionColumn) ⟹ void

tMatrix() ⟹ void

transposes the matrix of an arbitrary size.

triangle(bool side = false) ⟹ void

makes upper (if f = false) or lower triangular matrix.

determinant() ⟹ long double

returns the determinant of a matrix, if it is square matrix.

matrixRProduct(vector<vector> m) / matrixLProduct(vector<vector> m) ⟹ vector<vector<long double>>

returns the matrix (represented as vector<vector<long double>> rather than object of type Matrix/cMatrix) multiplied from right or left by a given matrix.

inverseMatrix() ⟹ vector<vector<ld>>

returns the inverse matrix.

solveEquation(vector c) (solveEquation() in code) ⟹ vector<long double>

returns the solution to the corresponding linear equation system.

findGeneralSolution(vector c) ⟹ vector<vector<long double>>

returns a general solution to a corresponding linear equation system.

operators

a bunch of operators (-, +, *, /, ^) to make work with matrices easier.

Also there are some useful functions:

matrixProduct(vector<vector> m1, vector<vector> m2, bool side = false) ⟹ vector<vector<long double>>

returns the product of matrices.

showMatrix(vector<vector<<long double/int/float/double/long long int>>> m) ⟹ void

sends the matrix to the standard output.

Vectors

The following functions are included:

vectorLength(const vector& v) ⟹ long double

returns the length of the given vector.

vectorProduct(vector vector1, vector vector2) ⟹ vector<long double>

returns the vector as a result of a multiplication of two vectors.

scalarProduct(vector v1, vector v2) ⟹ long double

returns a scalar product of a vectors.

angle(const vector& vector1, const vector& vector2) ⟹ long double

returns the angle between vectors.

addVectors(vector vector1, vector vector2) ⟹ vector<long double>

adds two vectors and returns corresponding vector.

subtractionVectors(vector v1, vector v2) ⟹ vector<long double>

subtracts two vectors and returns corresponding vector.

vectorNormalization(vector v) ⟹ vector<long double>

returns the normalized vector.

Primitive objects

Primitive objects include points, lines and planes. Functionality for working with points:

isOnLine(vector<vector> p) ⟹ bool

returns true if all given points lie on one line.

isOnPlane(vector<vector> p) ⟹ bool

returns true if all given points lie on one plane.

Class Line provides following methods:

getDirectV() ⟹ vector<long double>

returns the direct vector of a line.

getPointV() ⟹ vector<long double>

returns the point of a line. not implemented (?)

isPointBelong(vector v) ⟹ bool

returns true if point belongs to a line.

isPerpendicular(Line line) ⟹ bool

returns true if a given line is perpendicular.

isParallel(Line line) ⟹ bool

returns true if a given line is parallel.

isOnOnePlane(Line line) ⟹ bool

returns true if lines are on one plane.

isCross(Line line) ⟹ bool

returns true if lines cross.

Class 'Plane' provides following methods:

getDirectPlane() ⟹ vector<long double>

returns the direct vector of a plane.

getPointPoint() ⟹ vector<long double>

returns the point of a plane.

isParallel(Line line) ⟹ bool

returns true if a given line is parallel to the plane.

isParallel(Plane plane) ⟹ bool

returns true if a given plane is parallel to the plane.

isPerpendicular(Line line) ⟹ bool

returns true if a given line is perpendicular to the plane.

isPointBelong(vector p) ⟹ bool

checks whether the point belong to a plane.

Primitive objects also have functions:

pointLineCross(Line line1, Line line2) ⟹ vector<long double>

returns the point of cross.

Curves

Currently we are working on it and trying to learn more about shapes in multidimensional space. Our library works only with ellipse and provides class "Ellipsoid" which contains such methods:

isEquationCanonic() ⟹ bool

checks whether the equation is canonic.

isPointBelongs(vector p) ⟹ bool

checks whether the point belongs to the ellipse.

findEccentricity() ⟹ long double

returns the eccentricity of the ellipse.

findDirectrix() ⟹ vector<pair<string, long double>>

returns the directrix of the ellipse.

Future plans

  1. Make faster algorithms.
  2. Include functions for working with multidimensional figures.
  3. Implement UI for drawing graphs and working with 3D and 2D figures.

What are our goals?

Our main goal is to make a reliable library which can help modeling/solving complex mathematical problems. Every mathematician needs a simple but powerful tool to work with numbers. By building such a tool we can help the scientific community in further maths exploration.

calgeo's People

Contributors

stupidcucumber avatar kentoso avatar calculusenjoyer avatar

Stargazers

 avatar

Watchers

 avatar

Forkers

calculusenjoyer

calgeo's Issues

Gitignore

We should create gitignore for cmake, because every time someone builds the project, it changes it's configurations and commits become messy

Typos in method declarations.

Describe the bug
Typos in method declarations.

  • Matrix::solveEquasion(vector) => Matrix::solveEquation(vector)
  • cMatrix::solveEquasion(vector) => cMatrix::solveEquation(vector);
  • class Elipsoid => class Ellipsoid
  • Elipsoid::findExcetricity() => Elipsoid::findEccentricity()
  • Elipsoid::isEquasionCanonic() => Elipsoid::isEquationCanonic()

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.