/* * MathPlanner 3.2.0 - Mathematical design tool. * Copyright(C) 2003 Jarmo Nikkanen * * This program is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License as published by the * Free Software Foundation. * * You should have received a copy of the GNU General Public License with this program. * */ #ifndef _MATHPLANNER_MATH_H #define _MATHPLANNER_MATH_H #include "Unit.h" #include #define MN_NULL 0 #define MN_REAL 1 #define MN_COMPLEX 2 #define MN_VECTOR 4 #define MN_RATIONAL 8 // Not supported #define MN_MATRIX 16 // Not supported #define NEPER M_E #define PI M_PI typedef double mpl_real; struct mpl_complex { mpl_real r; mpl_real i; }; struct mpl_vector { mpl_real i; mpl_real j; mpl_real k; }; struct mpl_rational { mpl_real a; mpl_real b; }; struct mpl_rational_info { char pii_location; //0=No Pii, 1=Up 2=Lo bool root; }; class math_node { public: union { struct { mpl_real R,I,J,K; } m; mpl_real real; mpl_vector vector; mpl_complex complex; mpl_rational rational; } mpl; int type; char pwrs[COUNT]; // Used in unit calculation math_node(); math_node(mpl_real); math_node(mpl_rational); math_node(mpl_complex); math_node(mpl_vector); ~math_node(); void Clear(); bool isNull(); void SetReal(mpl_real); void SetComplex(mpl_complex); void SetRational(mpl_rational); mpl_real Real(); mpl_rational Rational(); mpl_complex Complex(); mpl_vector Vector(); }; // TEXT FUNCTIONS QString mpl_real2text_frac(mpl_real real,int digits,bool mode); QString mpl_real2text_exp(mpl_real real,bool mode); QString mpl_real2text_dec(mpl_real real,int digits); // NODE FUNCTIONS math_node mpl_add(math_node a,math_node b); math_node mpl_sub(math_node a,math_node b); math_node mpl_mul(math_node a,math_node b); math_node mpl_div(math_node a,math_node b); math_node mpl_neg(math_node a); // VECTOR MATH mpl_vector mpl_cross(mpl_vector a,mpl_vector b); mpl_vector mpl_neg(mpl_vector a); mpl_real mpl_length(mpl_vector a); mpl_vector mpl_unitvector(mpl_vector a); // REAL MATH mpl_real mpl_factorial(mpl_real val); mpl_real mpl_rad(mpl_real); mpl_real mpl_deg(mpl_real); mpl_real mpl_coth(mpl_real x); mpl_real mpl_asinh(mpl_real x); mpl_real mpl_acosh(mpl_real x); mpl_real mpl_atanh(mpl_real x); mpl_real mpl_acoth(mpl_real x); bool mpl_modul(mpl_real a,mpl_real b); mpl_real mpl_sin(mpl_real x); mpl_real mpl_cos(mpl_real x); mpl_real mpl_tan(mpl_real x); // COMPLEX MATH mpl_complex mpl_real2complex(mpl_real r); mpl_complex mpl_opz(mpl_complex); // one per z mpl_complex mpl_cnxroot(mpl_complex z,mpl_real n,mpl_real x); mpl_complex mpl_cnroot(mpl_complex z,mpl_complex n); mpl_complex mpl_cnpower(mpl_complex z,mpl_complex n); mpl_complex mpl_ce(mpl_complex z); mpl_complex mpl_cexp(mpl_complex z); mpl_complex mpl_cln(mpl_complex z); mpl_complex mpl_clog(mpl_complex z); mpl_complex mpl_cneg(mpl_complex z); mpl_complex mpl_ckunjugant(mpl_complex z); mpl_complex mpl_cang(mpl_real a); mpl_real mpl_cmodul(mpl_complex z); mpl_real mpl_cargz(mpl_complex z); mpl_real mpl_cImz(mpl_complex z); mpl_real mpl_cRez(mpl_complex z); // RATIONAL MATH mpl_real mpl_rat2real(mpl_rational a); mpl_rational mpl_power(mpl_rational a,mpl_real n); mpl_rational mpl_decrade(mpl_rational r); bool create_table_of_numbers(int n); void delete_table_of_numbers(); bool create_root(mpl_real real,mpl_real *in,mpl_real *out); bool real_to_rational(mpl_real real,mpl_rational *rat,mpl_rational_info *info=NULL,bool use_info=false,bool test=true); #endif